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
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.
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.
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6