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 :
Microsoft Dynamics CRM (Archived)

Invoking a custom action through JavaScript

(0) ShareShare
ReportReport
Posted on by

How can we invoke a custom action through JavaScript and use the output parameters of the action in the script, in Microsoft dynamics CRM?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    tw0sh3ds Profile Picture
    5,600 on at

    There are many tutorials for that. Example for calling action from JS here:

    community.dynamics.com/.../web-api-executing-custom-action-via-javascript

    And setting output parameters:

    www.powerobjects.com/.../setting-output-parameters-in-plugins-for-custom-actions

  • Verified answer
    ARIFNIIT Profile Picture
    1,391 on at

    you can refer below links

    community.dynamics.com/.../web-api-executing-custom-action-via-javascript

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    If you don't want to use webapi, you can use the process.js library by Paul Nieuwelaar as an alternative.

    Very easy to use. You can find the files here:

    github.com/.../processjs

    Hope this helps.

  • Community Member Profile Picture
    on at

    function triggerAction() {
    debugger;
    alert("hello");
    var serverURL = Xrm.Page.context.getClientUrl();

    var req = new XMLHttpRequest();
    req.open("POST", serverURL + "/api/data/v9.0/rvg_DetectDuplicate", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.onreadystatechange = function () {
    debugger;
    if (this.readyState == 4 /* request completed */) {
    req.onreadystatechange = null;
    alert("Request Sent");
    if (this.status == 200 /* response ready */) {
    var data = JSON.parse(this.response);
    }
    else {
    var error = JSON.parse(this.response).error;
    alert("Error is : " + error.message);
    }
    }
    };
    req.send();
    alert("Request Completed");
    }

    This is my code, and my action is a global action with name "rvg_DetectDuplicate", i am getting an error - "Resource not found for rvg_DetectDuplicate"

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    A couple of questions:

    1. are you able to debug and see where your error occurs (what line)?

    2. Is your action activated?

    Check the following if your action appears:

    community.dynamics.com/.../why-my-action-is-not-available-through-webapi

    Let me know

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Rahul,

    What is the type of the output parameters of the action?

    Simple output parameters: boolean, datetime, decimal, float, integer, money, picklist, string

    Complex output parameters: EntityReference, Entity, EntityCollection

    You can have any combination of simple output parameters or single complex output parameter to make your action available for WebApi.

    But it has a limitation.i.e, if you combine complex output parameter with any other one (including another complex output parameter), your action becomes unavailable for WebApi calls.

    See: community.dynamics.com/.../why-my-action-is-not-available-through-webapi

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks i fixed it , my action name was wrong

  • Suggested answer
    CRM Crate Profile Picture
    45 on at

    Please refer the below article to call action from JavaScript code :

    www.crmcrate.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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans