web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Forwarding to error page from marketing page in dynamics 365

(0) ShareShare
ReportReport
Posted on by 71

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

  • cloflyMao Profile Picture
    25,210 on at

    Hi Siva,

    You could refer to my last answer in thread below:

    https://community.dynamics.com/365/marketing/f/dynamics-365-for-marketing-forum/385271/thank-you-email-after-every-form-submitted

    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

  • SivaR Profile Picture
    71 on at

    Hi Clofly,

    thank you for the information.

    i followed this link to create my flow and call the flow from form submit.  

    www.itaintboring.com/.../

    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!....");  

    });

    HTTPFlowResult.docx

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Siva,

    You could refer to my steps.

    1. Flow

    overview

    pastedimage1595580020387v1.png

    action 1: request JSON schema:

    {
        "type": "object",
        "properties": {
            "mailbox": {
                "type": "string"
            }
        }
    }

    action 2: initialize a integer variable count.

     pastedimage1595580129213v2.png

    action 3: query that whether there is matching contact who has same emailaddress as submitted email 

    pastedimage1595580189100v3.png

    action 4: get count of result with expression: length(body('List_records')?['value')

    assign the result count to count variable.

    pastedimage1595580336145v4.png

    action 5: Define response body JSON schema.

    pastedimage1595580450504v5.png

    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

    1731.JPG

    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

  • SivaR Profile Picture
    71 on at

    Thank you so much CloFly. It worked. You are always very helpful.

    No words to thank you.

    Siva

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Syed Aqib Raza Profile Picture

Syed Aqib Raza 102

#2
11manish Profile Picture

11manish 88 Super User 2026 Season 2

#3
ParthPatel249 Profile Picture

ParthPatel249 84

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans