UI Action - on Click functionality

NewBiee
Tera Contributor

Hello, 

I have a requirement where i need to create a UI Action "Self Approve" 

On Click Action:

1.State will change to Approved

2.redirection to relevant record (a record in another table with same name).

3. Comments will be populated "Self Approved by <Owner name>"

4.Also there will be a info message after every successful Click stating "Impact Analysis is Approved - <Name of BIA-make it hyperlink>"

need help with this requirement

Thank you;.

2 REPLIES 2

ShubhamGarg
Kilo Sage

Hi,

Rather than providing the script here, I am copying some useful URLs you can use for self learning and code -

ServiceNow UI Action Tutorial with Examples| UI Action in ServiceNow - BasicoService NowLearning

ServiceNow UI Actions - YouTube

Please connect back if you still get stuck.

Mark this as Correct/Helpful if applicable.

Regards,

Shubham

 

Mohith Devatte
Tera Sage
Tera Sage

hello @NewBiee ,

you can try this in your UI action script 

current.state="approved_value";
current.comments = "self Approved by :"+current.your_owner_name_field_name;
current.update();
var url = "<a href='your url'>"+current.your_bia_field_name+"</a>";
gs.addInfoMessage('Impact Analysis is Approved'+url);
action.setRedirectURL("/your_table_name.do?sys_id=your_Record_sys_id") // to redirect to another table record

Hope this helps 

MARK MY ANSWER CORRECT IF THIS HELPS YOU