oData: When do I need to load jQuery?
-
maandag 30 april 2012 21:44
Hi there,
This question is more of a generic question on "best practices" in CRM development, as I am not looking for a definitive answer to a technical issue.
I've been flirting with oData in a CRM 2011 implementation for the past week, and so far I managed to do a lot without needing to load a jquery library into my CRM.
However I was under the impression that I would require to load the jQuery library to do most of the oData stuff I've been able to do so far. So I am quite confused.
Could somebody please give me some examples (e.g.: cases, scenarios) where loading the jQuery library would be necessary? is this something one could tell beforehand?
Thanks for your comments.
Regards,
P.
MCC, MCT, MCP, MCTS
If you find this post helpful then please "Vote as Helpful". If I helped you with an answer to a question then please "Mark As Answer".
Alle reacties
-
maandag 30 april 2012 23:12
You don't need jQuery to use OData/REST; it merely allows you to write cleaner code, as jQuery implements much of the plumbing required, such as the XmlHttpRequest instantiation and configuration, and the JSONification of the returned results. For example (from the SDK):
var account = {}; account.Name = "Sample Account"; var jsonAccount = window.JSON.stringify(account); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", datatype: "json", url: Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet", data: jsonAccount, beforeSend: function (XMLHttpRequest) { //Specifying this header ensures that the results will be returned as JSON. XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (data, textStatus, XmlHttpRequest) { account = data.d; }, error: function (XMLHttpRequest, textStatus, errorThrown) { errorHandler(XMLHttpRequest, textStatus, errorThrown); } });
--pogo (pat) @ pogo69.wordpress.com
-
dinsdag 1 mei 2012 4:38Moderator
Hi,
if you are writing code on CRM entity form you don't need to load jquery, at least I did all my code without loading it.
But if you are trying to use OData/Rest out side of entity form you need to load jquery, for example if you have webresource in your dashboard where you need some data from crm entities, in order to use JSON, you need to include jquery library in your webresource.
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
dinsdag 1 mei 2012 12:03
Hi there!
For Odata you need to upload json2, jquery 1.6.1min.js files, when you are working on global context through injecting on the webresouces , if with in crm context use the onload event and upload json2 and jquery library files. Make sure you follow order like first upload json and then jquery.
Hope this answers your question!
Thanks
Sama
SAMA