workflow script - Set field Mandatory

brown9394
Tera Expert

Hello Experts,

Is it possible to set a field on the demand form mandatory through the workflow between tasks? Before task can be closed out, I want 'u_manager' field to be mandatory before a task can be closed. I cannot do this with a UI policy on demand form on state change, because this state has 3 different tasks, and u_manager field needs to be mandatory before the last task closed. Any ideas?

Basically after the 'confirm requested resources' task is completed, we need to set 'u_manager' mandatorybefore 'resources fulfilled' can be completed.

Screen Shot 2016-11-21 at 12.20.50 PM.png

17 REPLIES 17

jagarnathn
Tera Expert

Can you just provide me the demand task table name ?



is it something like dmn_demand_task ? OOB nothing like that exists.




Moreover if we select task type as demand from the workflow demand will be created not the demand task and short description will be populated on the name   in the demand form.



find_real_file.png


find_real_file.png


yeah ... you got it right, it's 'u_demand_task'


If u_demand_task record will be created from the workflow, it will be standalone . How you will be associating   to a demand then ?


I am not sure how the relationship you established.



There are many ways to make the associated demand manager mandatory.



Write a   before update business rule on the demand task . Preferred one


Condtion: current.state.changesTo(3) && current.u_task_code=="Resources Fulfilled"// Closed Complete



Script;



var gr= new GlideRecord('dmn_demand');


gr.addQuery('demand_task', current.sys_id);


gr.query();



while(gr.next()){



if(gr.u_manager.nil()){


gs.flushMessages();


gs.addErrorMessage("Manager is empty in the parent record" + gr.number);



current.setAbortaction(true);


}


}