Jump to content

with a rule overriding my phone format rule


Recommended Posts

I'm building a business card template, and I'm having trouble with a rule overriding my phone format rule. The current rule looks like this:

var dirOut = "";

if (Trim(Field("Phone3")) != "") {dirOut += "Dir " + Field("Phone3");}

if (Trim(Field("Phone4")) != "") {if (dirOut != "") {dirOut += " Dir Fax " + Field("Phone4");}

else {dirOut += "Dir Fax " + Field("Phone4");

}

}

return dirOut;

If anyone has any ideas, I'm open to suggestion.

Link to comment
Share on other sites

I'm not sure exactly what you're trying to do, but the first thing I see is that no matter what the status of Phone4, you're adding the same thing. You might try removing or editing the else statement, and see if that helps.

 

var dirOut = "";
if (Trim(Field("Phone3")) != "") 
{dirOut += "Dir " + Field("Phone3");}
if (Trim(Field("Phone4")) != "") 
{
if (dirOut != "") 
[color=red]{dirOut += " Dir Fax " + Field("Phone4");}[/color]
else 
[color=red]{dirOut += "Dir Fax " + Field("Phone4");}[/color]
}
return dirOut;

Link to comment
Share on other sites

What I was trying to do was to incorporate a phone format rule into an existing rule, and as funny as it looked the rule I first posted worked like a charm with the exception of the phone format. After considerable weeping and gnashing of teeth, we came up with this:

<i>var dirOut = "";

if (Trim(Field("Phone3")) != "") {dirOut += "Dir " + (Rule("Phone3 Format Rule"));}

if (Trim(Field("Phone4")) != "") {if (dirOut != "") {dirOut += " Dir Fax " + Rule("Phone4 Format Rule");}

else {dirOut += "Dir Fax " + Rule("Phone4 Format Rule");

}

}

return dirOut;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...