How to change state using Ui action ?

suresh40
Tera Contributor

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

4 REPLIES 4

Anand Shukla
Mega Guru

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.

Pavankumar_1
Mega Patron

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

find_real_file.png

 

Hope it helps!!

Please Mark ✅ Correct/helpful, if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Hi Pavan,

Based on that if condition ui action button has to work . If its Yes goes to Amex admin and it is no its has to go master data I/P state . 

find_real_file.png

Yes, You can build the logic on UI action then workflow will trigger accordingly once the conditions are matched.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar