Thursday, January 12, 2023

Update content setting in live customer journey in d365 marketing

 In Dynamics 365 Marketing, you can use the Live Customer Journey feature to update the content of an active customer journey while it is running. This allows you to make changes to the journey without having to stop and restart it, which can save time and minimize disruption to your customers.

Here is an example of how you might update the content of an active customer journey using the Dynamics 365 Marketing API

// Update the content of an active customer journey function updateContentSetting(customerJourneyId: string, contentSettingId: string) { // Update the content setting var update = { content: "<p>New Content</p>" }; var req = new XMLHttpRequest(); req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/marketing/customerjourneys(" + customerJourneyId + ")/Microsoft.Dynamics.Marketing.LiveCustomerJourney/contentSettings("+contentSettingId+")", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 204) { // Content setting updated successfully console.log("Content setting updated successfully"); } else { console.log(this.statusText); } } }; req.send(JSON.stringify(update)); }


In this sample, you pass the customerJourneyId and contentSettingId of the customer journey to update and it will update the content of the customer journey. This is a simplified example you may need to import the required types and configure the appropriate options as per your need.

Please note that in order to use this sample code, you must have the appropriate permissions to update customer journeys in Dynamics 365 Marketing, and you must have an active customer journey with a content setting that you want to update.

Also, keep in mind that modifying an active customer journey can impact the ongoing customer interactions and cause unexpected results, so be sure to thoroughly test any changes you make before applying them to a live customer journey.

No comments:

Post a Comment