Email Notifcation in ADF Pipline

Rohit Kulkarni 731 Reputation points
2025-11-13T18:41:39.97+00:00

Hello Team,

I am using the Web activity to received the email notification in my outlook.So i have mentioned this formula

@json(concat(
  '{',
    '"message": "ERP-DW-UAT TRANSACTION_PARTITION INPROGRESS",',
    '"dataFactoryName": "', pipeline().DataFactory, '",',
    '"pipelineName": "', pipeline().Pipeline, '",',
    '"pipelineRunId": "', pipeline().RunId, '",',
    '"Time": "', pipeline().TriggerTime, '",',
      if(
        greater(length(trim(coalesce(variables('VarSequence'), ''))), 0),
        concat('"Sequence": "', trim(variables('VarSequence')), '", "'),
        ''
      ),   
    '"Status": "Pipeline is Currently Running"',
  '}'
))

But i am receiving the output as

"DataFactoryName":ERP-DW-UAT "PipelineName":PL_TRANSACTION_PARTITION "PipelineRunId":47d69ac1-a16e-44f3-895d-e5 "Time":2025-11-13T18:36:06.2102144Z "Status":Pipeline is Currently Running "Sequence":

When the sequence is Blank,Null and No Value it must be hidden in the notification.

I am looking output like

"DataFactoryName":ERP-DW-UAT "PipelineName":PL_TRANSACTION_PARTITION "PipelineRunId":47d69ac1-a16e-44f3-895d-e5 "Time":2025-11-13T18:36:06.2102144Z "Status":Pipeline is Currently Running

Please advise.

Thanks in advance

Rohit

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
{count} votes

1 answer

Sort by: Most helpful
  1. Pilladi Padma Sai Manisha 495 Reputation points Microsoft External Staff Moderator
    2025-11-24T08:00:04.2133333+00:00

    Hi Rohit Kulkarni,
    It looks like you’re trying to set up an email notification with Azure Data Factory (ADF) using the Web activity, but the "Sequence" field shows up even when it’s blank or null, and you want it suppressed.
    The issue with the JSON you are getting is due to an extra comma and quote mishandling when the variable 'VarSequence' is empty or null. This makes the JSON string malformed, leaving unwanted characters like commas or blank keys in the output.

    To fix this, you should include the comma only when the "Sequence" field is actually present. Adjust your expression so the comma is part of the conditional block that adds the "Sequence" field. This way, when 'VarSequence' is blank or null, the "Sequence" field and its comma are not added at all, resulting in clean, valid JSON without any trailing commas or empty keys.

    For example, your formula should be:

    @json(concat(
      '{',
        '"message": "ERP-DW-UAT TRANSACTION_PARTITION INPROGRESS",',
        '"dataFactoryName": "', pipeline().DataFactory, '",',
        '"pipelineName": "', pipeline().Pipeline, '",',
        '"pipelineRunId": "', pipeline().RunId, '",',
        '"Time": "', pipeline().TriggerTime, '",',
        if(
          greater(length(trim(coalesce(variables('VarSequence'), ''))), 0),
          concat('"Sequence": "', trim(variables('VarSequence')), '",'),
          ''
        ),
        '"Status": "Pipeline is Currently Running"',
      '}'
    ))
    

    This ensures the "Sequence" field appears only when it has a value, keeping your JSON neat and easy to read.

    This approach follows good JSON formatting practices that avoid trailing commas and empty values, making your output suitable for notifications and easier to maintain.
    Hope this helps you get the output you need!


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.