I have an application that has multiple companies. There's a lot of information needed to populate drop down boxes and each company wants a little different choices. One prime example is the source for a new customer. There are a lot of things in common between each company but some unique items as well. My idea is to provide a default list and then them copy the default then add the ones they want to their own. Each company has a unique companyID and in my master table of CustomerSourceCodes I have a companyID.
My plan was to designate companyID zero to be the default. Then I would show a list of all the items with a 0 in the companyID, allow the user to copy them and then edit add any unique ones. I have watched all of Selwyn's videos in the series: UXL_V12--21 and it does MOST of what I want. What I need to do is to change the default companyID from 0 to a session variable after the rows are moved to the second list.
I have been trying to write a JS function that would loop through the target list and just change the companyID from 0 to the companyID of the user. I cannot seem to get it to work properly.
Here is my function - or one of the iterations thereof, any suggestions? I have included both versions of my {dialog.object}.setValue statements. This is run after I use the action javascript to move the records from the default list to the current users list.
function updateCOId() {
//Get the CoID from the current user:
var cs = {dialog.object}.getValue('myCOID');
//get the list control to update
var lObj = {dialog.object}.getControl('myCALLSOURCECODES');
//get the data from the control
var xData = lObj._data;
//get the size of the list
var xDLen = xData.length;
//loop and update the CompanyID for each record
for(i = 0; i < xDLen; i++){
{dialog.object}.setValue('CompanyID',cs);
{dialog.object}.setValue('list::myCALLSOURCECODES::CompanyID',cs);
}
}
My plan was to designate companyID zero to be the default. Then I would show a list of all the items with a 0 in the companyID, allow the user to copy them and then edit add any unique ones. I have watched all of Selwyn's videos in the series: UXL_V12--21 and it does MOST of what I want. What I need to do is to change the default companyID from 0 to a session variable after the rows are moved to the second list.
I have been trying to write a JS function that would loop through the target list and just change the companyID from 0 to the companyID of the user. I cannot seem to get it to work properly.
Here is my function - or one of the iterations thereof, any suggestions? I have included both versions of my {dialog.object}.setValue statements. This is run after I use the action javascript to move the records from the default list to the current users list.
function updateCOId() {
//Get the CoID from the current user:
var cs = {dialog.object}.getValue('myCOID');
//get the list control to update
var lObj = {dialog.object}.getControl('myCALLSOURCECODES');
//get the data from the control
var xData = lObj._data;
//get the size of the list
var xDLen = xData.length;
//loop and update the CompanyID for each record
for(i = 0; i < xDLen; i++){
{dialog.object}.setValue('CompanyID',cs);
{dialog.object}.setValue('list::myCALLSOURCECODES::CompanyID',cs);
}
}
Comment