Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

show / hide a section

(0) ShareShare
ReportReport
Posted on by 1,695

please be gentle .. I'm learning

I have two sections in a tab (SUMMARY_TAB)

Section 'Section_ATAGLANCE' has a two option field new_ddmandate

Section 'Section_DirectDebit' has three fields.

what I want to do is on form load hide the Section_DirectDebit IF the value of new_ddmandate is false

I have had a look at some JS but to be fair im a bit confused. I've tried using 

function showhidedirectdebit()
{
var paybydd = Xrm.Page.data.entity.attributes.get("new_ddmandate").getValue();
if(paybydd == 1)
Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("Section_DirectDebit").setVisible(true);
else
Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("Section_DirectDebit").setVisible(false);
}

 but just get an error. Can anyone see where I have gone wrong in the first instance before I start posting up error code

*This post is locked for comments

  • Pete_N Profile Picture
    Pete_N 1,695 on at
    RE: show / hide a section

    I used the code Rawish posted

    function showhidedirectdebit()

    {

      var paybydd = Xrm.Page.getAttribute("new_ddmandate").getValue();  

      if (paybydd == 1)

          Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("Section_DirectDebit").setVisible(true);

      else

          Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("Section_DirectDebit").setVisible(false);

    }

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: show / hide a section

    It seems my response was late so please ignore it.

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: show / hide a section

    Hi,

    Can you please re-share your complete code, it seems there is some syntax error in your code.

  • Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: show / hide a section

    Okay  great!

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: show / hide a section

    make sure you did exactly this:
    24784.1.png

    2. try to add crm  url to trusted site.

    3. try to debug the script blogs.msdn.microsoft.com/.../debugging-custom-javascript-code-in-crm-using-browser-developer-tools

  • Pete_N Profile Picture
    Pete_N 1,695 on at
    RE: show / hide a section

    Scrub my previous answer, I made a mistake in calling the function …  your code works perfectly

    Thank you

  • Pete_N Profile Picture
    Pete_N 1,695 on at
    RE: show / hide a section

    HI,

    I have tried your code and am getting the same error

    TypeError: Object expected

      at eval code (eval code:1:1)

      at RunHandlerInternal (xxxx/.../ClientApiWrapper.aspx)

      at RunHandlers (xxxx/.../ClientApiWrapper.aspx)

      at OnScriptTagLoaded (xxxx/.../ClientApiWrapper.aspx)

      at Anonymous function (xxxx/.../ClientApiWrapper.aspx)

  • Verified answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: show / hide a section

    Hi There,

    Please dont worry. Everyone is learning here from each other.

    I copied your script and made a few modifications and it worked for me. :

    function showhidedirectdebit()

    {

       var paybydd = Xrm.Page.getAttribute("new_ddmandate").getValue();  

       if (paybydd == 1)

           Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("Section_DirectDebit").setVisible(true);

       else

           Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("Section_DirectDebit").setVisible(false);

    }

    would you please try above and let me know what are you get /or were getting?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans