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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Custom action with a complex input parameter (entityreference)

(0) ShareShare
ReportReport
Posted on by

I create a global (unbound) action in Dynamics 365 (new_newAction) that accepts an input parameter ( of name Target )  with type (EntityReference) and activate it.

I checked that my action is available throw WebAPI

 I want to call it in a JavaScript method, but for testing I wanted to call it from a REST Client ( example Postman, Insomnia  SoapUI).

 To do that  I did the following :

-          I use method POST with a json payload

-          I put my credential ( other calls to the WebAPI endpoint work)

-          I put the Url :   server/organization/api/data/v8.2/tgz_newAction

-          I put necessary headers :

Accept: application/json

OData-MaxVersion: 4.0

OData-Version: 4.0

Content-Type: application/json; charset=utf-8

 -          I put the payload but it’s not correct

Example :

{

     "inputTarget" :

           {

              "@odata.type": "Microsoft.Dynamics.CRM.crmbaseentity",

              "@odata.id": "78713858-5e81-df11-afdb-00155dba380a",

              "@odata.LogicalName": "new_entity",

              "@odata.Name": "new_entity"

         }

}

 But that it’s not working.  Do you have any idea ?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Fouad,

    Define particular entity type for your input.

  • Community Member Profile Picture
    on at

    the problem is that i want that my plugin be used for différents entities. (

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Then the easiest solution for you is to use string field and pass serialized version of entity reference inside.

  • Community Member Profile Picture
    on at

    why we have the possibility to define a entityreference and not to use it.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I believe it would work with SOAP endpoint (when Actions were introduced). Looks like it's platform limitation of WebApi endpoint.

  • Community Member Profile Picture
    on at

    thank you for your speed answers.

  • Verified answer
    Community Member Profile Picture
    on at

    I make it worked when i use the following payload :

    {

        "inputTarget" :

              {

                 "@odata.type": "Microsoft.Dynamics.CRM.new_NewEntity",

                 "new_NewEntity.id": "78713858-5e81-df11-afdb-00155dba380a",

                 // no need to put name and logical name.

            }

    }

  • Suggested answer
    Daryl LaBar Profile Picture
    500 Most Valuable Professional on at

    Your solution has a typo, "new_NewEntity.id" should not have the period before "id" ("new_newentityid") and I believe it should be lowercase as well.

    {
    
        "inputTarget" :
    
              {
    
                 "@odata.type": "Microsoft.Dynamics.CRM.new_NewEntity",
    
                 "new_newentityid": "78713858-5e81-df11-afdb-00155dba380a",
    
                 // no need to put name and logical name.
    
            }
    
    }
  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    Yes Daryl is right. This below line

    "new_newentityid": "78713858-5e81-df11-afdb-00155dba380a",


    should has either new_newentityid or "new_newentityid"

    Double quote (") is ok. No need of identifier (@) or dot (.)

     

    "new_newentityid": "78713858-5e81-df11-afdb-00155dba380a",

    or

    new_newentityid: "78713858-5e81-df11-afdb-00155dba380a",


  • Community Member Profile Picture
    on at

    Hello everyone,

    Doing pretty much the same - calling Action with JS:

    let parameters = {};

       parameters.myParameter =  {

        "inputTarget" :

            {

                "@odata.type": "Microsoft.Dynamics.CRM.new_myEntity",

                "new_myEntityid": parent.Xrm.Page.data.entity.getId().replace(/[{}]/, ''),

            }

       }

       parameters.Target = {

           entityType: "new_myEntity",

           id: entityId,

       };

    But getting an error: Input field type 'JObject' does not match expected type 'EntityReference' for field 'myParameter'

    Any suggestions on what am I doing wrong?

    Thanks in advance.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans