logo

NJP

How to get List of a User in workflow as an Approver

Import · Sep 13, 2019 · article

Hi All,

I had a requirement to get SDM (Service Delivery Managers ) as an approver in Servicenow Change workflow. So this SDMs should be added in a company record as shown below:

So I have created a SDM field on Company record ( u_sdm )

image

Now open the change workflow and add Approver User activity as need and write below code . This will give all the SDM users in approver.

// Set the variable 'answer' to a comma-separated list of user ids and/or group ids or an array of user/group ids to add as approvers.


if (!current.company.u_sdm_chg_approver){ //if company not flagged for SDMs to approve Changes
  answer = [];//empty array
}
else{  
  answer = new Array();
  var strClientSDMList = current.company.u_sdm.toString();
  answer = strClientSDMList.split(','); //grab ALL SDMs listed on the company record.
} 

Please give me advice incase anyone has an better way to achieve this.

Thank You,

AJay

View original source

https://www.servicenow.com/community/itsm-articles/how-to-get-list-of-a-user-in-workflow-as-an-approver/ta-p/2312665