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.

Enable Compose email button in HR agent configurable workspace list view

Rajareddy_VR
Tera Contributor

 

Hi team,

I have a requirement to enable the "compose email" button in the list view of the HR agent configurable workspace. When the agent clicks the compose email button, it will open a new tab with an email draft, allowing the agent to fill it in and click the submit button. I have an existing action called compose email, but it only works for the old workspace. Could you please provide a solution for this?

 

script:

 

    var LEGACY_EMAIL_CLIENT_NAME = 'sn-email-editor',
        SEISMIC_EMAIL_CLIENT_NAME = 'sn-email-client-wrapper',
        EMAIL = 'sys_email',
        DRAFT = 'sys_email_draft',
        tValue = DRAFT;

    //get the list of renderers
    var renderers = [];
    if (ux_globals && ux_globals.presource['sn-workspace-content:snCustomRenderer']) {
        renderers = ux_globals.presource['sn-workspace-content:snCustomRenderer'].data.GlideRecord_Query.sys_aw_renderer._results;
    }

    if (renderers.length > 0) {
        // Filter out Email renderers
        var renderMap = {};
        renderers.filter(function(o) {
            return o.table.value == EMAIL || o.table.value == DRAFT;
        }).map(function(o) {
            renderMap[o.table.value] = o.custom_renderer_tag.value;
        });

        //Figure out the final value
        if (!renderMap.hasOwnProperty(DRAFT))
            tValue = EMAIL;
        else {
            if (!renderMap.hasOwnProperty(EMAIL))
                tValue = DRAFT;
            else if (renderMap[EMAIL] == LEGACY_EMAIL_CLIENT_NAME)
                tValue = EMAIL;
        }
    }
   
    var dirtyFieldList = g_form.serialize(true).map(function(field) {
        return {
            field: field.name,
            value: field.value
        };
    });
    g_aw.openRecord(tValue, '-1', {parentTable: g_form.getTableName(), parentSysId: g_form.getSysId(), headerValue: getMessage("New Email"), dirtyFields: dirtyFieldList});
 

Rajareddy_VR_0-1736166800346.png

 

Rajareddy_VR_1-1736166844995.png

 

 

10 REPLIES 10

@Rajareddy_VR 

not very sure on this.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader