Skip to main content

Notifications

Dynamics 365 Community / Forums / Sales forum / How to read the Input ...
Sales forum
Suggested answer

How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

Posted on by 359

Hi, 

I have a functionality to trigger the plugin on button click, so for that, I have created a custom button, on button click I am calling Js and there in Js I am triggering the action. This action I have created for the opportunity entity with Input parameter(type of entity reference).

All are going good my plugin also getting triggered but not able to ready the Input parameter value, like I don't know the syntax to ready the entity reference parameter of an action inside the plugin.

My Action

pastedimage1684948064007v1.png

My code

I am getting error here in yellow highlighted, line number 46.

Please suggest me the syntax to read this parameter value

Categories:
  • Suggested answer
    Himanshu Kamboj Profile Picture
    Himanshu Kamboj 359 on at
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    My plugin code is working fine, now I have created the XMLHTTP api for that action and now, I am passing the string parameter instead of entity reference.

  • Himanshu Kamboj Profile Picture
    Himanshu Kamboj 359 on at
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    I have already attached the ss in above qtn.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    Hi,

    Try to execute your custom action from c# console app to confirm it works.

    www.ashishvishwakarma.com/.../

    If it works then we know there is something wrong in js code 

    I would request you to generate js code using Dataverse rest builder tool

  • Suggested answer
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    Hi Himanshu, 

    Can you post your code you are trying to ? 

    Thanks

  • Himanshu Kamboj Profile Picture
    Himanshu Kamboj 359 on at
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    Object reference is not set to an instance of an object.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    Hi,

    What is the error you are getting??

  • Himanshu Kamboj Profile Picture
    Himanshu Kamboj 359 on at
    RE: How to read the Input Parameter(Entity Reference Type) of an Action into Plugin

    Here I have attached my JS.

    function callActionToReopenOpp(primaryControl){

       var formContext = primaryControl;

       var Id = formContext.data.entity.getId().replace('{', '').replace('}', '');

       var target = {};

       target.entityType = "opportunity";

       target.id = Id;

       var req = {};

       req.entity = target;

       req.InputParam = target;

       req.getMetadata = function () {

               return {

                   boundParameter: "entity",

                   parameterTypes: {

                       "entity": {

                           typeName: "mscrm.opportunity",

                           structuralProperty: 5

                       }

                   },

                   "InputParam": {

                       "typeName": "mscrm.opportunity",

                       "structuralProperty": 5

                   },

                   operationType: 0,

                   operationName: "ReopenOpportunityFromDeclinedStage"

               };

       };

       Xrm.WebApi.online.execute(req).then(

           function success(result) {

               if (result.ok) {

                   //Success - No Return Data - Do Something

                   alert("Web API Action Called Successfully...");

               }

           },

           function(error) {

               Xrm.Utility.alertDialog(error.message);

           }

       );

    }

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,107 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,969 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans