Guidance on Configuring Compose Email Action in Workspace

pgvaishnav
Tera Contributor

Hi Team,

I have a quick question. I’m trying to configure the Compose Email action in Workspace so that the To, CC, Subject, and Body fields are pre-populated by default.

pgvaishnav_1-1755665117894.png

This is the UI Action - Compose email

pgvaishnav_2-1755665177597.png

pgvaishnav_3-1755665211960.png

 

function onClick(g_form) {
	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});
}

 

Could you please advise on the best way to achieve this?

Thank you for your support.

Best regards,
Prajwal

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@pgvaishnav 

you should not touch the OOTB UI action

Instead you should configure the email client template for your table and there you can mention TO, CC, BCC, Subject, Body etc

AnkurBawiskar_0-1755665845048.png

 

AnkurBawiskar_1-1755665859146.png

Once configured and you click "Compose Email" in workspace the template gets applied and fields will be populated accordingly

AnkurBawiskar_2-1755665914125.png

 

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@pgvaishnav 

you should not touch the OOTB UI action

Instead you should configure the email client template for your table and there you can mention TO, CC, BCC, Subject, Body etc

AnkurBawiskar_0-1755665845048.png

 

AnkurBawiskar_1-1755665859146.png

Once configured and you click "Compose Email" in workspace the template gets applied and fields will be populated accordingly

AnkurBawiskar_2-1755665914125.png

 

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

@pgvaishnav 

Thank you for marking my response as helpful.

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

Hi @Ankur Bawiskar,
Thank you very much for your response 😄. It worked as expected.