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 Output Parameter not being returned from the plugin

(0) ShareShare
ReportReport
Posted on by 1,532

Hi

I am using CRM 

Microsoft Dynamics® CRM 2016(8.1.0.359) (DB 8.1.0.359)

I am using a custom action and plugin.

The output parameter that I am setting is called "IsStatus".   I response result is coming back with nothing.  Not sure what I am doing wrong.

5483.actionProcess.JPG

javascript code - responseText is coming back with nothing

$.ajax({
     url: organizationUrl + "/api/data/v8.0/new_CreateNewCaseDataSheet",
     type: 'POST',
     contentType: "application/json; charset=utf-8",
     datatype: "json",
     data: data,
     success: function (responseText) {
         //var jsonData = JSON.stringify(responseText); 
         //var getStatus = JSON.parse(this.responseText);
         //isStatus = getStatus.isStatus;
         alert(" -- Action Called - 23");
         //    updateMap(myArr); 
         window.close();
         return false;
         
          },


Plugin Code

       // TODO: Implement your custom Plug-in business logic.
       IPluginExecutionContext context = localContext.PluginExecutionContext;
       IOrganizationService service = localContext.OrganizationService;

       if (context.InputParameters.Contains("EntityArg") && context.InputParameters["EntityArg"] is Entity)
       {
           context.OutputParameters["IsStatus"] = false;
           bool isStatus = true;
           context.OutputParameters["IsStatus"] = isStatus;
       }


*This post is locked for comments

  • Suggested answer
    Kjeld Poulsen Profile Picture
    180 on at
    RE: Custom Action Output Parameter not being returned from the plugin

    I had similar issue and found, if a mandatory output parameter is set in PRE stage they are overridden by the framework before the hit the client, while setting them in POST stage it works as it should.

    The PRE | POST pattern i not really that relevant for actions, because in most cases you just need one hook where you can put your synchronized code, so i simply changed my plugin to be registred on POST event rather than PRE event, and now i get values from the OutputParameters back to the client as expected..

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Glad that you were able to do that.

  • Verified answer
    rthompson Profile Picture
    1,532 on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Hi Andrew,

    With the help of this link https://arunpotti.wordpress.com/2014/11/30/html-webresource-example-in-crm/

    I manage to fix my issue.  Here's the working code.

      function CallActionPlugin(datatracking) {
    
          var isStatus;
          var organizationUrl = serverUrl;
    
          var query = "new_CreateNewCaseDataSheet"
    
          var data  = JSON.stringify(datatracking);
    
          $.ajax({
              url: organizationUrl + "/api/data/v8.0/" + query,
              type: 'POST',
              contentType: "application/json; charset=utf-8",
              async: false,
              datatype: "json",
              data: data,
              beforeSend: function (XMLHttpRequest) {
                  //Specifying this header ensures that the results will be returned as JSON.
                  XMLHttpRequest.setRequestHeader("Accept", "application/json");
              },
              success: function (responseText) {
                  var jsonData = JSON.stringify(responseText); 
                  var getStatus = JSON.parse(jsonData);
                  isStatus = getStatus.IsStatus;
    
                  alert(" -- Action Called - 23");
    
    window.close(); return false; }, error: function (jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect.\n Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error.\n' + jqXHR.responseText; } alert(msg); } }); }


  • rthompson Profile Picture
    1,532 on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Hi Andrew,

    Here's what I am seeing in the metadata

    <ComplexType Name="new_CreateNewCaseDataSheetResponse">

    <Property Name="IsStatus" Type="Edm.Boolean" Nullable="false"/>

    </ComplexType>

    <Action Name="new_CreateNewCaseDataSheet">

    <Parameter Name="EntityArg" Type="mscrm.new_datatracking"/>

    <ReturnType Type="mscrm.new_CreateNewCaseDataSheetResponse" Nullable="false"/>

    </Action>

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Can you check /api/data/v8.0/$metadata . Check that output argument is available there.

  • rthompson Profile Picture
    1,532 on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Plugin that is setting the output Parameter to true.

    ResponseText.JPG

    The response is coming back with nothing.

    ResponseText.JPG

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Ok. That shows that your code works and reaches setting of value.

    Can you please provide code that you use to check output value?

    That piece of your code in initial post is commented out:

                 //var getStatus = JSON.parse(this.responseText);

                 //isStatus = getStatus.isStatus;

    Even if you will use it you should use IsStatus and not isStatus.

    Good luck.

  • rthompson Profile Picture
    1,532 on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Here's the input parameters from the plugin.

    Plugin

    InputParameter.JPG

    Debugging

    InputParameter.JPG

  • rthompson Profile Picture
    1,532 on at
    RE: Custom Action Output Parameter not being returned from the plugin

    Did not show all this code.

            var XrmP = window.top.opener.frames[0].Xrm;

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Custom Action Output Parameter not being returned from the plugin

    I mean your JS code is not valid. It will not work.

    Regarding fact that "your input parameters are working in the plugin" - why are you so sure?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans