- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2018 05:00 PM
Hello all,
I need to hide a field on my catalog item form and not have it show until my first task. This is a simple catalog item with only catalog task and only a couple of fields on the form.
When I create UI policies I normally hide/show by setting conditions (e.g. request_type is Other, Other field is visible and mandatory). In this case though I'm not sure how to set conditions when all the other fields are showing on the form??
Hope this makes sense and someone can provide guidance?!
Any help greatly appreciated!
Thanks,
Grace
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2018 06:19 PM
Hi Grace
If I understand correctly, you want to hide the variable on catalog form but display it in TASK after submitting request.
If that is the case, in workflow you can select this variable to be displayed in TASK activity and hide the variable through UI Policy (without any condition). also make sure this UI policy applies only on catalog item not on catalog task. these options can be found in Advanced view in UI Policy.
If your requirement is different, my apologies. Would like to help if I understand correctly
Thanks
Ashok Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2018 06:19 PM
Hi Grace
If I understand correctly, you want to hide the variable on catalog form but display it in TASK after submitting request.
If that is the case, in workflow you can select this variable to be displayed in TASK activity and hide the variable through UI Policy (without any condition). also make sure this UI policy applies only on catalog item not on catalog task. these options can be found in Advanced view in UI Policy.
If your requirement is different, my apologies. Would like to help if I understand correctly
Thanks
Ashok Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2018 11:20 AM
Hi Ashok,
Yes this is my exact requirement. I tried your suggestion and it works, only problem is that I need my variable to be mandatory on the task.
I tried setting the variable to mandatory but that makes it show on the form. Once I disabled the mandatory it is not mandatory on the task. Should I create another UI policy for this?
Thanks,
Grace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2018 11:32 AM
Disregard my previous comment. The suggest ui policy is in place and working. The reason for it not setting it to mandatory was because I had a UI policy in place for it to be mandatory when closed complete, etc., but that has been disabled.
Thanks for your help Ashok!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2018 06:47 PM
I don't think you could do it with a UI policy in this case. I think your best option would be an onLoad client script with a GlideAjax call. Try this:
function onLoad() {
g_form.setDisplay('your_field', false);
var ga = new GlideAjax('TaskCheckerAjax');
ga.addParam('sysparm_name', 'hasTasks');
ga.addParam('sysparm_ritm', g_form.getValue('number'));
ga.getXMLAnswer(showField);
function showField(taskExists) {
if(taskExists == 'true') {
g_form.setDisplay('your_field', true);
}
}
}
Then add the following script include and make sure 'client-callable' is checked:
var TaskCheckerAjax = Class.create();
TaskCheckerAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
hasTasks: function() {
var ritmNumber = this.getParameter('sysparm_ritm');
var ritm = new GlideRecord('sc_req_item');
ritm.get('number', ritmNumber);
var scTask = new GlideRecord('sc_task');
scTask.addQuery('request_item', ritm.sys_id);
scTask.query();
return scTask.getRowCount() > 0;
},
type:"TaskCheckerAjax"
});
Hope this works for you!
Update: I had a slight error in the script include as I forgot the GlideRecord get() function returns true or false and not the sys_id of the record. It should hopefully work now. (still didn't test)
Update again: One more tweak, tested it and it works.