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!