Hi
I am using marketing landing page.
I need to check for duplicate record error and forward the page to error page with the details of error and other instruction for the user.
Please advice me how i can do that.
Thank you,
Siva
Hi
I am using marketing landing page.
I need to check for duplicate record error and forward the page to error page with the details of error and other instruction for the user.
Please advice me how i can do that.
Thank you,
Siva
Thank you so much CloFly. It worked. You are always very helpful.
No words to thank you.
Siva
Hi Siva,
You could refer to my steps.
1. Flow
overview
action 1: request JSON schema:
{ "type": "object", "properties": { "mailbox": { "type": "string" } } }
action 2: initialize a integer variable count.
action 3: query that whether there is matching contact who has same emailaddress as submitted email
action 4: get count of result with expression: length(body('List_records')?['value')
assign the result count to count variable.
action 5: Define response body JSON schema.
2. Code in marketing page.
MsCrmMkt.MsCrmFormLoader.on('formSubmit', function (event) { var url = "xxxxxxx"; var data = { "mailbox": document.getElementById("yyyyy").value }; var req = new XMLHttpRequest(); req.open("POST", url, false); 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 === 200) { var result = JSON.parse(this.response); if (result.count > 0) { event.preventDefault(); alert("The email has been used in Dynamics Marketing!"); } } else { alert(this.response); } } }; req.send(JSON.stringify(data)); })
3. Result
Suggestion:
1. Check whether your flow could run successfully after you called the URL in marketing page.
2. We need a response action to send count to marketing page as callback data.
Regards,
Clofly
Hi Clofly,
thank you for the information.
i followed this link to create my flow and call the flow from form submit.
The flow successfully ran, however, it didn't return any value after the run. Please advise me what i am missing here.
I am not sure how to call the callback function to check if the count is more than one (if a record is already exist). Please provide me a sample code.
Please refer to the attached file to see the flow result and advice me what i am missing. thank you, Siva
This is the way i am calling the flow.
MsCrmMkt.MsCrmFormLoader.on('formSubmit', function (event) {
alert("Thank you!....");
var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
//xmlhttp.open(“POST”, “REQUEST URL”);
//this is the url for the flow
xmlhttp.open("GET", "----------/.../invoke
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify(
{
email: .getElementById("7f685ebb-7c54-4cff-a1bc-772562d25c38").value
}
));
alert("after you!....");
});
Hi Siva,
You could refer to my last answer in thread below:
Call the endpoint/flow at formSubmit event, it will retrieve whether there is matching contact in Dynamics Marketing,
if callback data(result count of List records action) is larger than 0, then prevent submission.
Regards,
Clofly
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156