- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-23-2022 10:56 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-23-2022 11:31 AM
Hello
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-23-2022 11:07 AM
Hi Hussain,
You can use onChange Client script
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-23-2022 11:16 AM
Hi,
To get an idea please refer
isMemberOf function in client script
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-23-2022 11:21 AM
Hi ,
I know whatever you send but I want script on ON-CHANGE client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-23-2022 12:09 PM
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.***