- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 08:46 AM
Hello:
The following is what I need to accomplish:
Table: [Interaction]
Application: ITSM Workspace & Customer Service
Within the Agent Workspace Interaction there are a few UI Actions:
Create Incident - App: ITSM Workspace & Create Case - App: Customer Service
I need to deactivate these 2 and create a new one Called: Create Ticket. This new UI Action should either create an Incident or a Case based on the Field: Account, if the account is such, generate an incident if it's this other then generate a Case.
I am puzzled about how to start this if I need to code everything in one UI Action? Or if I should create 2 UI Actions with the same name (Create Ticket) and then SHOW or HIDE based on the Account?
Please help; I would greatly appreciate any help with the Code that I would need for the UI Action or the conditions.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 08:57 AM
Hi Morrix,
I recommend creating two UI actions based on the condition. Please refer below link to get started.
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 11:03 AM
You are very welcome Morrix. Would you mind marking my response as correct if I am able to resolve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 11:47 AM
Hi Pradeep:
I marked it. I have one more question, what if the field I need to set the condition against is a user reference field and instead of using the company as the condition for the UI Action I need the Role of the person on that field, which is called Contact.
Would something like current.contact == gs.hasRole('snc_external') work?
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 12:57 PM
Hi Morrix - You need to validate this via GlideRecord call to the sys_user_has_role by passing contact user to check if he has the right roles or not. This could be done via Script include where you can handle all the logic and return true or false output. Once you have the script you can then call the Script Include from UI action condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 01:32 PM
Hi:
Any chance you have a script like that? or point me out where to find it? I have not been able to make it work and I am not an expert coding yet, i defend myself but this is kicking my butt.
I started like this but i dont think is working
var RoleChecker = Class.create();
RoleChecker.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
verifyExternalRole: function(){
var gr = newGlideRecord('sys_user_has_role');
gr.addQuery('user', user_id);
gr.addQuery('role','940ba702933002009c8579b4f47ffbe2'); //sys_id of snc_external
gr.query();
return gr.next();
},
_verifyInternalRole: function(){
var gr = newGlideRecord('sys_user_has_role');
gr.addQuery('user', user_id);
gr.addQuery('role','7fcaa702933002009c8579b4f47ffbde'); //sys_id of snc_internal
gr.query();
return gr.next();
},
type: 'RoleChecker'
});
Condition: new RoleChecker()._verifyInternalRole(current.contact)
condition: new RoleChecker().verifyExternalRole(current.contact)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 01:41 PM
Sure. Below please find the updated Script Include Code.
Ui Action condition : new RoleChecker()._verifyInternalRole(current.contact)
Script Include:
var RoleChecker = Class.create();
RoleChecker.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
verifyExternalRole: function(contact){
var gr = newGlideRecord('sys_user_has_role');
gr.addQuery('user', contact);
gr.addQuery('role','940ba702933002009c8579b4f47ffbe2'); //sys_id of snc_external
gr.query();
return gr.next();
},
type: 'RoleChecker'
});