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

Call Action with Output in JavaScript

(0) ShareShare
ReportReport
Posted on by 196

Hi

I want to call an action with JavaScript which has an Output. I can call the action fine but I can't get the Output Parameter for some reason. How can I do this?

regards

Manuel

I have the same question (1)
  • meelamri Profile Picture
    13,216 User Group Leader on at

    Hello, 

    Please can you screenshot your action and your js code ?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Take a look below reference  -

    www.wipfli.com/.../160810-calling-custom-actions-from-javascript

  • zica Profile Picture
    on at

    Could you please provide the source code?

    You may need to define a variable outside the the function call and assign the value of output to that variable in order to have access to it later.

  • Manuel Steiner Profile Picture
    196 on at

    My code is as follows:

    var parameters = {};

           parameters.DateFrom = JSON.stringify(new Date("03/10/2015 01:30:00").toISOString());

           parameters.DateTo = JSON.stringify(new Date("02/13/2050 01:30:00").toISOString());

           var product = {};

           product.productid = "05f18edb-881a-ea11-a811-000d3ab8d5b5"; //Delete if creating new record

           product["@odata.type"] = "Microsoft.Dynamics.CRM.product";

           parameters.Product = product;

           parameters.Quantity = 5;

           var ambcust_CheckProductAvailabilityRequest = {

               DateFrom: parameters.DateFrom,

               DateTo: parameters.DateTo,

               Product: parameters.Product,

               Quantity: parameters.Quantity,

               getMetadata: function() {

                   return {

                       boundParameter: null,

                       parameterTypes: {

                           "DateFrom": {

                               "typeName": "Edm.DateTimeOffset",

                               "structuralProperty": 1

                           },

                           "DateTo": {

                               "typeName": "Edm.DateTimeOffset",

                               "structuralProperty": 1

                           },

                           "Product": {

                               "typeName": "mscrm.product",

                               "structuralProperty": 5

                           },

                           "Quantity": {

                               "typeName": "Edm.Int32",

                               "structuralProperty": 1

                           }

                       },

                       operationType: 0,

                       operationName: "ambcust_CheckProductAvailability"

                   };

               }

           };

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

               function success(result) {

                   if (result.ok) {

                       var results = JSON.parse(result.responseText);

                   }

               },

               function(error) {

                   Xrm.Utility.alertDialog(error.message);

               }

           );

    I did this with the REST Builder and made it fromn the ground too so I din't know that to do. the action should return an Output result "IsFree" which is a boolean. It works with the deprecated XMLHttp Request.

  • Manuel Steiner Profile Picture
    196 on at

    And it gives me back a ok status but no statustext or anything. just an url

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

    Hello,

    You need to use json method of call result to access Output of your action. Check following post that describes the approach to use - www.inogic.com/.../

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 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans