Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Reading field and separating data
- This topic has 2 replies, 2 voices, and was last updated 4 years, 3 months ago by T.L. Ford.
-
AuthorPosts
-
September 7, 2020 at 3:00 AM #41876
Jason BolczakParticipantHello To my Much Smarter counter parts,
I am hopping one of you extramly smart programers can help me by either pointing me in the right direction or explain to me how it is done.
What I have is a set of data from an excel form.
Badge #, Name, Trade, Company
This data is in a pick list Just as it is listed above
I would like to select Badge # and have the rest of the information auto fill the correct fields.
Example:
Badge #, Name, Trade, Company
001, John Black, Super Hero, Villain Inc.
002, Smith Bond, Data Clerk, Enterprise Company
003, Kirk Newmonic, Captain, SamsungI pick one or all and this should be what I get:
Field Badge #: 001, 003
Field Name: John Black, Kirk Newmonic
Field Trade: Super Hero, Captain
Field Company: Villain Inc, SamsungCan anyone help?
September 7, 2020 at 7:17 AM #41878
T.L. FordParticipantAs a field level script, it looks like this:
function Characters() { var select_characters = record.getFieldValue('fld-70910404166b458b8147aaf560efb4eb'); var characters = select_characters.split(","); // put into an array so we can easily sort it var characters_array = {}; // jumping by 4, because that's the number of fields for (var index = 0, count = characters.length; index < count; index += 4){ var arr = { characters[index], characters[index + 1], characters[index + 2], characters[index + 3] }; characters_array.push(arr); } characters_array.sort(function(a,b) { if (a[0] > b[0]) { return 1; } if (a[0] < b[0]) { return -1; } return 0; }); var badge = "Field Badge #: "; var fname = "Field Name: "; var trade = "Field Trade: "; var company = "Field Company: "; for (index = 0, count = characters_array.length; index < count; index++){ badge += characters_array[index][0] + ", "; fname += characters_array[index][1] + ", "; trade += characters_array[index][2] + ", "; company += characters_array[index][3] + ", "; } badge = badge.splice(0,-2); fname = fname.splice(0,-2); trade = trade.splice(0,-2); company = company.splice(0,-2); return badge + "\n" + fname + "\n" + trade + "\n" + company; } Characters();
See the attached.
September 7, 2020 at 7:21 AM #41879
T.L. FordParticipantI tried a different browser this time for the upload – it really just doesn’t like my attachments.
http://www.cattail.nu/tap_forms/SplitPicklist.tapforms.zip
– T
-
AuthorPosts
You must be logged in to reply to this topic.