How to update the select box variable based on the list collector variable values in servicenow.

Balaram7
Kilo Sage

Hi all,

 

iam stuck with the below requirement can anyone please help me out.

There is a custom table named "u_cost_manage" in that table there are three custom fields.

Supplier (reference) field, branch string field, and partner choice box (True/false)

Below is the requirement in a catalog item,

We have a list collector variable named "Branch" list collector, if the branch records are selected then if one of the records has partner as true, then we need to mark the Trusted partner variable select box (True/false) as true else it should be false.

 

Below is the client script i have tried.

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || !newValue){
    return ;
   }
 var ga = new GlideAjax('CheckTrustedpartner');
 ga.addParam('sysparam_name','check');
 ga.addParam('sysparam_ids',newValue);
 ga.getXML(function(response){
    var answer = response.responseXML.documentElement.getAttribute("answer");
    g_form.setValue('trusted_partner',answer == 'true');
 });


}
 
 
Please help me on this, how to get the trusted partner variable marked as true when one of the list collector record contains the partner field value marked as true.
 
 
Thank you,
Balaram.
1 ACCEPTED SOLUTION

Balaram7
Kilo Sage

Hi all,

 

Thanks all for your responses. i updated the script as shown below and its working as expected.

 
function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || !newValue){
 g_form.setValue('load_to_cmt', false);
   return;
   }
  var ga = new GlideAjax('CheckTrustedpartner');
  ga.addParam('sysparm_name','check');
  ga.addParam('sysparm_branch_ids', newValue);
  ga.getXMLAnswer(function(answer){
//alert(answer);
g_form.setValue('trusted_partner', answer == 'true' ? 'true': 'false');
  });
 
}

View solution in original post

6 REPLIES 6

Balaram7
Kilo Sage

Hi all,

 

Thanks all for your responses. i updated the script as shown below and its working as expected.

 
function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || !newValue){
 g_form.setValue('load_to_cmt', false);
   return;
   }
  var ga = new GlideAjax('CheckTrustedpartner');
  ga.addParam('sysparm_name','check');
  ga.addParam('sysparm_branch_ids', newValue);
  ga.getXMLAnswer(function(answer){
//alert(answer);
g_form.setValue('trusted_partner', answer == 'true' ? 'true': 'false');
  });
 
}

Hello @Balaram7 ,

 

 

Okay , if your query is resolved then accept your own answer and close the thread .