How to include a field value in message body of EMAIL action in Rules and Connectors?

I want to include only specific fields in the message body of email action. When using the {{context.hits}} it is returning the whole document. But I want to include only specific fields from the document.

Thanks in advance

I can give you an example:

Let's say in the input part of your watcher you've got that kind of selection:


  "input": {
{
   "Application": {
     "simple": {
       "name" : "TEST"
      }
   }
}

Then in your email body you can just refer to it as {{ctx.payload.Application.name}}

If what you get is a list of elements, let's say a list of name and phone number like this:
testlist.name
testlist.phone

and you want to dispatch all the values, you need to use the following sentences:

{{#ctx.payload.testlist.hits.hits}}{{#_source}}{{name}}{{/_source}}{{/ctx.payload.testlist.hits.hits}}

or you can expand:
{{#ctx.payload.testlist.hits.hits}}{{#_source}} whatever you want {{phone}} and other things like this{{name}} and that's it{{/_source}}{{/ctx.payload.testlist.hits.hits}}

1 Like

Thank you John :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.