PDA

View Full Version : I'm Having Trouble with a rule overriding my phone format rule


Brad Sawatzky
January 6th, 2009, 09:44 AM
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.

pklingler
January 6th, 2009, 11:24 AM
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 != "")
{dirOut += " Dir Fax " + Field("Phone4");}
else
{dirOut += "Dir Fax " + Field("Phone4");}
}
return dirOut;

Brad Sawatzky
January 6th, 2009, 02:32 PM
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;