- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 03:10 AM
Hi all,
I've got a custom UI action on the sc_task table. I want to include a condition to only make this action display when there is no record matching in a related m2m list.
I've created this function in a script include called 'CdlStandardChange' :
linkedToChng : function(sctask){
var link = new GlideRecord('u_m2m_catalog_task_change_reque');
link.addQuery('u_catalog_task', sctask);
link.query();
if(link.next()){
return true;
} else {
return false;
}
},
I have my condition in the UI Action as:
current.request_item.cat_item == '38190489dbd13240ddb9338ffe9619ed' && !CDLStandardChange().linkedToChng(current.sys_id)
The UI Action is called 'Add to Standard Change' and I only want it to display when there is not change linked to the sctask in the 'u_m2m_catalog_task_change_reque' related list.
The UI action adds a record to this related list, so esentially once the button has been clicked once I want it to no longer display to prevent duplicate entries into the m2m table.
I will then want a different UI Action to appear when a record does exist in the m2m and not display when there is not a record (the opposite logic)
Thanks
Sam
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 03:30 AM
you missed the new operator for the script include call in the UI action condition;
please update as below and test once
!new CDLStandardChange().linkedToChng(current.sys_id)
For making it work in opposite use this
current.request_item.cat_item == '38190489dbd13240ddb9338ffe9619ed' && new CDLStandardChange().linkedToChng(current.sys_id)
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 03:38 AM
Glad to know.
if you think there is any response that helps you please mark that helpful or accepted so that this thread can be closed.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader