in servicenow, my script include and client script is not working please check var…
- User
in servicenow, my script include and client script is not working please check
var GetCIServiceForCatalog = Class.create(); GetCIServiceForCatalog.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getServiceRecord: function() { var gr = new GlideRecord('cmdb_ci_service'); if (selectValue == 'salehubplus') { gr.addQuery('name', 'SALESHUB+ - HANDHELDNEXT - SO'); } else if (selectValue == 'salesproplus') { gr.addQuery('name', 'SALESPRO+ - SO'); } gr.query(); if (gr.next()) { return gr.getValue('sys_id'); } // Return the service record if found }, type: 'GetCIServiceForCatalog'});
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue !== '') { return; } if (newValue) { var ga = new GlideAjax('GetCIServiceForCatalog'); ga.addParam('sysparm_name', 'getServiceRecord'); // Call the function in the Script Include ga.addParam('selectValue', selectedValue); // Pass the selected value to the Script Include ga.getXML(service); }
function service(response) { var answer = response.responseXML.documentElement.getAttribute("answer"); g_form.setValue('service_offering', answer); }}
- Assistant
- User
not working please change the format
- Assistant
- User
variable and parameter is confusing var selectValue = this.getParameter('selectValue');
- Assistant
- User
see this is not working and i dont know why we repeat same code again and again, just listen freshly, based on variable 1 of type selectbox and 2 choices , based on these i need to set the value of variable 2 of type reference. Example if App Name has value apple then i need to set Service as Bike by searching it by name in cmdb_ci table
- Assistant
- User
name is SALESPRO+ - SO and it is available when i manually search it but return alert
- Assistant
- User
it is still clearing the value of the field
- Assistant
- User
lets start again,
i have 3 variables = AppName , Service Offering ,Assignment Group I need to set ServiceOffering and Assignment Group reference variable based on AppName choices, Choices are like that
if AppName is "SalesHub+" then Service Offering is "SALESHUB+ - HANDHELDNEXT - SO" and Assignment Group is "SALESHUB PLUS SUPPORT"
- Assistant
- User
this is working but not working on esc service portal
- Assistant
- User
how to set these values with the help of script include and client script
- Assistant
- User
not changing the values of reference fields
- Assistant
- User
not working with script include, it is working on client side only
- Assistant
- User
please try another approach, donot provide the same code again and again
- Assistant
- User
but this is not working on customer portal
- Assistant
- User
it is working in try portal but not on main escportal
- Assistant
- User
this script include and client script is working but only 1 time , now it is setting different record only business warehouse even after changing the values,
Script include: var ServiceDetailsProvider = Class.create(); ServiceDetailsProvider.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getServiceOffering: function() { var result = {}; var cmdbCI = new GlideRecord('cmdb_ci_service'); var appValue = this.getParameter('sysparm_appName'); if (appValue == 'salesleadplus') { cmdbCI.addEncodedQuery('name=STORE FACTS ON DEMAND - SO'); } cmdbCI.query(); if (cmdbCI.next()) { result.sys_id = cmdbCI.getUniqueValue(); } return JSON.stringify(result); }, type: 'ServiceDetailsProvider'});
Client Script: function onChange(control, oldValue, newValue, isLoading) { // Don't run if the form is loading or if no new value is selected if (isLoading || newValue == '') { return; }
var appName = g_form.getValue('app_name'); if (newValue) { var serviceOff = new GlideAjax('ServiceDetailsProvider'); serviceOff.addParam('sysparm_name', 'getServiceOffering'); serviceOff.addParam('sysparm_appName', 'appName'); serviceOff.getXMLAnswer(function(result) { var response = JSON.parse(result); g_form.setValue('service_offering', response.sys_id); }); } - Assistant