Notifications
Announcements
No record found.
How to call a webservice from javascript in CRM ?please explain the steps with scenario.
*This post is locked for comments
Here is an example using Javascript mahenderpal.wordpress.com/.../calling-external-webservice-using-js
However usin jquery may be easier spring.io/.../consuming-rest-jquery
hth
Joe
Hi Michel,
Using CRM web resource you can call OData services using Ajax call.
Odata query reference link : msdn.microsoft.com/.../gg309461(v=crm.7).aspx
Ajax call reference link:
guruprasadcrm.blogspot.in/.../update-optionset-lookup-data-using.html
Thanks,
Sandeep
Thank you.
You can use an XMLHttpRequest with OData to call the CRM webservice endpoint. I've used the following javascript function to retrieve a record in CRM:
function RetrieveRecord(id, entityType, select, expand, sCallback, eCallback) { var sURL = Xrm.Page.context.getClientUrl(); // Make sure the trailing / is there if (sURL.charAt(sURL.length - 1) != '/') sURL += '/'; var _ODataPath = sURL + "XRMServices/2011/OrganizationData.svc/"; var systemQueryOptions = ""; if (select != null || expand != null) { systemQueryOptions = "?"; if (select != null) { var selectString = "$select=" + select; systemQueryOptions = systemQueryOptions + selectString; } if (expand != null) { systemQueryOptions = systemQueryOptions + "&$expand=" + expand; } } var url = _ODataPath + entityType + "Set(guid'" + id + "')" + systemQueryOptions; //alert(url); var req = new XMLHttpRequest(); req.open("GET", url, true); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState == 4) { if (this.status == 200) { var retrieved = JSON.parse(this.responseText).d; // Do something } else { if(eCallback != null) eCallback(req.statusText); } } } req.send(); }
Hope that helps.
John
thanks john
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