Adding Source Name in email template

Hi All,

I am trying to add source name in the access request reviewer email template but the code I tried is not working.Can anyone help with the exact working code for fetching the source name.

The code I used to fetch Source name is:

#if($sourceInformation)

Source Information:



    #foreach($source in $sourceInformation)

  • Source Name: ${source.sourceName}

    #if($source.sourceAccountName)
    Account Name: ${source.sourceAccountName}
    #end

  • #end

#end

TIA

Hi @kanusha9

According to the docs (below), the sourceInformation variable should only be used with multiple accounts. Are you attempting this on a single account access request? Also, with your current setup, is your email sending with no data or are you failing to get an email sent at all?

Blockquote
Note: This should only be used in case of multiple accounts.

Your code looks fine. The $sourceInformation variable is documented for the Access Request Reviewer template, but it only populates when the identity has multiple accounts on the same source. If the identity has a single account per source (which is the common case), $sourceInformation will be null, so your #if block won’t render anything.

For single-account cases, I think there’s no built-in variable in this template that exposes the source name.

If you need source name for every request regardless of account count, you can try to handle it outside the email template: use a workflow triggered on Access Request Submitted, call the ISC APIs to resolve the source name from the requested item, and send a custom email via the Send Email action with whatever variables you need. That gives you full control over the payload.

If a workflow feels like overkill for this, a simpler option is to include the source name in your access profile or entitlement display names (e.g., “AD - Domain Admins”). That way the reviewer sees it in $requestedObjectName without any template changes.

I am trying to call v3/search api to fetch the source name using entitlement id
Here is the response from postman
[
{
“source”: {
“name”: “a******”,
“id”: “6*******************4a”
},
“type”: “entitlement”,
“_type”: “entitlement”,
“_index”: “202”,
“_score”: 12.889268
}
]

and call it in my custom email {{$.hTTPRequest.body[0].source.name}} this is not working
am I doing anything wrong here? Please correct

TIA

At first glance, the JSONPath expression you used looks correct.

Can you provide us your workflow or at least the configuration for the HTTP Request and Define Variable / Send Email that you’re referencing that variable in?

Hello Anusha,

Your API response looks correct. I think the issue is how the value is being used in the custom email template. Instead of calling this directly in the email body:

{{$.hTTPRequest.body[0].source.name}}

Try passing the value first in the Send Email action under Templating Context:

{
"sourceName.$": "$.hTTPRequest.body[0].source.name"
}

Then use this in the email body/template:

Source Name: ${sourceName}

Also please confirm the exact technical name of your HTTP Request step from the workflow execution history. If the step name is different, the JSONPath has to match that exact name.

Thanks for your response.

I tried what you mentioned but it is not working.

Ah, it looks like the HTTP Request name hTTPRequest vs hTTPRequest3 was likely your initial issue. You can either reference the variable using {{}} in the body of the email or use the templating context like Harish mentioned.

I would try using a Define Variable step before your Send Email with the variable you’re trying to resolve in there. Once it’s set, during the execution you can see the output to ensure it’s resolving correctly and there’s not a reference issue.

From your screenshot, the email body part looks fine:

Source Name: ${sourceName}

The next thing to check is the actual workflow execution output for the Search source in ISC HTTP Request step.

Can you please open the workflow test/execution result and confirm these two things?

  1. What is the exact technical step name?

    Example: hTTPRequest3

  2. What does the response body look like?

We need to confirm whether this path really exists in the execution output:

$.hTTPRequest3.body[0].source.name

If the step name or response structure is different, ${sourceName} will come blank in the email.

and the response from postman

[
{
“source”: {
“name”: “a******”,
“id”: “6*************************************”
},
“type”: “entitlement”,
“_type”: “entitlement”,
“_index”: “202”,
“_score”: 12.889268
}
]

hi @kanusha9 - can you share whole workflow script?

Sorry we shouldn’t share

I mean what you are trying to do ..

The step name and templating context both look correct. The piece that might be worth checking is the actual body output from the hTTPRequest3 step in the workflow execution history, not the Postman response. Postman confirms the API works, but the workflow could be getting a different result at runtime if the entitlement ID in the search request body isn’t resolving properly.

If you expand the hTTPRequest3 step in the execution history and the body comes back as an empty array, that would explain why ${sourceName} renders blank.

If the body does show the expected response, one thing that could help isolate the issue is adding a Define Variable step between the HTTP Request and Send Email. Setting it to $.hTTPRequest3.body[0].source.name using the variable selector and passing that into the email instead would make it easier to see exactly where the value is dropping off.

Even the variable cannot be able to fetch the source name , Below is the response in email when used with define variable.


I am trying to fetch the source name of the access request and trying to incorporated the source name in the email template in a workflow (Access Request Response/Access Request Submitted).

Hi @trettkowski

I have even tried define variable but still not able to fetch the source name - Define variable is outputting below

Thanks for providing that detail. Based off that, I think we’ve determined that the output from $.hTTPRequest3.body[0].source.name is null, so I would confirm that the output from your HTTP Request 3 Step is actually getting the correct data.

Like Harish already mentioned, it could be that a parameter that you’re using in your search API call is not resolving and is returning no results from your call. If you look at the output of your HTTP Request 3, what does it show? I’m guessing [], which indicates a variable that you’re passing into it or something is wrong with the API call.

To test the same I updated the hardcoded value in the request body and tried. It’s not working.

{

“indices”: [“accessprofiles”,“entitlements”,“roles”],

“query”: {

"query": "id:\\"8**********************************c\\""

},

“queryResultFilter”: {

"includes": \[ "source.id", "source.name" \]

}

}

I just tested this in my own tenant and it’s working for me with this query, please try this in your JSON body and update the id value with your own:

{
  "indices": [
    "accessprofiles",
    "entitlements",
    "roles"
  ],
  "query": {
    "query": "id:acc27d19895336db95683a5f891ef7b3"
  },
  "queryResultFilter": {
    "includes": [
      "source.id",
      "source.name"
    ]
  }
}

Correct Workflow Execution Output:

HTTP Request Configuration: