g_form.getValue is not working in Service Portal Catalog Item

saikatmitra
Tera Contributor

Hi Team ,

 

Need help. I am not sure I have built a catalog item and it works fine in CSM portal but not in service portal For example the below code is not working when running from Service Portal view. The alert is not triggered but it is triggered in CSM. Can you let me know why?? This is really weird.

 

var k =g_form.getValue('type_of_operation');
alert(k);

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please set the UI type =  ALL for your client script

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please set the UI type =  ALL for your client script

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

asifnoor
Kilo Patron

As Ankur already suggested check if UI type is set to ALL.

If yes, then go to browser console and check if there is any error coming there.

saikatmitra
Tera Contributor

Thank you guys, this is really helpful. I am very new to Service Portal. Can you let me know what is the alternative of getXMLWait in Service Portal. This can not be achieved through getXML call I guess.

 

I am running into an issue in processing this script that involves onSubmit validation, it was working fine in CSM portal. Any help will be highly appreciated.

 

if (c =='op_create' && e!='')
{
var agrp1 = new GlideAjax('AppDetails');
agrp1.addParam('sysparm_name','checkCiExist');
agrp1.addParam('sysparm_userID_1',e);
agrp1.getXMLWait();
var populate1 = agrp1.getAnswer();

alert(populate1);
if(populate1 =="failed1"){

}
else{
alert("The request is not fit for CI creation as the selected CI does exist");
g_form.clearValue('type_of_operation');
g_form.clearValue('application_name_1');
return false;
}
}

Hi,

you will have to use getXML()

updated script below

if (c =='op_create' && e!='')
{
var agrp1 = new GlideAjax('AppDetails');
agrp1.addParam('sysparm_name','checkCiExist');
agrp1.addParam('sysparm_userID_1',e);

agrp1.getXML(callBackMethod);

function callBackMethod(response){
    var answer = response.responseXML.documentElement.getAttribute("answer");
            
var populate1 = answer;

alert(populate1);
if(populate1 =="failed1"){

}
else{
alert("The request is not fit for CI creation as the selected CI does exist");
g_form.clearValue('type_of_operation');
g_form.clearValue('application_name_1');
return false;
}    
    
}


}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader