Notifications
Announcements
No record found.
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
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
you can refer below links
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.
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"
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
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
Thanks i fixed it , my action name was wrong
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2