Making a single Catalog Item Variable Mandatory when SCTASK is closed

Joe Taylor
Giga Guru

HELP!

I want to make a single Catalog Item Variable mandatory only when I try to close the SCTASK.

Since it's only on one Item, I don't want to make a global change in the "Close SCTACK" UI actions.

I think the "Catalog UI Policy" definition is the way to go here.

Variable name is "active_directory_user_id".

My Catalog conditions are when "activity_directory_user_id" is empty and only applied to Catalog Tasks.

The script looks like this:

UI Type: Desktop

Execute if true:

function onCondition() {
var ritm= g_form.getReferenec("request_item");

if((g_form.getValue('state')==3) && (ritm.cat_item=='6c680c8c1b98b300c7ad8622dd4bcb88'))

if(g_form.getValue('variables.active_directory_user_id')=='')

g_form.setMandatory('variables.active_directory_user_id',true);

return false;

}

What else to I need to do to get this to work?

 

5 REPLIES 5

Brian Lancaster
Tera Sage

I'm not sure this is achievable.  I have never been able to get a catalog client script to run on the sc_task or sc_req_item level.  In the past what I have done is make it so this variable is only visible on the catalog task and request item level using a UI policy and then inside the workflow I use an if to verify the field was filled out and if it was not I use a roll back to send it back to the task so it cannot be close.  Example screenshot of my workflow below.

find_real_file.png

Surendra Poosa1
Kilo Expert

This can be done via 2 step process :

1. Business Rule to check the current workflow activity - make sure you specify your filter conditions

(function executeRule(current, previous /*null when async*/) {

g_scratchpad.wf_activity = current.wf_activity.getDisplayValue();

})(current, previous);

 

2. Client script OnChange of State - call a function - 
if state == 3 and g_scratchpad.wf_activity == your taskname 

then g_form.setMandatory('variables.active_directory_user_id',true);

 

 

Joe Taylor
Giga Guru

Thanks Brian.  That workflow worked just as you said except for a couple of things:

1)  This rolls back correctly to the previous "Open" state, but My work notes are only updated after the person correctly fills in the required variable in the task.

2) The SCTASK window closes after you click on "Close Task" and unless the agent is paying close attention, he probably won't notice that it's still open.  I'd really like the task window to stay open and get the warning on the screen (just like when you try to close an Incident without filling out the resolution code.)

I'm not sure what you are looking for with your fist question.  for number two you would need to update the close task UI action to have the added code of action.setRedirectURL(current); before the current.update().