Jump to content

Creating a sub routine.


Recommended Posts

I am creating a title field that has two routines. The first is:

if(Field("Manual Title")== "")

return ""

else

return Field("Title");

 

The second part to this is:

if(Field("Title")== "None")

return ""

else

return Field("Title");

 

Each works fine individually. How do I combine them so that the 'Manual Title field' is checked first, and then if the 'Title field' is defaulted to, it is checked for the word 'None'?

Link to comment
Share on other sites

I'm not sure I understand your first if statement. If the Manual Title field is not populated, you want to return nothing but if it is populated, you want to return the Title field? If that's the case, you can use this code with the second if statement nested within the first:

 

if(Field("Manual Title")== "") {
   return "";
}
else {
   if(Field("Title")== "None") {
       return "";
   }
   else {
       return Field("Title");
   }
}

 

But if you want to return the Manual Title field if it's populated, and return the Title field if it's not, you can try this (commented to detail what it's doing):

// If Manual Title is populated, use it. If not, use Title
var myTitle = (Field("Manual Title") != "") ? Field("Manual Title") : Field("Title");

// If myTitle (the title field being used as defined above) does not have a value of "None",
// set it equal to its value. If it does, set it equal to nothing
myTitle = (myTitle != "None") ? myTitle : "";

// Return the title
return myTitle;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...