How to access a variable on a catalog task?

PranavSuj96
Mega Expert

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;
}

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

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.

View solution in original post

34 REPLIES 34

JavaScript Executor window by pressing <Control><Shift><Alt><j> is super cool!

Phuong Nguyen
Kilo Guru

Hi PranavSuj96,

You might need to use g_scratchpad to get a list of variables you need or use AJAX to retrieve the variables from client script.

Thanks,

Phuong

Okay seems like ajax is the answer. How can I get the RITM number from the task?

Hi PranavSuj96,

Before doing that, try this: 

g_form.getValue('variableName');

replace variableName with the actual name of your variable. Notice there is no need to variables.variableName

Thanks,

Phuong

for a reference field use this:

g_form.getDisplayBox('variableName').value;

Let me know how it goes 🙂

Thanks,

Phuong

 

 

PS: I did not see your question about getting the RITM number, simply use

g_form.getDisplayBox('request_item').value;