- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2019 02:27 PM
Hello all,
I am writing an onSubmit script which will not allow the user to close the task if a variable from the catalog item that I display on the catalog task (I display it by selecting it in the workflow using the slushbucket). I tried using g_form.getValue('variables.variable_name'). This seems to not work...
Any ideas why? I'll post the script below. Also the onsubmit script is also preventing saving/updating..
Script:
function onSubmit() {
if(g_form.getActionName('close_task') && g_form.getValue('short_description') == 'Precheck for Server Snapshot' && (g_form.getValue('variables.mc_storage')!='false' || g_form.getValue('variables.mc_storage')!='true')) {
var val = g_form.getValue('variables.mc_storage');
alert(val.getDisplayValue());
return false;
}
return true;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2019 06:15 AM
Based upon what you describe, I am guessing that you want to have specific variables become mandatory only on a particular task, and only when the record becomes closed. If this is true, we can use a UI Policy on the Catalog Task table (not a Catalog UI Policy) to achieve this. I have done this before, so if this is the case and you want more information, let me know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2019 03:12 PM
Try this script
function onSubmit() {
if(g_form.getValue('short_description') != 'Precheck for Server Snapshot'){
return;
}
if(g_form.getActionName() == 'close_task' && g_form.getValue('mc_storage') =='false') {
alert(g_form.getValue('mc_storage');
return false;
}
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2019 03:26 PM
the g_form.getValue('mc_storage') is blank. guess you can't directly access from task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2019 07:52 PM
Hello Pranav,
If the goal is for individuals to not be able to close out a task until a variable has been populated, I would recommend a simple business rule with an abort action and a gs.addErrorMessage. The can simply set the condition to the state changing to closed complete within the task, and set the BR to only trigger for the specific catalog item. I did this with an example in which I was dealing with a text variable. within the SC Task record (make sure to also make the BR before update, so that it can cancel the submission, you could also make it fancier if need be, where it will proceed with the save but leave the state as Work in Progress and show your desired error message on re-load).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2019 06:15 AM
Based upon what you describe, I am guessing that you want to have specific variables become mandatory only on a particular task, and only when the record becomes closed. If this is true, we can use a UI Policy on the Catalog Task table (not a Catalog UI Policy) to achieve this. I have done this before, so if this is the case and you want more information, let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2023 10:33 AM
If it is at the form level we can make use of
g_form.getValue('field name here');
If it is at workflow or at server side we can make use of
current.getValue() or current.getDisplayValue() or
we can dot walk up to 2 references.
for example: current.assigned_to.email;