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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create entity and webhook call

(0) ShareShare
ReportReport
Posted on by

I have managed to make a web hook call when if I update a contact entity, it will call a web hook endpoint. In this webhook call, I also call the CRM API to get the contact entity since I cannot parse the post image successfully. In any event, works great.

However when creating one for creating an entity, the problem I am having is that the entity in CRM is not actually committed to CRM but do get an entity ID. This makes sense however I am unable to then convert the JSON being posted into a proper Contact object as it fails deserialization.

How can I get the contact entity, on create, so I can pull out the properties I need and ALSO set a property in the contact entity?

using Dynamics 365.

thank you.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    Hi, CRM also have transaction scope. If I understand correctly about your question you must creating :

    1. Create plugin on pre-operation/post-operation (In transaction scope).

    2. After create, you need to retrieve using Service.Retrieve("entityName", entityId, new ColumnSet("attr1", "attr2"));

    3. Do your operation, either calling another web services and update your entity which just create on step no 2.

    Please give us your code and what error given from CRM so we more clearly understand about your situation.

  • Community Member Profile Picture
    on at

    Thank you.

    The code is simple but that is not the issue here, in essence.

    I have a webhook and I create a post validation create message image. (Create on contact and we have customized contact entity).

    Message: Create

    Primary Entity: contact

    Event Handler (WebHook) CreateContact

    Event Pipeline stage of execution: PostOperation in Sync mode

    Deployment: Server

    Now, when the contact is created in CRM 365, it calls the webhook - great. BUT when retrieving the entity with the given ID, it fails to find it and throws an error that the entity was not found.

    How can I get it to invoke the web hook AFTER CRM itself creates the entity so I can then access the entity in the webhook using the ServiceProxy/context?

    The code to retrieve is simple. This works for UPDATE but NOT Create:

    // Create Organization Service Proxy

               var _serviceProxy = new OrganizationServiceProxy(this.CRMEndpointURL, null, clientCredentials, null);

               _serviceProxy.EnableProxyTypes();

               var orgContext = new OrganizationServiceContext(_serviceProxy);

               // retrieve the contact object

               var cols = new ColumnSet(true);

               Contact c = _serviceProxy.Retrieve("contact", contactID, cols) as Contact;

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans