Reputation: 863
So I have a form with 3 sections. I want a functionality where Section 1 gets filled than section 2 shows up and so on.
I know the basic code of JavaScript but I don't know where to use it or how to invoke it. I have made a web resource with SHOW and HIDE functions, now how do I invoke them.
I am currently working the idea of using JAVA SCRIPT to hide the sections and show the latter sections when the former gets filled up. Here is my code.
function Hide()
{ Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(false); }
function Show()
{ Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(true); }
Now I am aware that Show()
will get attached to the last field of section 1 of the form, but what about the Hide()
function? where will I invoke it?
Upvotes: 3
Views: 10637
Reputation: 21
We can use this code for hiding/show tab:
Show:
Xrm.Page.ui.tabs.get("TabName").setVisible(true);
Hide:
Xrm.Page.ui.tabs.get("TabName").setVisible(false);
Upvotes: 0
Reputation: 186
I came across this while looking for code for something similar. Don't think it's exactly what you want but it may help!
The guy has a few other useful articles on Dynamics CRM 2011 too.
Upvotes: 1
Reputation: 1158
Firstly i guess it's a personal preference however I would have a "validate" function and ensure you have all the information you need before hiding the first section (what happens if they enter the last field first for instance?)
Then I would just do something like the following and call it on all fields in the section:
function SectionOneField_OnChange()
{
if (IsSectionOneValid())
{
Xrm.Page.ui.tabs.get("NextTab").sections.get("NextSection").controls.get(0).setFocus();
Xrm.Page.ui.tabs.get("FirstTab").sections.get("SectionOne").setVisible(false);
}
}
Side note : As with most CRM javascript this probably isn't Microsoft supported :-)
Upvotes: 1