Auto populate MVRS variable on basis of a variable outside it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 08:38 AM
Hi All,
I'm trying to auto-populate the "SAP Cost center" variable inside the mvrs based on the option selected in a reference field called "Company code" which is outside mvrs. In the company code variable, when code is selected, the location should autopulate in the 'sap_cost_center' field which is inside a MVRS(Multi Row).
I'm trying to set the value like below, but it isn't working.
Script Include:
sap:function()
{
var companycode=this.getParameter('sysparm_company');
var gr=new GlideRecord('core_company');
gr.addQuery('name',companycode);
gr.query();
if(gr.next())
{
var ans=gr.location;
return ans;
}
},
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('populateaddress');
ga.addParam('sysparm_name', 'sap');
var com = g_form.getValue('sap_purchase');
ga.addParam('sysparm_company', com);
ga.getXML(callBackFunction);
function callBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('sap_cost_center_mr', answer);// this is the MVRS variable
}
}
When tried with alert, we are getting the location value but unable to set the value in to the MVRS variable. Can anyone please guide me on this.
Thank you in Advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 04:15 AM
If the MRVS is populated, the first line should be retrieving a JSON formatted string of all of the variable names and values for each row, and this is the format you have to match when re-populating it with the answer value. If the first alert is empty the MRVS internal name must not be 'multirow_variable'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 05:22 AM
Hi @Brad Bowman , the internal name is actually multirow_variable