Jump to content

Recommended Posts

Posted

Is there a way to suppress a field with no data?

 

I'm working with an XDF which pulls in Address information. For those addresses with two lines, there is a line break between Field("Addr1") and Field("Addr2"). Some addresses have two lines, some only one. Is there a way to suppress when the Addr2 field is empty?

Posted

Lisa,

The easy way to do it is in the rule pulling the XDF data for the address, return the data validating the existence of Addr2 and use tags for format control:

if (Addr2 != "")

{

return Addr1+"<p>"+Addr2+"<p>"+City+", "+State+" "+Zip;

}

 

else if (Addr2 == "")

{

return Addr1+"<p>"+City+", "+State+" "+Zip;

}

Posted

Thanks for the response, Rich.

 

I think I might be using old code for XDF because my rule is set up in a way where I'm not sure where to add this. Here is my code:

 

returnStr = '';
if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)
{
   Rule("OnJobStart");
}
numRecsExtDF = externalDF.recordCount;

for (recordWalker=1; recordWalker <= numRecsExtDF; recordWalker++)
{
   if (externalDF.GetFieldValue(recordWalker, 'LocationCity') == Field("Address"))
   {
     if (Field("Address") =="")
       {
           return "";

       }
       else
       {
           returnStr += externalDF.GetFieldValue(recordWalker, 'LocationAddress');
           returnStr += externalDF.GetFieldValue(recordWalker, 'LocationAddress2');
           returnStr +='<br>'
           returnStr += externalDF.GetFieldValue(recordWalker, 'LocationCity');
           returnStr += ', ';
           returnStr += externalDF.GetFieldValue(recordWalker, 'LocationState');
           returnStr += ' ';
           returnStr += externalDF.GetFieldValue(recordWalker, 'LocationZip');
       }
   }
}


return returnStr;

Posted

The link below has an example job. Here is the JS rule for the Address Info:

//XDF is defined is in OnJobStart

if (FusionPro.inValidation) //this tells the script to run OnJobStart

Rule("OnJobStart");

 

 

Address1 = ""; //initializing the variables we will use below

Address2 = "";

City = "";

State = "";

Zip = "";

 

 

 

for (i = 1; i < XDF.recordCount+1; i++)

//i is established as a numeric value that we will cycle through until it reaches the end record

//header is zero, so look at row 1 (i=1), look at rows for all records plus 1 because we started at 1, increment by 1 (i++)

 

{

T2Toffice = XDF.GetFieldValue(i, 0); //where in XDF T2Toffice is the first column in the data

{

if (Field("Office Location") == T2Toffice)

{

Address1 = XDF.GetFieldValue(i, 1);

Address2 = XDF.GetFieldValue(i, 2);

City = XDF.GetFieldValue(i, 3);

State = XDF.GetFieldValue(i, 4);

Zip = XDF.GetFieldValue(i, 5);

}

}

}

 

if (Address2 != "")

{

return Address1+"<p>"+Address2+"<p>"+City+", "+State+" "+Zip;

}

 

else if (Address2 == "")

{

return Address1+"<p>"+City+", "+State+" "+Zip;

}

XDF Lookup Example
Posted
I think I might be using old code for XDF because my rule is set up in a way where I'm not sure where to add this.

I don't see where to add code either. The information in your two posts seems contradictory. In your first post, you specifically mention fields named "Addr1" and "Addr2":

I'm working with an XDF which pulls in Address information. For those addresses with two lines, there is a line break between Field("Addr1") and Field("Addr2"). Some addresses have two lines, some only one. Is there a way to suppress when the Addr2 field is empty?

Then in your follow-up, you post some code which doesn't seem to reference those same field names at all. Do you mean these fields?

returnStr += externalDF.GetFieldValue(recordWalker, 'LocationAddress');

returnStr += externalDF.GetFieldValue(recordWalker, 'LocationAddress2');

Because I sure don't see where there's a line break between them.

 

Are you sure that the code you posted is what's generating the output you want to change? :confused:

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...