Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is two-way synchronization between two catalog variables technically supported inside Service Portal

profile
Tera Contributor

Is two-way synchronization between two catalog variables technically supported inside Service Portal.

I have two catalog variables inside a variable set:

euid (text)

associate_name_common (reference to sys_user)

Both fields need to stay synchronized:

When the user enters an EUID, the script should populate associate_name_common.

  1. When the user selects associate_name_common, the script should populate EUID. This is not works correctly in Maintain Item view and Service Portal (Try It)

Important details:

Both variables are on a variable set, used on 25 items

Using onChange Catalog Client Scripts

Using GlideAjax + Script Include

Even with flags like:

g_form.setParameter('sysparm_skip_euid_update')

window._lock

g_scratchpad

isLoading

→ the loop continues in Service Portal and Maintain Item view(platform ui) view.

I want solution to this problem. Please, anyone help me out from this problem

Below I am attaching my Catalog Client Scripts and Script Include.

I have tried by creating all the server side script include code in one script include itself it doesn't work 

And both script include code are Client callable.

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@profile 

share scripts here and not the screenshots of the script.

it becomes difficult to go through them 1 by 1 and we can't even copy the script to debug or help

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

profile
Tera Contributor

var UserLookupAjax = Class.create();

UserLookupAjax.prototype = Object.extendsObject(AbstractAjaxProcessor,

getUserByEUID: function() {

var euid = this.getParameter('sysparm_euid');

if (!euid) {

return '';

}

var user = new GlideRecord('sys_user');

user.addQuery('u_euid', euid);

user.query();

if (user.next()) {

return user.sys_id;

}

return '';

},

type: 'UserLookupAjax'

});

 

var UserLookupEUID = Class.create();

UserLookupEUID.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getEUIDByUserSysId: function() {

var sysId = this.getParameter('sysparm_user_sysid');

if(!sysId) {

return '';

}

var user = new GlideRecord('sys_user');

if(user.get(sysId)) {

return user.u_euid.toString();

}

return '';

},

type: 'UserLookupEUID'

});

 

function onChange (control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') {

return;

}

// Type appropriate comment here, and begin script below

var ga = new GlideAjax('UserLookupEUID');

ga.addParam('sysparm_name', 'getEUIDByUserSysId');

ga.addParam('sysparm_user_sysid', newValue);

ga.getXMLAnswer (function(response) {

if (response) {

g_form.setValue('euid', response);

} else {

g_form.setValue('euid', '');

}

});

}

 

function onChange (control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') {

return;

}

var ga = new GlideAjax ('UserLookupAjax');

ga.addParam('sysparm_name', 'getUserByEUID');

ga.addParam('sysparm_euid', newValue);

ga.getXMLAnswer (function(response) {

if (response) {

g_form.setValue('associate_name_common', response);

} else {

g_form.setValue('associate_name_common', '');

}

});

 

}