How to change state using Ui action ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 02:58 AM
Hi All,
I have Requirement , How change state value using UI action button .
i have design workflow, in HR state If condition is there . Card is needed if its "Yes "state has to go amex Admin state value 6 its is "No" state has to go master adimin state value is 7 .Please help on this .
Thanks,
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:19 AM
Hi Suresh,
Create a UI Action and Create a onClick() Function and on the script section just do set value of what ever you want to set on that field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:30 AM
Hi suresh,
I will give you an example you can add your fields and values.
on condition field of UI action form we can provide conditions and if those conditions matches the only UI actions will be visible.
//ex current.state=='-5' || current.state=='2'
//cancelorder() function name need to define on the Onclick field on UI action form.
//use below script function name and action should be anything
function cancelorder() {
//MUST call the 'Action name' set in this UI Action
gsftSubmit(null, g_form.getFormElement(), 'cancel_order');
}
if (typeof window == 'undefined') {
current.state= 'Closed Incomplete';
current.update();
//will be on the current page after UI action
action.setRedirectURL(current);
}
refer below screenshot
Hope it helps!!
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 04:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 07:32 AM
Yes, You can build the logic on UI action then workflow will trigger accordingly once the conditions are matched.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar