Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

add_tabStateChange is not a function

Posted on by 420

I'm trying to follow this simple guide ( https://community.dynamics.com/crm/b/misscrm360exploration/archive/2015/06/29/tab-state-change-event-crm-javascript ), but i get the error 

add_tabStateChange is not a function

Anyone was able to make this work?
My code: 

test = function () {
    Xrm.Page.ui.tabs.forEach(
                function (tab, index) {
                    Xrm.Page.ui.tabs.get(index).add_tabStateChange(function () {
                        var currTabState = Xrm.Page.ui.tabs.get(index).getDisplayState();
                        if (currTabState == "expanded") {
                            alert("Expanded");
                        }
                        else {
                            alert("Collapsed");
                        }
                    });
                }
    );
}



*This post is locked for comments

  • anonsgate Profile Picture
    anonsgate 420 on at
    RE: add_tabStateChange is not a function

    addTabStateChange  worked! Thank you

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: add_tabStateChange is not a function

    Instead of add_tabStateChange use addTabStateChange. I had same issue and it worked for me.

  • anonsgate Profile Picture
    anonsgate 420 on at
    RE: add_tabStateChange is not a function

    Putting tab instead of index doesn't work.

    I ended up changing my code and putting it inside of the tabchange event of the tab on the form instead of the form's onload. So I marked Andrew's answer, even though I'm still wondering why the article I linked doesn't work.

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: add_tabStateChange is not a function

    Hi,

    Instead 'index' it should be 'tab', Please give a try :

    Xrm.Page.ui.tabs.get(tab).add_tabStateChange(function ()

    Thanks

    Hemant

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: add_tabStateChange is not a function

    Hello,

    Check this - msdn.microsoft.com/.../gg334481.aspx but to make it work you will have to rework your code a bit.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans