Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Actions is visible even if condition is false.

SNOW32
Giga Expert

Hello Everyone,

I have created 2 buttons(UI actions) named "Under Review" "Investigate" in problem ticket to move phase(process flow), state & stage. Phase, state & stage are updating also as expected but button is visible after the condition is false too. "Under Review" should not reflect if Phase,stage & state are Under Review.Written script and screenshot is below:

find_real_file.png

find_real_file.png

Script:
function updateUnderReview(){
    g_form.setValue('state', '103');
    g_form.setValue('u_stage', '101');
    
    gsftSubmit(null, g_form.getFormElement(), 'under_review'); //MUST call the 'Action name' set in this UI Action
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
    serverUnderReview();

function serverUnderReview(){
    current.state = 103;
    current.u_stage = 101;
    current.update();
}

Below screenshot for Field: State,Type: Integer, Dependent value: Value of "Stage" field


find_real_file.png

For Process flow, please refer below:

find_real_file.png

Any idea where I am doing wrong the code.

 Kind Regards,

Anu

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Anu,

First of all current.state == '0' should be changed to only using 0 since it is an integer and not string

secondly check script include whether it is returning true/false properly

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Jace Benson
Mega Sage

I'm pretty sure the condition field is evaluated server side, so just drop the `javascript: ` bit.

That's fine.After removing `javascript: ` from condition also buttons are visible. My issue has not been resolved yet.

Thanks,

Anu

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Anu,

First of all current.state == '0' should be changed to only using 0 since it is an integer and not string

secondly check script include whether it is returning true/false properly

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader