Making variable visible after task is closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 07:21 PM
Hello developers,
I need a suggestion as if it is possible to make custom variable visible on RITM once task is closed complete(this variable will be visible on catalog task).Any help is appreciated, Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2024 12:04 PM
Hi @servicenow14710 ,
instead of going the other way around, you can simply create UI Policy on RITM table which make the field visible and mandatory when the ritm state is closed.
I hope this helps..
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 11:55 PM
Let's try to make an OnLoad Client Script and an Ajax call to identify the completed catalog task, then make the variable visible accordingly.
Sample below.
#Script Include
var CLCatalogItemUtilAJAX = Class.create();
CLCatalogItemUtilAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isTaskCompleted: function(){
var ritm = this.getParameter('sysparm_request_item');
var grSCTASK = new GlideRecord('sc_task');
grSCTASK.addQuery('request_item', ritm);
grSCTASK.addQuery('state', 3);
//Suppose the RITM has multiple Catalog Tasks. Apply your own query below to get that specific task
//grSCTASK.addQuery('short_description', '<your_task_short_description>');
grSCTASK.query();
return grSCTASK.hasNext();
},
type: 'CLCatalogItemUtilAJAX'
});
#Client Script
function onLoad() {
var ga = new GlideAjax('CLCatalogItemUtilAJAX');
ga.addParam('sysparm_name', 'isTaskCompleted');
ga.addParam('sysparm_request_item', g_form.getUniqueValue());
ga.getXMLAnswer(function(answer) {
g_form.setDislay('<your_varialbe_name>', answer);
});
}
Cheers,
Tai Vu