Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

xrm webapi Execute CRUD request

Posted on by Microsoft Employee

I noticed that the new Xrm.WebApi has an option to make a CRUD request. So far i only saw examples of executing an action and function but no CRUD. I know the api has specific method for each operation but would still like to know how to make a CRUD operation with the execute/executeMultiple methods.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: xrm webapi Execute CRUD request

    using the new v9 xrm.webapi there are 2 declared ways of performing CRUD operations, one is using the execute command which is not documented and doesnt work perfectly as i stated earlier. the other way is using a specific method such as retrieceRecord, retrieveMultipleRecords, createRecord...

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: xrm webapi Execute CRUD request

    I just opened an issue with MS documentation, let’s see if we are getting any updates on code samples for operationtype : 2 (CRUD)

    github.com/.../203

  • IanMcDonald Profile Picture
    IanMcDonald 5 on at
    RE: xrm webapi Execute CRUD request

    Hi there

    Are you saying that the retrieveRecord can be made to work?

    I am about to try this so didn't want to waste a lot of time over it

    Kind Regards

    Ian

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: xrm webapi Execute CRUD request

    Interesting, I had not taken a look at the source.  I am wondering if the API simply not complete which is why it has not been fully documented.  A quick look at the October 2018 release notes didn't show anything about Web API updates, but that document does not dive into a lot of detail.

    That might be a question for the product team, such as what is the timeline for CRUD support in Web API.  I'll reach out to some colleagues that have access to the Microsoft internal KB for this kind of thing!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: xrm webapi Execute CRUD request

    I too had to reverse engineer the script, and while i didnt check it all the way, it appears that there are several bugs. i only tried retrieve so far. in order to do that you need to specify 

     this.entityReference = {
            "etn": "incident",
            "id": "85D8D20D-3C93-E811-A952-000D3AB0FC6E"
        };

    and add this as a parameter. this.columns is an array of the fields you want to query (schema name).

    first of all in the developers guide it says to specify the operation name but the code doesnt accept "retrieveMultiple":

     switch.PNG

    second, what i found out was happening is that for each requested field there is a match to see if it is of type "lookup"/"owner"/"customer" but the type that is retrieved from the metadata is in fact "Lookup" and thus no such field exists for the query (if there is a match it returns _field_value in order to add it to the select statement). there is also no way to add filter/expand statements (althouth the script is looking for it but always on an empty array). I still didnt have the time to investigate the other operations.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: xrm webapi Execute CRUD request

    It does not look like the execute() methods support anything outside of Actions and Functions.  

    Check out this post by Andrew Butenko and his follow up: butenko.pro/.../microsoft-dynamics-365-v9-0-usage-of-new-oob-webapi-functions-part-2

    He talks briefly about having to reverse engineer the script to figure it out!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: xrm webapi Execute CRUD request

    i am talking about the execute method https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/execute 

    according the api :

        • boundParameter: (Optional) String. The name of the bound parameter for the action or function to execute. 
          Specify undefined if you are executing a CRUD request.
          Specify null if the action or function to execute is not bound to any entity. 
          Specify entity logical name or entity set name in case the action or function to execute is bound to one.
        • operationName: (Optional). String. Name of the action, function, or one of the following values if you are executing a CRUD request: "Create", "Retrieve", "RetrieveMultiple", "Update", or "Delete".
        • operationType: (Optional). Number. Indicates the type of operation you are executing; specify one of the following values: 
          0: Action
          1: Function
          2: CRUD
        • parameterTypes: Object. The metadata for parameter types. The object has the following attributes:
          • enumProperties: (Optional) Object. The metadata for enum types. The object has two string attributes: name and value
          • structuralProperty: Number. The category of the parameter type. Specify one of the following values: 
            0: Unknown
            1: PrimitiveType
            2: ComplexType
            3: EnumerationType
            4: Collection
            5: EntityType
          • typeName: String. The fully qualified name of the parameter type.

    but there is no refrence in the parameterTypes object on how to set the request, where do i put my retrieve query for example?

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: xrm webapi Execute CRUD request

    Hi golan,

    These articles cover Xrm.WebApi operations in depth.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans