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

Ankur Bawiskar
Tera Patron
Tera Patron

@Rajareddy_VR 

I don't think it should be on list view.

what if user selects multiple records and then click on that button?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Rajareddy_VR 

can you share complete script of UI action which is working in legacy agent workspace?

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

@Ankur Bawiskar ,

 

Yes, you're right. The old workspace is working for form view, but in a configurable workspace, it is necessary to enable list view.

refer below script for legacy workspace. then how we can configure for new workspace in form view?

Rajareddy_VR_0-1736167726015.pngRajareddy_VR_1-1736167747591.pngRajareddy_VR_2-1736167776234.png

Thanks

Raja Reddy

@Rajareddy_VR 

what if user selects multiple records and then click on that button?

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