Outlook actionable messages overriding additional info in the notification

Victor17
Giga Contributor

Hi,

When I use outlook actionable messages for surveys, the embedded survey will "override" other information in that notification.

For instance, I would like information on an incident or Case to be included in the notification with the embedded survey. Is there a way to do this?

1 ACCEPTED SOLUTION

Tim_Clark
Kilo Sage

Hi,

This is such a hit and miss plug-in for me, there is so much great work in there but the ability to customize is such a big piece of the puzzle. It is a notification after all.

Digging into the plugin I can see most the magic of creating the embedded survey is done in the protected script include, SurveyAdaptiveCardGenerator.

The first issue is the hideOriginalBody is set to true (see below), which works great for a clean embedded survey but takes any chance away of customizing around it. I think this is the override piece you are talking about.

this.card = {
			"type": "AdaptiveCard",
			"version": "1.0",
			"originator": gs.getProperty('sn_ms_oam.outlookactionable.originator'),
			"padding": "none",
			"expectedActors": this._getExpectedActors(),
			"hideOriginalBody": true,
			"body": []
		};

Description of hideOriginalBody copied from Microsoft Doco

When set to true, causes the HTML body of the message to be hidden. This is very useful in scenarios where the card is a better or more useful representation of the content than the HTML body itself, which is especially true when the card contains actions. Consider hiding the original HTML body if the card itself contains all the information a user would need, or if the content of the card is redundant with the content of the body. Do always include a nice, meaningful HTML body, even if it is going to be hidden. The HTML body is the only thing an email client that doesn't support cards will be able to display. Furthermore, cards are not included when replying to or forwarding emails, only the HTML body. Don't hide the body when it is complementary to the information presented in the card. For example, the body of an expense report approval might describe the report in great details while the card just presents a quick summary along with approve/decline actions.

 

For me I would really like to add some branding as it helps with uptake of the notification as we use specific logos to make this look like a company email. (fully aware that's what phishing is :))

IF we could modify the script include, I think that is where you would be able to add the additional information you wanted.

Really I would like to see some configuration options added to this plugin, like some simple branding or more input into how the protected script include behaves would be great.

If anyone has some workaround ideas on how to brand "outside the box" that would be great. My only thought now is to possibly manipulating the notification before it is sent to add the required AdaptiveCard JSON,  for my use case that would be:

   {
      "type": "Image",
      "url": "https://path_to_image_here",
      "altText": "
   },

 

View solution in original post

39 REPLIES 39

Hi Victor,

Like you have added the email script, like below:

${mail_script:include_survey_actionable} 

in the Notification that you are sending to the user. Create one email script and call that email script just above this mail script and see whether the data is overridden or not.

You can check the below link for creating email scripts here:
https://docs.servicenow.com/bundle/paris-servicenow-platform/page/script/server-scripting/reference/r_ExScptEmlNtfn.html

--
Thanks and Regards, 
Nitish

Tim_Clark
Kilo Sage

Hi,

This is such a hit and miss plug-in for me, there is so much great work in there but the ability to customize is such a big piece of the puzzle. It is a notification after all.

Digging into the plugin I can see most the magic of creating the embedded survey is done in the protected script include, SurveyAdaptiveCardGenerator.

The first issue is the hideOriginalBody is set to true (see below), which works great for a clean embedded survey but takes any chance away of customizing around it. I think this is the override piece you are talking about.

this.card = {
			"type": "AdaptiveCard",
			"version": "1.0",
			"originator": gs.getProperty('sn_ms_oam.outlookactionable.originator'),
			"padding": "none",
			"expectedActors": this._getExpectedActors(),
			"hideOriginalBody": true,
			"body": []
		};

Description of hideOriginalBody copied from Microsoft Doco

When set to true, causes the HTML body of the message to be hidden. This is very useful in scenarios where the card is a better or more useful representation of the content than the HTML body itself, which is especially true when the card contains actions. Consider hiding the original HTML body if the card itself contains all the information a user would need, or if the content of the card is redundant with the content of the body. Do always include a nice, meaningful HTML body, even if it is going to be hidden. The HTML body is the only thing an email client that doesn't support cards will be able to display. Furthermore, cards are not included when replying to or forwarding emails, only the HTML body. Don't hide the body when it is complementary to the information presented in the card. For example, the body of an expense report approval might describe the report in great details while the card just presents a quick summary along with approve/decline actions.

 

For me I would really like to add some branding as it helps with uptake of the notification as we use specific logos to make this look like a company email. (fully aware that's what phishing is :))

IF we could modify the script include, I think that is where you would be able to add the additional information you wanted.

Really I would like to see some configuration options added to this plugin, like some simple branding or more input into how the protected script include behaves would be great.

If anyone has some workaround ideas on how to brand "outside the box" that would be great. My only thought now is to possibly manipulating the notification before it is sent to add the required AdaptiveCard JSON,  for my use case that would be:

   {
      "type": "Image",
      "url": "https://path_to_image_here",
      "altText": "
   },

 

Tim_Clark
Kilo Sage

Just an addendum to my previous post, I found I was able to brand the cards by making copies of the relevant script includes and referring to the copies with the additional Adaptive Card JSON added.

For the examples below I have used u_ to signify the copied version.

Original items copied: 

  • include_survey_actionable (email script) 
  • AdaptiveCardsFactory (script include)
  • SurveyAdaptiveCardGenerator (script include) - Copy if using Surveys
  • ApprovalAdaptiveCardGenerator (script include) - Copy if using Approvals

Modifications made to copied files (high level) - :

  • Edit u_include_survey_actionable to point to u_AdaptiveCardsFactory.
  • Edit u_AdaptiveCardsFactory to point to u_SurveyAdaptiveCardGenerator or u_ApprovalAdaptiveCardGenerator depending or requirements.
  • Add JSON code to u_SurveyAdaptiveCardGenerator or u_ApprovalAdaptiveCardGenerator depending or requirements.

If there is any interest in this, I will post the solution in more detail. I am new to posting so I will need a few thumbs up for motivation :).

Thank you Tim for your suggestion 

 

I solved my problem by copying the SurveyAdaptiveCardGenerator and customized it by adding my own Sections and Json Items: 

 

I created a new function: e.g: 

 

 

 

_addEndNoteLogo: function() {
        endNoteLogObj = {
            "type": "Container",
            "style": "emphasis",
            "padding": "Default",
            "items": [
                {
                    "type": "Image",
                    "id": "946393ae-12a4-b7a2-5a4b-ac3788be3dad",
                    "url": "https://" + gs.getProperty('instance_name') + ".service-now.com/sn_ms_oam.OAMNoteResponse.png",
                    "horizontalAlignment": "Center"
                }
            ]
        };
        this.card.body.push(endNoteLogObj);
    },

 

 

And added this function to the response Body:

 

 

 

this._addCompleteMessage();
this._addEndNoteLogo();
this._addEndNote();
return JSON.stringify(this.card);

 

 

Hey, is this the only thing you did? I've changed all these scripts many times, but nothing seems to work... Only when I add stuff to the survey intro/end notes message. If you don't mind sharing all the configurations you've done, I would appreciate it.