Cancel Change without filling mandatory fields in SOW

ElSalmiito
Tera Contributor

I already have made a script which works fine but doesn't work in "Service Operation Workspace"

 

 
HenriSalminen_0-1713442614767.png

 

I know I should click the "Workspace Form Button" and then write a script there but I have tried but it still keeps trying to force me put all the mandatory information before canceling.

 

4 REPLIES 4

Akshay Jugran
Tera Expert

Hi ElSalmitto , have you set your client script UI type to "All" ?

ElSalmiito_0-1714725745812.png

I am still struggling with it. I have an Ui action button but this script doesnt work.

Ashutosh44
Tera Contributor

Hi @ElSalmiito ,
Write a UI policy: that runs on Change table when state is Cancelled with the following code to check all the editable variables and make them non mandatory:

function onCondition() {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
    var field = g_form.getValue(fields[x]);
    g_form.setMandatory(fields[x], false);
    g_form.setReadOnly(fields[x], true); // use this if required.
}
}
 
Now in your UI Action's Client script function (moveToCancel - as per your screenshot)
Add this code in starting  to set the state to Cancel: 
g_form.setValue('state', '7'); // replace 7 with internal value of Cancel state in your instance.

BillMartin
Mega Sage

Hi @ElSalmiito ,

 

I see you are not using debugging features. Isolate each line of code and as a practice return a paremeter that your function is successful. A Void method is not recommended. Establish validation on entry and return of your functions. It will help you and other developers understand the behaviour of your code.

 

Please mark as helpful and accept as solution if you find it lucrative.