Answered by:
"window.setTimeout(loadtemplate, 500);" - replacement for this javascript

Question
-
Hello experts,
I want to know the equivalent for "window.setTimeout(loadtemplate, 500);" in javascript which supports all browsers. We are using online crm.
var nodePath = "//attributes/attribute"; var doc = new ActiveXObject("Microsoft.XMLDOM"); doc.preserveWhiteSpace = true; doc.async = false; doc.loadXML(result.ReturnValue); params = new Array(); var nodelist; nodelist = doc.selectNodes(nodePath); Xrm.Page.getAttribute("description").setValue(doc.selectSingleNode("template/body").text);
And also in the above code, custom validation tool is showing that "ActiveXObject", ".selectNodes" will have problem in browsers other than ie. Can you please suggest where can i find alternative for these so the script support multiple browsers.
Thank you.
Thanks and Regards. MadhuSudhan M
Friday, September 20, 2013 5:08 AM
Answers
-
You should check out the CRM SDK - specifically the portion dedicated to client side scripting: Client-Side Programming Reference
Jason Lattimer
My Blog - Follow me on Twitter - LinkedIn- Marked as answer by Madhu-CRM Tuesday, September 24, 2013 10:24 AM
Monday, September 23, 2013 1:12 PMModerator
All replies
-
You can try setInterval as an alternate to setTimeout.
var interval=window.setInterval(function(){loadtemplate()},500); function loadtemplate() { window.clearInterval(interval); //Implement your logic here. }
- Proposed as answer by KashifZeeshan Friday, September 20, 2013 11:04 PM
- Unproposed as answer by KashifZeeshan Friday, September 20, 2013 11:04 PM
Friday, September 20, 2013 3:51 PM -
Thank you KZee. Setting time interval worked fine for me. Is there any alternative for "ActiveXObject" and ".selectNodes" as well ?
Thanks and Regards. MadhuSudhan M
Monday, September 23, 2013 5:18 AM -
ActivexObject and .selectNodes is not cross-browser compliant and hence these are being highlighted by the tool since CRM is now cross-browser compatible.
Not sure what you are trying to do here. If you are looking at setting the value of fields on crm form, you should use the XRM API to do this.
HTH
Sam
Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"
- Proposed as answer by Sam - Inogic Monday, September 23, 2013 6:14 AM
Monday, September 23, 2013 6:14 AM -
Hello Sam, I'm trying to add signature to a email form when a user tries to create an email activity. Below is the code 'm using. As you have said ActivexObject and .selectNodes is not working in firefox since its not cross browser complaint. Can you please provide me some links where i can learn how to use XRM API.
function loadtemplate() { var formType = Xrm.Page.ui.getFormType(); if (formType!= 1) {return;} var emailTemplateToLoad = "1A7DF4A2-51C8-E211-9BC9-AC162DB4BC72"; // Get Regarding object details var RegardingItems =Xrm.Page.getAttribute("regardingobjectid").getValue(); if (Xrm.Page.getAttribute("regardingobjectid").getValue() == null) {return;} var regardingObjectId = RegardingItems[0].id; var regardingObjectType = RegardingItems[0].type; var command = new RemoteCommand("EmailTemplateService", "GetInstantiatedEmailTemplate"); command.SetParameter("templateId", emailTemplateToLoad ); command.SetParameter("objectId", regardingObjectId); command.SetParameter("objectTypeCode", regardingObjectType); var result = command.Execute(); if (result.Success) { var o = new Object(); o.EmailBody = ""; o.EmailSubject = ""; if(typeof(result.ReturnValue) == "string") { var nodePath = "//attributes/attribute"; var doc = new ActiveXObject("Microsoft.XMLDOM"); doc.preserveWhiteSpace = true; doc.async = false; doc.loadXML(result.ReturnValue); params = new Array(); var nodelist; nodelist = doc.selectNodes(nodePath); Xrm.Page.getAttribute("description").setValue(doc.selectSingleNode("template/body").text); } } }
Thank you.Thanks and Regards. MadhuSudhan M
Monday, September 23, 2013 12:23 PM -
You should check out the CRM SDK - specifically the portion dedicated to client side scripting: Client-Side Programming Reference
Jason Lattimer
My Blog - Follow me on Twitter - LinkedIn- Marked as answer by Madhu-CRM Tuesday, September 24, 2013 10:24 AM
Monday, September 23, 2013 1:12 PMModerator