Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Forwarding to error page from marketing page in dynamics 365

Posted on by 459

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

  • SivaR Profile Picture
    SivaR 459 on at
    RE: Forwarding to error page from marketing page in dynamics 365

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

    No words to thank you.

    Siva

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Forwarding to error page from marketing page in dynamics 365

    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
    SivaR 459 on at
    RE: Forwarding to error page from marketing page in dynamics 365

    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

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Forwarding to error page from marketing page in dynamics 365

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans