Skip to main content

Posts

Showing posts with the label ajax

ServiceNow AJAX Client Script Include not working for user with no roles

 ServiceNow AJAX Client Script Include not working for user with no roles reproducible when impersonating that user solution: include this snippet in the client callable script include  isPublic: function() {         return true;     },   otherwise you may get a javascript error in browser console message and the AJAX function call will return null

ServiceNow select a user role on this client callable script include message

ServiceNow select a user role on this client callable script include see  https://www.servicenow.com/community/now-platform-articles/privacy-on-client-callable-script-includes-instance-security/ta-p/2386648 https://docs.servicenow.com/bundle/vancouver-platform-security/page/administer/security/reference/privacy-on-client-callable-script-includes.html f needed, you can change the privacy setting for an individual client-callable script include by adding the  isPublic()  function. The  isPublic()  setting takes precedence over the  glide.script.ccsi.ispublic property . For example, if you set  isPublic()  to true in an individual script, it makes it public, which overrides the  glide.script.ccsi.ispublic  property that makes all other client-callable script includes private isPublic:function(){return[true/false];}, https://docs.servicenow.com/bundle/utah-platform-security/page/administer/security/reference/privacy-on-client-callable-script...

ServiceNow GlideAjax: 4 approaches (single value, multiple values)

ServiceNow GlideAjax: 4 approaches (single value, multiple values) single return value multi return values multi return values using ARRAY object multi return values using JSON object   CLIENT SCRIPT   function onLoad () {     //--uncomment just one of below to test     //ajax1();     //ajax2();     //ajax3();     ajax4 (); } function ajax1 () {     var ga = new GlideAjax ( 'rds_testajax' );     ga . addParam ( 'sysparm_name' , 'getUserDetails_singleVal' );     ga . getXMLAnswer ( function ( answer ) {         alert ( 'AJAX CALL 1' );         alert ( 'AJAX SINGLE VAL return: ' + answer );     }); } function ajax2 () {     var ga2 = new GlideAjax ( 'rds_testajax' );     ga2 . addParam ( 'sysparm_name' , 'getUserDetails_multiVals' );     ga2 . getXML ( function ( serverResponse ) {       ...

AJAX call example 1a: return multiple values (Using JSON)

AJAX call example 1a: return multiple values (Using JSON)  alternative approach to returning multi values on Ajax call client script try { if ( newValue == '' ) { return ; } var ga = new GlideAjax ( 'UserClientScriptUtil' ); ga . addParam ( 'sysparm_name' , 'getUserDetails' ); ga . addParam ( 'sysparm_user_sysid' , g_form . getValue ( 'Requested_for' )); ga . getXML ( function processdata ( response ) { var answer = response . responseXML . documentElement . getAttribute ( "answer" ); if ( answer ) { answer = JSON . parse ( answer ); g_form . setValue ( 'Email_Address' , answer . displayEmail ); g_form . setValue ( 'phone_number' , answer . phone ); g_form . setValue ( 'department_details' , an...