Use break or exit in UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 01:16 AM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 02:58 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 03:04 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 03:16 AM
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)
Else Block: Updating the summary value with no message on the top of form.
Code :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 02:27 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 03:01 AM
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