Calling a Script Include from UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 02:49 AM
HI All,
I have a requirement where I need to show the UI action if the logged in user is part of some group and current state of the record is new or assessment. And if the user is not part of that group, then that UI action should only be visible in new state and no other state.
To achieve this, I have written a script include and later called that script include in UI action.
But somehow it is not working.
Could someone help me here to check where I'm going wrong.
Script Include Code(client callable is not checked)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 03:00 AM
Hi Rutusha,
Try below.
UiActionVisibility: function(currObj){
//var memberOfGroup = gs.getUser().isMemberOf('TPX-Connect-ChangeManagement-CORE');
if((gs.getUser().isMemberOf('TPX-Connect-ChangeManagement-CORE')) && ((current.state==-4 || current.state==29 || current.state==-3 || current.state==-2 || current.state==-1))){
gs.info('1st loop');
return true;
}else if(current.state==-5 ){
gs.info('2nd loop');
return true;
}return false;
},
new global.CINotFoundUIActionVisibility().UiActionVisibility();
Also, try replacing name of group with sys_id of group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 03:03 AM - edited 04-30-2024 03:04 AM
Hi @Rutusha ,
You can try below code
In Ui action you have to add this code which client callable
var ga = new GlideAjax('ScriptIncldueName');
ga.addParam('sysparm_name', 'FunctionName');
ga.addParam('sysparm_buildingid', "Parameter_value");
ga.getXML(updateCampus);
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
Script Include (which is client callable)
asu_GetLocationData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
functionName: function () {
var buildingid = this.getParameter('parameter_value');
Your logic
}
});
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 03:35 AM
Check Script Include Invocation: Make sure that the script include CINotFoundUIActionVisibility is properly instantiated and invoked in your UI action script. Ensure that there are no syntax errors or typos in the script include name or method invocation.
Verify Group Membership Check: Double-check that the group name 'TPX-Connect-ChangeManagement-CORE' is correct and that the logged-in user is indeed a member of this group. You can verify this by logging the output of gs.getUser().isMemberOf('TPX-Connect-ChangeManagement-CORE') to ensure it returns the expected value.
Check Current Object Properties: Ensure that the current object passed to the script include method contains the state property and that it represents the correct state of the record. You can log current.state to verify its value during execution.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 04:40 AM
Do you see this UIAction at all? If not maybe its the condition, I'd use something like:
if(new global.CINotFoundUIActionVisibility().UiActionVisibility(current))
P.S. What type is your UIAction ?