3
votes

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?

3
please edit your question instead adding the code inside a commentGuido Preite
So you're saying that you want to hide sections 2 and 3 at first? Try putting it in the load event of the document stackoverflow.com/questions/3880307/…Dan Drews
make all 3 sections invisible on the form. in onload() make section 1 visible. then you'll have to mess around with the onchange events of the fields in section 1 to determine if section 2 should be visible or not. same for section 3 based on section 2 etc.keerz

3 Answers

1
votes

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 :-)

1
votes

I came across this while looking for code for something similar. Don't think it's exactly what you want but it may help!

http://www.magnetismsolutions.co.nz/blog/11-06-28/Show_a_Tab_Based_on_a_Radio_Button_Dynamics_CRM_2011.aspx

The guy has a few other useful articles on Dynamics CRM 2011 too.

0
votes

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);