We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Populate the service offering values depends upon the parent of service offering on other variable

shaik mahaboobj
Tera Contributor

Hi 
In my catalog item i have two variables with the name's Service with  reference type to Service_offering table and other one bussiness with type select box with question choice. Here when we select question choice in bussiness then I want to display the service offering values in service variable.
For example:- if I select X in bussiness variable, the  relation ship with service offering table is X is the parent for some of the Service offering that should be display in service variable

 

so.JPG

Here If I select slack in business variable i want to display tes2 in service variable

can you pls help on this  

  

5 REPLIES 5

Devender Kumar
Tera Guru

Hi @shaik mahaboobj ,

Update your Client Script like below.

var business=newValue;
var ga=new GlideAjax('scriptIncludeName');
ga.addParam('sysparm_name','getService');
ga.addParam('sysparm_business',business);
ga.getXML(getResponse);
function getResponse(response)
{
var answer=response.responseXML.documentElement.getAttribute('answer');
            g_form.setValue('service_variable_name', answer);
 
}

 

and Script Include like below.

getService: function()
{
var serviceName='';
var businessName=this.getParameter('sysparm_business');
var grOffering=new GlideRecord('service_offering');
grOffering.addQuery('parent.name',businessName);
grOffering.query();
if(grOffering.next())
{
serviceName=grOffering.getValue('sys_id');
    return serviceName;
}
}

 

If my answer helps to resolve your issue then please mark it as correct and helpful.

Regards,

Devender