I’m trying to wrap my mind around a problem, need some help.
5 clients have a set of 10 records each withinin a table, for a total of 50 records. Each record has a unique text “key”, plus an integer field. Thus each client has a unique key reading “abc”, “def”, etc.
In effect a double array something like this:
abc 1
def 0
ghi 1
The task is to store this “double array” for one of the five clients and then loop through all 50 records making them all have equivalent values as those of the target client. I understand JavaScript doesn’t support multi-dimensional arrays. Is there a workaround? Right about here I’m feeling out of my depth. Pointers appreciated.
By the way, I can’t assume that Client #2 will have their set of 10 records in the same sequence as the target client’s set. Therefore I will need to locate client #2’s “abc” record within the double array before setting the integer field.
Thanks Maarten, but I don’t see where to set the calls for the specific fields I want to insert into the two-dimensional array. I’ve spent time on a JavaScript forum looking for clarification and your code was not understood by the folks there.
I’ve tried various experiments, the best so far being:
var a = new Array(4)
var c = controller.getSelectedIndex();
for (i=0; i < 4; i++)
{
a[i] = new Array(4)
for (j=0; j < 4; j++)
{
a[i][j] = [catkey,tick];
controller.setSelectedIndex(c++);
}
}
Although it pulls in the correct data the comma separators are erratic, highly irregular. Sorry, but I’m still quite green at JavaScript.
I should also ask another related question. My purpose for this routine is to pick up a set of “standards” and copy them to other clients. It’s possible that there could be more than a thousand “stardards” records. Is an array practical for this purpose? If not, what alternatives should I explore?
I’ve checked your code on the companies table of the crm demo using company_name,company_type instead of catkey,tick and it works fine.
But let’s go back to the get a clearer picture of what you want to achieve.
client_id text int
1000 abc 1
1000 def 0
1000 ghi 1
…up till 10 records
1001 djr 1
1001 fkd 0
…up till 10 records
…
…up till 5 client_id’s
Is this a correct representation of your table?
And if so,
what exactly do you want the script to do?
Please show me how the above list should look like after the script is run.
I’m part way through implimenting a nested category structure. One table holds the category definitions (for the purposes of discussion 10 records, could be much more), a second line items table holds a set of 10 records for each client. A “key” field is in common between the “definitions” table and the line items table. The current problem is to enable the end user to mark up the required categories for one client record and then have these settings imposed on the remaining records currently browsed.
Because the sequence of the line item records may vary a simple loop won’t cut it. Therefore I’ve been assuming the way go is to pick up the two significant fields of the target set into an array and then loop through the required records, imposing the matching tickmark field as found.
Does this make sense? I’m feeling somewhat beyond my depth, but everything up to this point is working well. One of my concerns is how well this structure will deploy as the end user adds and removes categories from time to time.
By the way, the “one” field in the CRM is more useful than the “company_type” field for similating the integer field.