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

Announcements

No record found.

News and Announcements icon
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 429

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
    429 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
    429 on at

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

  • Suggested answer
    Anupam.Khasia Profile Picture
    181 Super User 2026 Season 1 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
    429 on at

    I have already attached the ss in above qtn.

  • Suggested answer
    Himanshu Kamboj Profile Picture
    429 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 189 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 66

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans