#1
|
|||
|
|||
![]()
Attached is a sample data file with Slot1 - Slot68. Each slot could be a voucher or Coupon. The attached image shows what they are trying to do. The first character determines if the page selected is a coupon, voucher or blank. If a voucher then the next three character are the voucher number like SLOT35 in the sample data V203.
If a coupon then the 2-3 character is the coupon code, 4-5 is the Service Type code, 6-11 in the mileage, and 12-15 is the value. Would need to parse each out to include the data into the coupon. Anyone have an idea on how to parse this out via Javascript? I could then turn on and off pages based on the it being a coupon, what version of coupon and/or if blank. |
#2
|
||||
|
||||
![]()
You could use the substr method to parse the values from your string:
Code:
// Your field here. var field = Field('SLOT1'); var type = field.substr(0, 1); switch (type) { case 'V': var code = field.substr(1, 3); break; case 'C': var code = field.substr(1, 2); var serviceCode = field.substr(3, 2); var mileage = field.substr(5, 6); var value = field.substr(11, 4); break; } Code:
// Your field here. var field = Field('SLOT1'); var [type, code, serviceCode, mileage, value] = (field.match(/^(.)(.{2,3})(.{2})?(.{6})?(.{4})?$/) || [,'B']).slice(1);
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#3
|
|||
|
|||
![]()
Thanks Ste. I was going to use a OnRecordStart rule that turns on the correct pages for the slots see example below. To use the parsed data in your example on each page do I need to create a rule for each field and data set I am trying to use? If I want to use Slot2 and value. Do I have to create a rule Slot2CouponValue? and Slot2CouponMileage for the mileage for Slot2?
Quote:
|
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|