Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 20th, 2018, 08:22 AM
indum@glynndevins.com indum@glynndevins.com is offline
Junior Community Member
 
Join Date: Jan 2018
Location: Kansas City, MO
Posts: 15
Default Drop down List with Open Text Choice

Hi,

I'm trying to figure out if there is an easier way to accomplish what we are doing. Example...we are working on Memorial Day postcard and there is a data field Header and we also offer HeaderCustom field (in case user doesn't want to use our pre-written copy they can add their own). Then we have Copy and CopyCustom and so on. On Marcom Side this needs to be a drop down for user to either pick our copy or Custom. Right now we are using .txt file and uploading to MarcomCentral and creating drop down list with the value to pull from that XDF file... the rule looks something like this...


Header = "";

var XDF = new ExternalDataFileEx("PostcardContent.txt", "\t");

for (i = 1; i < XDF.recordCount+1; i++)
{
Option = XDF.GetFieldValue(i, 0);

{
if (Field("Header") == Option)

{
Header = XDF.GetFieldValue(i, 1);
}
}

}

return Header;


and...

var var1 = Rule("Rule HeaderContent");
var var2 = Field("HeaderCustom");


if (var1=="") {
var1 = var2;
} else {
var1 = var1;
}

return var1;


Is this the best practice for what we are doing or is there another way this can be done without XDF file maybe? Thank you,
Reply With Quote
  #2  
Old April 20th, 2018, 02:33 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Drop down List with Open Text Choice

Because your site is sending back the "option" the user selected rather than the value of the option the user selected, I think you'll have to continue referencing the external data file.

That being said, you can certainly simplify things. You consolidate your two "header" rules into one:
Code:
var XDF = new ExternalDataFileEx("PostcardContent.txt", "\t");
return XDF.GetFieldValue(XDF.FindRecord(0, Field('Header')), 1) || Field('HeaderCustom');
The above code will search for a value in the first column of your data file that matches the value of the "Header" field. If found, the corresponding value of the second column will be returned. If nothing is found, it will return the value of the "HeaderCustom" field.

I set that up in accordance to the rule you supplied but I would think the value of the custom field would take precedence over the pre-written options. If that's the case, you can just reverse the order:
Code:
var XDF = new ExternalDataFileEx("PostcardContent.txt", "\t");
return Field('HeaderCustom') || XDF.GetFieldValue(XDF.FindRecord(0, Field('Header')), 1);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old April 23rd, 2018, 07:43 AM
indum@glynndevins.com indum@glynndevins.com is offline
Junior Community Member
 
Join Date: Jan 2018
Location: Kansas City, MO
Posts: 15
Default Re: Drop down List with Open Text Choice

Thank you Step! That's good to know.
Reply With Quote
  #4  
Old April 23rd, 2018, 12:47 PM
indum@glynndevins.com indum@glynndevins.com is offline
Junior Community Member
 
Join Date: Jan 2018
Location: Kansas City, MO
Posts: 15
Default Re: Drop down List with Open Text Choice

That being said, you can certainly simplify things. You consolidate your two "header" rules into one:
Code:
var XDF = new ExternalDataFileEx("PostcardContent.txt", "\t");
return XDF.GetFieldValue(XDF.FindRecord(0, Field('Header')), 1) || Field('HeaderCustom');

OK got stuck with this lol...Is it possible to add a replace substring to the code above? I know how to do this as two separate rules, but can it be done as one to simplify code further?
This is what I have for HeaderReplace rule...

var s = Rule("Rule Header");

s = ReplaceSubstring(s, "[COMMUNITY NAME]", Field("Community Name"));
s = ReplaceSubstring(s, "[RSVP]", Field("RSVPPhone"));
return s;
Reply With Quote
  #5  
Old April 23rd, 2018, 02:05 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Drop down List with Open Text Choice

Code:
var XDF = new ExternalDataFileEx("PostcardContent.txt", "\t");
var s = XDF.GetFieldValue(XDF.FindRecord(0, Field('Header')), 1) || Field('HeaderCustom');
s = ReplaceSubstring(s, "[COMMUNITY NAME]", Field("Community Name"));
s = ReplaceSubstring(s, "[RSVP]", Field("RSVPPhone"));
return s;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old April 23rd, 2018, 02:20 PM
indum@glynndevins.com indum@glynndevins.com is offline
Junior Community Member
 
Join Date: Jan 2018
Location: Kansas City, MO
Posts: 15
Default Re: Drop down List with Open Text Choice

Thank you once again...I was so close LOL
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:38 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.