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
Tera Guru

Hi @shaik mahaboobj ,

Create OnChange Catalog Client Script and select the business variable in field.

Write Client Script like below to show the service offering in another service variable.

var business=newValue;
var ga=new GlideAjax('scriptIncludeName');
ga.addParam('sysparm_name','getService');
ga.addParam('sysparm_business',business);
ga.getXMLAnswer(getResponse);
function getResponse(answer)
{
answer=JSON.parse(answer);
for (var a = 0; a < answer.length; a++) { 
            g_form.setValue('service_variable_name', answer[a]);
        }
}

and write 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();
while(grOffering.next())
{
serviceName.push(grOffering.getValue('sys_id'));
    return JSON.stringify(serviceName);
}
}

 

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

Regards,

Devender

shaik mahaboobj
Tera Contributor

Thank you @Devender Kumar  for your quick response its working fine 

Devender Kumar
Tera Guru
Tera Guru

Hi @shaik mahaboobj ,

If my answer helped you to resolve you issue then please mark it as correct and close the thread so that other developers can refer it 

 

Regards,

Devender

Hi @Devender Kumar 

Its working but it also showing all the remaining record also when we search it

bs.JPG

Here when we select Balckbarry it showing test1 its correct but when we explore it show all the service offering values which is not correct it show's only the values which are belongs to parent of blackbarry only.

 

Can you pls cross check it....