Catalog Client Script not working not working in Technical Catalog

GaneshKumar
Tera Guru

Hello Experts,

we have a catalog item requirement , which requires the end user to select an AD group description for accessing  a resource and in the back end the appropriate AD group will get selected and user will get added after the approval is completed.

we are basically querying the Groups table and populating the AD and Approval Groups depending on the selection of description.

 

GaneshKumar_0-1692017259226.png

 

For example if any of yellow ones 'read' or 'change' is selected the approval should go to Manager group, i.e in Green

But if manager (green) was selected there is a default approval group.

 

My initial challenges were to populate the AD group based on description

And then the approval group based on the populated AD group value

using a catalog client script i was able to accomplish that , but the result did not work in Portal but worked in Fulfiller view only.

Then after some research i was able to write a client callable script include to query the groups table and populate group name in the 'Target AD' field.

Now the approval group was the portion where i had to trim the received AD group value to replace CHG /Read to MGR depending on the selection. Since that is something which i do not have to query on the server, i wrote a catalog client script and it worked brilliantly in the portal, but the same is not working in the Fulfiller view.

I mean approval group value is appearing blank on the fulfiller view.

I have enclosed the groups table values, scripts and gif for your understanding.

Below are my scripts , Please advise where can i make corrections so that it could work both on the end user and fulfuller view

This is the script include to query the description based on selected description

 

var GroupUtilsAjax = Class.create();

GroupUtilsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getGroup: function() {
        //var adGrp='';
		var desc = this.getParameter('sysparm_pwd_safe');
		var grp = new GlideRecord('sys_user_group');
		grp.addQuery('description', desc);
        grp.query();

        if (grp.next()) {
           return grp.name;
        }
        
    },

    type: 'GroupUtilsAjax'
});

Once i get the answer from the above script include, the 'Target Ad' value will be set using the 'On-Change' catalog client script below

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
    var ga = new GlideAjax('GroupUtilsAjax');
	ga.addParam('sysparm_name','getGroup');
	ga.addParam('sysparm_pwd_safe',g_form.getValue('pwd_sf'));
	ga.getXML(callback);
	
	function callback(response){
		var answer = response.responseXML.documentElement.getAttribute("answer");
	g_form.setValue('ad_grp',answer);
	
   //Type appropriate comment here, and begin script below
	}
}

Once the above 'Target Ad' value is populated, the Approval group will be populated using another 'On-Change' catalog client script below

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
	var adGrp = g_form.getValue('ad_grp');
	if(adGrp.endsWith('_Change') || adGrp.endsWith('_Read')){
		newAppG = adGrp.replace(/_Change$|_Read$/, '_Mgr');
		
	} else {
		newAppG = 'RMA Approvers';
		
		}
	g_form.setValue('approval_group', newAppG);

 I appreciate your input. Thank you in advance !

1 ACCEPTED SOLUTION

Peter Bodelier
Giga Sage

Have you tried to disable 'Isolate script'?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

2 REPLIES 2

Peter Bodelier
Giga Sage

Have you tried to disable 'Isolate script'?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

GaneshKumar
Tera Guru

@Peter Bodelier Thank you Thank you ..very much . Unchecking the 'Isolate Script' on my populate approval group client script made the value to populate as expected in fulfiller view. I appreciate your quick reply.