Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Getting all fields from Form.

Posted on by Microsoft Employee

I am using below cde but its not working pls some one help me.

function getFieldListFromTab(tabId)
{
    var fieldList = new Array();

    var tab = Xrm.Page.ui.tabs.get(tabId);

    tab.sections.forEach(function (section, sectionIndex)
    {
        section.controls.forEach(function (control, controlIndex)
        {
            var attribute = control.getAttribute();

            if (attribute != null)
            {
                fieldList.push(attribute.getName());
            }
        });
    });

    return fieldList;
}

*This post is locked for comments

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: Getting all fields from Form.

    Hi Naresh,

    You can also refer the following link to retrieve all controls:

    www.mscrmconsultant.com/.../retrieve-form-all-controls-using.html

    Regards,

    Rajkumar Rajaraman

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Getting all fields from Form.

    Hi,

    Try the following code:

    function getFieldListFromTab(tabId)
    {
        var fieldList = new Array();
    
        var tab = Xrm.Page.ui.tabs.get(tabId);
    
        tab.sections.forEach(function (section, sectionIndex)
        {
            section.controls.forEach(function (control, controlIndex)
            {
                switch (control.getControlType())
                {
                    case "standard":
                    case "lookup":
                    case "optionset":
                        var attribute = control.getAttribute();
    
                        if (attribute != null)
                        {
                            fieldList.push(attribute.getName());
                        }
                        break;
                }
            });
        });
    
        return fieldList;
    }

    See: http://www.xrmcoaches.com/2012/04/retrieve-all-of-the-field-names-in-a-tab/

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Getting all fields from Form.

    You need to put a check for control types subgrid in section. Use below code:

    function getFieldListFromTab(tabId)
    {
        var fieldList = new Array();
    
        var tab = Xrm.Page.ui.tabs.get(tabId);
    
        tab.sections.forEach(function (section, sectionIndex)
        {
            section.controls.forEach(function (control, controlIndex)
            {
    			if(control.getControlType() != "subgrid" && control.getControlType() != "iframe" && control.getControlType() != "webresource" &&
    				control.getControlType() != "notes" )
    			{
    				var attribute = control.getAttribute();
    
    				if (attribute != null)
    				{
    					fieldList.push(attribute.getName());
    				}
    			}
            });
        });
    
        return fieldList;
    }


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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans