The CreatorCon Call for Content is officially open! Get started here.

Use break or exit in UI action

Amit Pal1
Tera Contributor

If the else block is executed, the function publishitem() will not run. Can this be achieved ?

PFA snapshot as I am not able to copy paste the code.

16 REPLIES 16

Hi Gaurav,



Thanks for trying this.


I used the code mentioned by you, but this does not fulfill my requirement.


Reason: I need the else block to change the state the state and save the form.



Background: If answer is true, publishitem function gets executed and the item is published. If the answer is not true, the state gets changed and the form is saved.



PFB the script modified to the one you asked me to.


find_real_file.png


Hi Gaurav,



The exact reason why i was being skeptical.The values wont save until you update/save it somehow, clicking the ui action wont help.


Hi,



Earlier I thought you don't want to reload the page.



But now, I have tried to update my summary field with g_form.setValue in the else block and it did fine.



If Block: on confirm value as yes, it submits the form and add a message on the top of form.( gsftsubmit is called)



find_real_file.png





Else Block: Updating the summary value with no message on the top of form.



find_real_file.png





Code :


find_real_file.png


Abhimanyu Bansa
Giga Expert

Hi Amit,




please go through the below link, hope that will help you in fulfilling the requirement.https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/


https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/




Regards,


Abhimanyu Bansal


-----------------------------------------


Please Note: Kindly LIKE or MARK Correct/Helpful, if you are satisfied with my response.


Hi Abhimanyu,



I have went through these URL again and again before, my requirement is different from this.


According to my requirement, if the condition even validates to false, still I need to change the state and save it.


If the condition validates to true, the function should run which works fine.



Regards,


Amit