Is it possible to manipulate a field of type Yes/No by script or others, how?

Alessa
Mega Guru

Hello dear community, I need help:

 

1. I have a field of type Yes/No (hubo_contr_cambio), inside a task (current.u_slx_task_id == 15) in a workflow.
2. I need this field to be automatically set to YES, if the task current.u_slx_task_task_id == 12 is in state closed complete (3), because when is being set to YES displays another field so that it can be filled by the user.
4. Otherwise, that is, if the task current.u_slx_task_task_id == 12 is not in full closed state, then this field is automatically set to NO.
Why do I need to do this?:  to avoid user errors, because the idea is that if the workflow goes through the task with the id 12 and that task is closed, then the field hubo_contr_cambio remains as YES and a field is displayed so that the user can complete it, but otherwise that field is not displayed and in this way we can avoid errors that the user can make.

In order to do this, I have created the following script, inside the task with id 15 (which is where the field hubo_contr_cambio is, which I need to change automatically)

 

if (current.u_slx_task_id == 15) {
 
    var taskGR = new GlideRecord('sc_task');
    taskGR.addQuery('u_slx_task_id', 12);
    taskGR.query();


    if (taskGR.next() && taskGR.state == 3) {
        current.hubo_contr_cambio = true; // SI
    } else {
        current.hubo_contr_cambio = false; // NO
    }

    current.update();
}

 

 

 

 

 

 

Alessa_0-1692021197272.png

 

However, so far I have not been successful, so I really don't know if I can manipulate the hubo_contr_of_change field in the way I need.

 

 

Can someone help me with this?

 

 

1 REPLY 1

Barrilito van D
Kilo Guru

Hi,

In general, start simple and just script one line without all if statements or queries and dependencies on other tables and just try to set it to yes or no. If that does not work you can rule out that the if is not working and that it is just your one liner that is not scripted well.

I think you need something like:


current.variables.hubo_contr_cambio ='yes' ; 

(or perhaps change yes to true, not sure)

 

If you think my answer put you in the right direction or you appreciated my effort, please mark the response as Helpful or mark my response as Correct.
Thanks in advance! Good luck!