jdames Posted March 25, 2011 Share Posted March 25, 2011 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 More sharing options...
scubajbc Posted March 25, 2011 Share Posted March 25, 2011 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 More sharing options...
jdames Posted March 28, 2011 Author Share Posted March 28, 2011 Thank you. That did the trick! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.