Answered by:
Alternative for "Xrm.Page.ui.controls.get('WebResource_Name')" or "Xrm.Page.getControl('WebResource_Name')" methods for Microsoft Dynamics CRM Online

Question
-
Hi,
I have inserted a web resource (containing a select control) on one of my custom entity form. I am using the following JavaScript code to disable the select control on save of the entity form.
(Xrm.Page.getControl('WebResource_Name').getObject().getElementsByTagName('select'))[0].disabled = true;
This code works fine for Microsoft Dynamics CRM 2013 on-premise, but not for Microsoft Dynamics CRM Online. "Xrm.Page.ui.controls.get('WebResource_Name')" and " Xrm.Page.getControl('WebResource_Name')" methods are not supported by Microsoft Dynamics CRM Online.
Is there any way to solve this problem?
Monday, February 2, 2015 12:41 PM
Answers
-
Hi!
I did a blog about accessing webresources functions from the parent page a while back - but it still applies:
http://www.develop1.net/public/post/Calling-a-function-in-a-Html-Webresource-from-another-Javascript-Webresource.aspx
Basically you will need to create a function on your webresource page that you then call from your on save event on the parent page. You can then call that function from the on save event using:
Xrm.Page.getControl("WebResource_<Name>").getObject().contentWindow.window.fooBar();
That function can then do what you need it to do such as disable your optionset.
Hope this helps,
Scott
Scott Durow
Blog www.develop1.netFollow Me
Rockstar365
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"- Proposed as answer by Scott Durow (MVP)MVP, Editor Monday, February 2, 2015 7:58 PM
- Marked as answer by P H S Tuesday, February 3, 2015 11:53 AM
- Unmarked as answer by P H S Tuesday, February 3, 2015 11:53 AM
- Marked as answer by P H S Tuesday, February 3, 2015 12:02 PM
Monday, February 2, 2015 7:58 PMAnswerer -
Something went wrong, but both the methods are supported by Microsoft Dynamics CRM Online environment and work fine. Thanks for your help.
- Marked as answer by P H S Tuesday, February 3, 2015 12:02 PM
Tuesday, February 3, 2015 12:01 PM
All replies
-
Hi!
I did a blog about accessing webresources functions from the parent page a while back - but it still applies:
http://www.develop1.net/public/post/Calling-a-function-in-a-Html-Webresource-from-another-Javascript-Webresource.aspx
Basically you will need to create a function on your webresource page that you then call from your on save event on the parent page. You can then call that function from the on save event using:
Xrm.Page.getControl("WebResource_<Name>").getObject().contentWindow.window.fooBar();
That function can then do what you need it to do such as disable your optionset.
Hope this helps,
Scott
Scott Durow
Blog www.develop1.netFollow Me
Rockstar365
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"- Proposed as answer by Scott Durow (MVP)MVP, Editor Monday, February 2, 2015 7:58 PM
- Marked as answer by P H S Tuesday, February 3, 2015 11:53 AM
- Unmarked as answer by P H S Tuesday, February 3, 2015 11:53 AM
- Marked as answer by P H S Tuesday, February 3, 2015 12:02 PM
Monday, February 2, 2015 7:58 PMAnswerer -
Something went wrong, but both the methods are supported by Microsoft Dynamics CRM Online environment and work fine. Thanks for your help.
- Marked as answer by P H S Tuesday, February 3, 2015 12:02 PM
Tuesday, February 3, 2015 12:01 PM