Master data V2

I’m trying to create a trigger that fires after an order is invoiced, however when I check the order number it’s not the same one — it’s returning an order placed by the person years ago. Why is this happening? In runAt I set dateTime: "now" and increment: {addMinutes: 1}, meaning it should fire the trigger 1 minute after the customer makes a purchase and then send the related email.

	"v-triggers": [
		{
			"name": "Copy data",
			"active": true,
			"condition": "status=invoiced",
			"action": {
				"type": "t-email",
				"template": "reviews-and-rating",
				"provider": "default",
				"subject": "My template email with VTEX Master Data",
				"to": [
            ""
        ],
        "bcc": [
            ""
        ],
        "replyTo": "wanderson@livreeleve.com.br",
         "body": {
						"firstName": "{!clientProfileData.firstName}",
						"email": "{!clientProfileData.email}",
						"id": "{!id}",
						"clientName": "{!clientProfileData.firstName}{!clientProfileData.lastName}",
						"ownerListName": "{!customData.customApps[0].fields.ownerListName}",
						"ownerListEmail": "{!customData.customApps[0].fields.ownerListEmail}",
						"items": "{!items}",
						"openTextField": "{!openTextField.value}"
         }
			},
			
			"runAt": {
				"dateTime": "now",
        "increment": {
           "addMinutes": 1
        }
			}
		}
	]
}

Hi Wanderson,

Looking at the code you shared, I believe the issue is that the condition being used is too broad. The “status=invoiced” condition, as it’s currently configured, applies to both newly invoiced orders and older ones.

My recommendation in this case would be to add an additional condition — either a time filter (so that only orders created recently are taken into account) or an extra flag that could be applied to older orders and/or orders for which the email has already been sent (for example, an emailSent flag).

This second suggestion would also require a change to the action field, to update the value of that flag.

Eduardo Luciano
Field Software Engineer | VTEX