Auto update column in Incident table

Kalpesh Kalgutk
Tera Contributor

Hi,

 

I would like to write a script to update a column when a specific subcategory is selected in Incident table.

 

Could you please assist me with this?

 

Thank you.

2 ACCEPTED SOLUTIONS

Hello @Kalpesh Kalgutk ,

You can put below line of code in your Business Rule -> 

 

(function executeRule(current, previous /*null when async*/) {

// Add your code here
var session = gs.getSession();
var URL = session.getUrlOnStack();
//gs.info(URL);
current.COLUMN_NAME = URL;

})(current, previous);

 

Reference documentation - https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server/c_GlideSessionScopedAPI

 

If my response helps you in any way, kindly mark this as Accepted Solution/Helpful and help in closing this thread.

Regards,

Shubham

View solution in original post

Hello @Kalpesh Kalgutk ,

I see & understand what is implemented. If interested, you can try my solution so provided in your PDI and we can check why it does not work. Normally, it does.

 

If my response helps you in any way, kindly mark this as Accepted Solution/Helpful and help in closing this thread.

Regards,

Shubham

View solution in original post

11 REPLIES 11

Hello @Kalpesh Kalgutk ,

I see & understand what is implemented. If interested, you can try my solution so provided in your PDI and we can check why it does not work. Normally, it does.

 

If my response helps you in any way, kindly mark this as Accepted Solution/Helpful and help in closing this thread.

Regards,

Shubham

Thanks @ShubhamGarg ,

 

I tried the following code, and it worked. The actual issue was that the "Insert" option under "When to run" was unchecked. I realized this today, and now it's functioning properly. 

 

 

    var baseUrl = 'https://sharepoint.com'; 
    var Url = baseUrl + '/' + current.number;
    current.[COLUMN NAME] = URL;

 

 
It was my mistake; the code you provided wasn't working sorry.