getMessageLang usage in email scripts with inline styling

Suchitha Challa
ServiceNow Employee
ServiceNow Employee

Hi everyone,

I am trying to use getMessageLang in sys_script_email which was previously having getMessage 

let printText = sn_i18n.Message.getMessage('scope_name',
'<p><span style="font-size: 12pt; font-family: Gilroy, century-gothic;">' +
'{assignedUser} has assigned you the {taskName} <strong>{taskDescription}</strong> in workspace.' + '&nbsp;</span></p><p><span style="font-size: 10pt; color: #454D5B;">' + '{taskSpaceName} | {taskBoardName} | Work management' + '</span></p><br>',{
taskName: current.type.name,
assignedUser: assignedBy,
taskDescription: current.short_description,
taskSpaceName: spaceName,
taskBoardName: boardName
}
);
Can we use getMessageLang directly when we have inline styling?

1 ACCEPTED SOLUTION

Hi @Suchitha Challa 

 

Could you Please accept the solution, if it solves your question.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

View solution in original post

4 REPLIES 4

pavani_paluri
Giga Guru

Hi @Suchitha Challa ,

 

Yes, you can use  getMessageLang  with inline styling exactly as you do with getMessage  Just add the language code argument. But it’s cleaner to move the HTML template into a message record and keep only the key in your script.

 

let printText = sn_i18n.Message.getMessageLang(
'scope_name',
'<p><span style="font-size: 12pt; font-family: Gilroy, century-gothic;">' +
'{assignedUser} has assigned you the {taskName} <strong>{taskDescription}</strong> in workspace.' +
'&nbsp;</span></p><p><span style="font-size: 10pt; color: #454D5B;">' +
'{taskSpaceName} | {taskBoardName} | Work management' +
'</span></p><br>',
'en',
{
taskName: current.type.name,
assignedUser: assignedBy,
taskDescription: current.short_description,
taskSpaceName: spaceName,
taskBoardName: boardName
}
);

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

Hi @Suchitha Challa 

 

Could you Please accept the solution, if it solves your question.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

I tried using gs.getMessageLang directly and it worked instead of sn_i18n.Message.getMessageLang with the inline styling  and scope passed as parameter

Ankur Bawiskar
Tera Patron
Tera Patron

@Suchitha Challa 

yes it should.

you are already doing that.

Did it not work fine?

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