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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

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

(0) ShareShare
ReportReport
Posted on by 425

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

I have the same question (0)
  • Himanshu Kamboj Profile Picture
    425 on at

    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);

           }

       );

    }

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    What is the error you are getting??

  • Himanshu Kamboj Profile Picture
    425 on at

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

  • Suggested answer
    Anupam.khasia Profile Picture
    170 on at

    Hi Himanshu, 

    Can you post your code you are trying to ? 

    Thanks

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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

  • Himanshu Kamboj Profile Picture
    425 on at

    I have already attached the ss in above qtn.

  • Suggested answer
    Himanshu Kamboj Profile Picture
    425 on at

    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.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans