- 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: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 07:38 PM
Thank you@Mohith Devatte