How to send approval based on field update on the catalog item.

raj149
Giga Guru

Hello Experts,

 

I have created ABC catalog item to update existing user record. In that catalog item I created below fields.

1. Select User name (string)

2.Name(string)

3.Email

3.Cost center(reference to cmn_costcenter table)

4.Department(reference to cmn_department table)

5.VIP (true/false)

6.Country (dropdown)

7.Company(reference to core_company table)

8.Title (string)

9.Manager(reference to sys_user table)

 

 

Created catalog client script if user selected user name in field 1 then remaining fields will populate automatically.

 

Now my requirement is,

1.If user updated 2nd field or 3rd field or 4th field then we need to send approval to Department.Manager.

2.If user updated 5th or 6th or 7th fields then we need to send approval to Company.Assignment Group

3.If user updated 8th and 9th fields then we need to send approval to current.manager

 

Here the problem is how to know end user how many fields updated in catalog item. We need to compare old value and new value for all the fields.

 

If new value is same as old value we need to skip for approval.

If new value is not equals to old value then we need to send approval.

 

How can we do that by using script in workflow...?

 

Best Regards,

Raj

 

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @raj149 

 

Created catalog client script if user selected user name in field 1 then remaining fields will populate automatically.

Atul: Use Auto populate feature on variable, which is zero code.

 

https://www.servicenow.com/community/itsm-forum/send-approval-based-on-a-variable-value/m-p/811170

https://www.servicenow.com/community/itsm-forum/set-approval-based-on-variable-in-catalog-task/td-p/...

https://www.servicenow.com/community/now-platform-articles/article-9-create-user-approvals-using-cat...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hello @Dr Atul G- LNG 

 

Above links which you shared it is not helpful for me. 

 

Now my requirement is,

1.If user updated 2nd field or 3rd field or 4th field then we need to send approval to Department.Manager.

2.If user updated 5th or 6th or 7th fields then we need to send approval to Company.Assignment Group

3.If user updated 8th and 9th fields then we need to send approval to current.manager

 

Here the problem is how to know end user how many fields updated in catalog item. We need to compare old value and new value for all the fields.

 

If new value is same as old value we need to skip for approval.

If new value is not equals to old value then we need to send approval.

 

How can we do that by using script in workflow...?

 

Best Regards,

Raj

My friend, that is baselines for you. You need to write the script and check. If you looking for ready made code may be someone from chatgpt can build in seconds and give.

 

My motto is , to give a baseline and you try your hand and share fedback. Please try to build and if you stuck , let us know. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Mani A
Tera Guru

We can't achieve this in workflow directly..

Do it onChange scripts by comparing old and new value..if equals then g_form.setValue("flag", false)..else setValue flag as true and (include require approval details in ApprovalvariableName)

 

In workflow activities...check if  flag==true

   Use array.push( current.varibales.approvalVariableName);