Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set Short Description on Approver tab

SNewbies
Tera Contributor

Hello!

I am creating 2 different approvals from same request one for onboarding another for system access.

I am able to get the two approvals but the short description for both Approvals is same, I want to keep short description for Onboarding to Onboarding User and for System access to be System access.

How can I do this? 

Thank you

SNewbies_0-1715075204667.png

 

2 REPLIES 2

Sohail Khilji
Kilo Patron

Hi @SNewbies ,

 

You can create a business rule on insert of approval. define right condition and set the short description accordingly.

 

or you can set the dynamic values in workflow or flow desinger if your creating / generating approval via flow / workflow.

 

(function executeRule(current, previous /* previous() if it is an async business rule */) {
    var requestType = current.u_request_type;
    var shortDescription = "";
    if (requestType == "Onboarding") {
        shortDescription = "Onboarding User";
    } else if (requestType == "System Access") {
        shortDescription = "System Access";
    }

    current.short_description = shortDescription;

})(current, previous);

 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Community Alums
Not applicable

Hi @SNewbies ,

I tried your problem in my PDI and it works for me please create Before Business Rule on Inserted and add below code 

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

    // Add your code here
    var type = current.u_request_type;
    var shortDescription = "";
	gs.log("Here Approvals SD = " + current.document_id);
    if (type == "backend value onboarding_user") {
		gs.log("Here Approvals SD = " + current.document_id);
        current.short_description = 'Onbording User';
    }if (type == "backendValue of System Acess") {
		current.short_description = 'System Access';
    }

})(current, previous);

SarthakKashyap_1-1715076931713.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak