Go Back   PTI Marketing Technologies User Community > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 4th, 2017, 01:28 PM
aaron@supremeworks.com aaron@supremeworks.com is offline
Junior Community Member
 
Join Date: Oct 2008
Location: Seattle, WA
Posts: 49
Default Counting contents of fields

I have a customer that is having a dinner. I was hoping to get some help with a rule that would count the different meal choices in the different columns (one column for each guest) and return a result something like: 1 Steak, 1 Halibut

Sample data attached.

thanks

Aaron
Attached Files
File Type: zip Oct 12th RSVP Meal Choices by Name.xlsx.zip (21.7 KB, 7 views)
__________________
Aaron Nissalke
Digital Print Specialist

FP 9.3.36 / Acrobat X / OSX 10.11.6
Reply With Quote
  #2  
Old October 4th, 2017, 04:20 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 954
Default Re: Counting contents of fields

Maybe this would do the trick:
Code:
var result = [];
var meals = {};
var fields = ["Guest Entree", "2nd Guest", "3rd Guest", "4th Guest", "5th Guest", "6th Guest", "7th Guest"]
              .map(Field).filter(String).forEach(function(s){ meals[s] = meals[s] + 1 || 1 });

for (var mealChoice in meals)
  result.push((count = meals[mealChoice]) + ' ' + mealChoice + (count > 1 ? 's' : ''));

return result.join('<br/>\n');
__________________
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 October 6th, 2017, 12:56 PM
aaron@supremeworks.com aaron@supremeworks.com is offline
Junior Community Member
 
Join Date: Oct 2008
Location: Seattle, WA
Posts: 49
Default Re: Counting contents of fields

Thanks Step!

That worked great!
__________________
Aaron Nissalke
Digital Print Specialist

FP 9.3.36 / Acrobat X / OSX 10.11.6
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 11:28 AM.


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