Split a long string (every other word) into multiple fields
Hi,
I'm trying to build an advance form that allows in-company ordering of products. The difficulty for most employees is to select the correct 'booking code' properly: which budget and which cost category.
For example: rubber stamps (part of the range of the office supply products) must be booked on B001(budget number) and 1234 (cost category). Short: B001.1234. Second example: pencils (again part of the office supply products) must be booked on B001.1235. This product range is pretty large.
Our source for the correct booking codes is an Excel sheet: column 1 contains product names, column 2 the main category, column 3 the sub-category and column 4 the correct booking code. Example
rubber_stamps; office supplies;postal needs;B001.1234
pencils; office supplies;statiorary;B001.1235
etc.
The idea is to present employees with 3 pull down menu's: main category, subcategory and product.
For maintenance and update purposes, it would be great to import data into the form/these pull down menu's from a file that is easy to maintain and update.
Thus far, I have been able to read data from an attached CSV (the data.csv our controller can make /extract from an Excel sheet, send it to me and I can attach it to the adobe form). Current java code to get the data imported into the sheet works.
var oFile = this.getDataObjectContents("data.csv");
var cFile = util.stringFromStream(oFile, "utf-8");
this.getField("datafield").value = cFile
The result is a field that consists of a long string of text: rubber_stamps, office_supples,postal_needs,B001.1234 pencils,office_supples,stationary,B001.1235.
The problem I'm facing is how to split this data into 4 new data fields, so I can use the first 3 fields to populate the pull down menu's and - based on the 3rd selection (e.g. pencils), fill another field with the correct booking code B001.1235.
Any suggestions / help is very welcome. Thanks in advance.
