Assign a catalog task without filling Mandatory variables

jyan3
Kilo Guru

I am trying to allow catalog tasks to be assigned to a user without the mandatory fields being required.

I have one field that needs to be filled in before the catalog task is closed. This is controlled by a Catalog UI Policy

jyan3_0-1720548590456.png

I tried creating a new save button with a UI Action on the sc_task table using code from the below link, but it doesn't seem to work. Maybe it only works on an older version (Current build is Utah)

https://www.servicenow.com/community/developer-forum/saving-a-record-without-populating-all-mandator...

Any help would be appreciated

Thanks

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

I would create a UI action 'Assign to me' and make check mandatory false in that UI action. That way user will be able to assign to the ticket to them and later fill in that mandatory field.

g_form.checkMandatory = false;

 


Please mark this response as correct or helpful if it assisted you with your question.

Isn't that basically what the linked solution is trying to do?
It checks whether the state is 3, which I assume is closed, and if it's not 3, then it sets checkmandatory to false, ignores the variables, and then submits. Is there something wrong with it that I'm missing?

Ohh...I see. So looks like the checkMandatory doesnt work for variables.

I think the solution provided in this thread should work for you to add script in the UI policy

 

https://www.servicenow.com/community/developer-forum/set-variables-mandatory-depending-on-task-state...

SanjivMeher_0-1720559299307.png

 


Please mark this response as correct or helpful if it assisted you with your question.

Community Alums
Not applicable

Hi @jyan3 ,
I think you should go with UI Policy here.

 

Like below-

Execute if true-

function onCondition() {
if(Your_condition) { 
g_form.setMandatory('name_of_computer_on_loan', true);
}
}

 

Execute if false-

function onCondition() {
g_form.setMandatory('name_of_computer_on_loan', false);
}

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar