Hi @shruti1 ,
You can use the following code after your enrichment activity inside a JavaScript activity. Ensure that all the necessary fields are created and have alias names, so you can reference these alias names in the query. Make sure to adjust the field names in the code to match the actual field names in your schema or enrichment.
// Define the schema name from the target schema
var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);
// Create the query definition to select required fields
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@totalRecipient"/>
<node expr="@totalContract"/>
<node expr="@classification"/>
</select>
</queryDef>
);
// Execute the query
var result = query.ExecuteQuery();
// Initialize variables to store the sums
var totalRecipient = 0;
var totalContract = 0;
var totalDiff = 0;
// Loop through each record in the result set
for each (var rcp in result.recipient) {
// Sum TotalRecipient and TotalContract
totalRecipient += rcp.TotalRecipient;
totalContract += rcp.TotalContract;
// Calculate the difference and sum it
totalDiff += rcp.TotalRecipient - rcp.TotalContract;
}
// Log the calculated totals
logInfo("Total Recipient Sum: " + totalRecipient);
logInfo("Total Contract Sum: " + totalContract);
logInfo("Total Diff Sum: " + totalDiff); Thanks