If current logged in user in member of assignment group that time particular field will be visible in service catalog item

Hussain Basha
Tera Contributor

If current logged in user in member of assignment group that time particular field will be visible in service catalog item

For this one  how to use script include and for this one you can use only ON-CHANGE client script only

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Hussain Basha ,

try this script

script include which should be client callable and name should be getStandardFields

getStandardFields.prototype = {


  getUser : function() {

var standardFields = new GlideRecord('sys_user_grmember');
standardFields.addQuery('group',this.getParamter('groupId'));
standardFields.addQuery('user',gs.getUserID());
standardFields.query();
return standardFields.next();
},
 type: 'getStandardFields'

};




Client script:

Client script:


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
  return;
  }

  //Type appropriate comment here, and begin script below

var ga = new GlideAjax('getStandardFields');//this is the script include
ga.addParam("sysparm_name", "getUser"); //this is the function within the script include
 ga.addParam("sysparm_groupId", g_form.getValue('assignment_group_field_name'));
 ga.getXML(getResponse);
}
function getResponse(response) {
 var values = response.responseXML.documentElement.getAttribute('answer').toString().split('|');
 if(values=="true"||values==true)
{
g_form.setVisible('your_field_name',true);
}
}
}

Hope this helps

PLEASE MARK MY ANSWER CORRECT IF THIS HELPS YOU

View solution in original post

6 REPLIES 6

Yousaf
Giga Sage

Hi Hussain,

You can use onChange Client script



***Mark Correct or Helpful if it helps.***

Yousaf
Giga Sage

Hi,

To get an idea please refer

isMemberOf function in client script


***Mark Correct or Helpful if it helps.***

Hi , 

Yousaf

 I know whatever you send but I want script on  ON-CHANGE client script

you can use it on onChange client script with a little modification.

Try what mohith sent if the problem persist let us know.


***Mark Correct or Helpful if it helps.***