Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Contact created using API

Posted on by Microsoft Employee

I created a contact in Dynamics 365 by using SOAP Api. Is there a flag or audit stamp in dynamics which would confirm that the contact was created/modified by API?

Thanks, 

Manik Soi

*This post is locked for comments

  • Suggested answer
    NicksTuk Profile Picture
    NicksTuk 1,833 on at
    RE: Contact created using API

    You could either use a specific account only for records created through API, or you could put a custom flag on the record and raise it for records created in that manner, if you need to track that.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Contact created using API

    Hi,

    If you are using WebApi, the following should be your code to create a Contact record:

    var entity = {};

    entity.firstname = "John";

    entity.lastname = "Smith";

    entity.emailaddress1 = "john.smith@contoso.com";

    entity.new_createdfromwebapi = 1;

    var req = new XMLHttpRequest();

    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/contacts", 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) {

               var uri = this.getResponseHeader("OData-EntityId");

               var regExp = /\(([^)]+)\)/;

               var matches = regExp.exec(uri);

               var newEntityId = matches[1];

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(entity));

    The newEntityId will return the newly created contact Id value from your request. If there is a value there, you know contact is created.

    You can add a field to your contact entity called Created from Api, which you pass to your contact form that will specify when this was created from the Web Api. You can probably use one of the existing fields on the contact entity for this as well.

    Hope this helps.

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