Notification dynamic recipient (different CAB groups)

JordyZ
Mega Sage

Hi,

 

I have a custom notification that triggers when a change has been requested for approval. 

JordyZ_0-1685101786397.png

These are the triggers and they work fine. 

 

However, I'd like to know how to make the recipients (who will receive) dynamic (different CAB groups).

 

Extra information: on the change form I have a custom field "CAB" that shows the different CAB groups based on the region and selected choice of the CAB field.

JordyZ_1-1685102971172.png

This is the client script that shows the different CAB groups based on the selected choices.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var userloc = g_form.getReference('requested_by', callBackMethod);

    var cab = g_form.getValue('u_cab');

    function callBackMethod(userloc) {
        if (cab == "global")
            g_form.showFieldMsg('u_cab', "Group is Global_CAB_Approval");
        else if (userloc.u_region !== "08ecdf14475b51107ad60b27e26d4396") { //sys id of EMEA
            switch (userloc.u_region) {
                case '0cecdf14475b51107ad60b27e26d4395': //sys id of NAM
                    g_form.showFieldMsg('u_cab', "Group is NAM_CAB_Approval");
                    break;
                case '0cecdf14475b51107ad60b27e26d4392': //sys id of LATAM
                    if (cab == "regional_application" || cab == "country_application")
					g_form.showFieldMsg('u_cab', "Group is LATAM_CAB_Apps_Approval");
					else g_form.showFieldMsg('u_cab', "Group is LATAM_CAB_Approval");
                    break;
                case '00ecdf14475b51107ad60b27e26d4395': //sys id of APAC
                    g_form.showFieldMsg('u_cab', "Group is APAC_CAB_Approval");
                    break;
                case '04ecdf14475b51107ad60b27e26d4397': //sys id of India
                    g_form.showFieldMsg('u_cab', "Group is INDIA_CAB_Approval");
                    break;
            }
        } else if (userloc.u_region == "08ecdf14475b51107ad60b27e26d4396") {
            switch (cab) {
				case 'regional_infrastructure':				
			g_form.showFieldMsg('u_cab', "EMEA_CAB_Infra_Approval");
					break;
				case 'regional_application':
                g_form.showFieldMsg('u_cab', "EMEA_CAB_Apps_Approval");
					break;
				case 'country_application':					
            switch (userloc.country) {
                case 'Belgium': 
                    g_form.showFieldMsg('u_cab', "Group is Belgium_Apps_CAB_Approval");
                    break;
                case 'France': 
                    g_form.showFieldMsg('u_cab', "Group is France_Apps_CAB_Approval");
                    break;
                case 'Germany': 
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
                case 'Greece': 
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
                case 'Italy': 
                    g_form.showFieldMsg('u_cab', "Group is Italy_Apps_CAB_Approval");
                    break;
                case 'Netherlands':
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
                case 'Russian Federation':
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
                case 'Spain': 
                    g_form.showFieldMsg('u_cab', "Group is Spain_Apps_CAB_Approval");
                    break;
                case 'United Kingdom': 
                    g_form.showFieldMsg('u_cab', "Group is UK_Apps_CAB_Approval");
                    break;
				case 'Czech': 
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
				case 'Switzerland': 
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
				case 'Poland': 
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
				case 'Hungary': 
                    g_form.showFieldMsg('u_cab', "Group is DBE_Apps_CAB_Approval");
                    break;
                default:
                    if (userloc.country == '')
                        g_form.showFieldMsg('u_cab', "Group is EMEA_CAB_Apps_Approval");
                    break;
            }
        }
    }
}
}

The change approvers are based on the selected choice of the custom CAB field. For example, if "regional application" is chosen from the custom CAB field, and the user's region is LATAM, then the approver will be from the LATAM_CAB_Approval group.

JordyZ_2-1685103113977.png

How do I dynamically have my custom notification send emails to the right CAB group? Thanks in advance.

 

1 REPLY 1

Manmohan K
Tera Sage

Hi @JordyZ ,

 

Based on the selection, get the sys_id of the approver group and store it in any flow variable

Now trigger an event with the sys_id of approvers as one of the parameters of the event say parm1

gs.eventQueue('event.name', GlideRecord, parm1, parm2); // standard form

 

Now create a Notification which would be triggered by the event and in the who will receive tab , select recipients in event parameter 1. 

 

ManmohanK_0-1685105244652.png