Jump to content

Trouble with javascript rule for a Personalized Picture Resource


jdames

Recommended Posts

I have modified the generic javascript that fusionpro generates for a Personalized Picture Resource and it is not working how I expect it to. I want the Personalized Picture from Expression to return the first and last name, but if the last name field is blank, I want it to return the company name. Here is the code. The outcome I'm getting is that the "Dr." is showing up no matter if the last name field is blank or not and I am not getting the company field to show up at all. Any help is much appreciated, this is driving me nuts!

 

 

 

var Pic1 = "Resource1";

var Var1 = "FIRST_NAME";

var Var2 = "LAST_NAME";

var Var3 = "COMPANY";

 

var myPI = Resource(Pic1);

 

if(Var2 != "")

{

myPI.AddData("Dr." + " " + Field(Var1) + " " + Field(Var2));

}

else

{

myPI.AddData(Field(Var3));

}

 

return myPI;

Link to comment
Share on other sites

You need to add Field() to these 3 lines...

 

var Var1 = Field("FIRST_NAME");

var Var2 = Field("LAST_NAME");

var Var3 = Field("COMPANY");

 

And change these lines to...

myPI.AddData("Dr." + " " + Var1 + " " + Var2);

myPI.AddData(Var3);

 

The way you have it, you are setting Var2 to the literal string "LAST_NAME", not a field from your data. That is why Var 2 always != "" and you get Dr. every time.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...