简体   繁体   中英

How to change a section name in dynamics crm 2013

I want to change a section name if my checkbox is checked their is my code
I was trying to use a loop but I still had the same error !!
and I got this Error Message Champ :cac_is_demande_mere Événement onchange Erreur :Unable to get property 'controls' of undefined or null reference

function Demande_Type()
{
    if (Xrm.Page.getAttribute("cac_is_demande_mere").getValue())
    {
        Xrm.Page.getControl("parentcaseid").setLabel("new Field");

        Xrm.Page.ui.tabs.get("general").sections.get("ChildCasesGrid").controls.setLabel("new Field");

    /* var ctrlName = Xrm.Page.ui.controls.get();   
        for(var i in ctrlName) {    
             var ctrl = ctrlName[i];    
             var ctrlSection = ctrl.getParent().getName();  
             if (ctrlSection == "ChildCasesGrid") { 
                   ctrl.setLabel("new Field");  
            }   
        }   */


    }
    else 
    {
        Xrm.Page.getControl("parentcaseid").setLabel("Demande Parente");
        Xrm.Page.ui.tabs.get("general").sections.get("ChildCasesGrid").controls.setLabel("Demandes Filles");
    /* var ctrlName = Xrm.Page.ui.controls.get();   
        for(var i in ctrlName) {    
             var ctrl = ctrlName[i];    
             var ctrlSection = ctrl.getParent().getName();  
             if (ctrlSection == "ChildCasesGrid") { 
                   ctrl.setLabel("Demandes Filles");    
            }   
        }*/
    }

}

Based on your code I can suggest to recheck id of a section. Is it really ChildCasesGrid? Could you please provide a screenshot of section settings form?

Based on provided screenshot you use id of a grid and not of a section on which it is put. So solution - find Id of a section and put it to your code.

Since the only .controls you're attempting follows this line

Xrm.Page.ui.tabs.get("general").sections.get("ChildCasesGrid")

then it means that .get("ChildCasesGrid") result is null or undefined.

This means that you don't have any section named ChildCasesGrid inside the tab named general : either one of the names is wrong (watch out, they are case-sensitive).

部分设置表单的屏幕截图

@andrii butenko that's the name of my section

你真的想做Xrm.Page.getControl("ChildCasesGrid").setLabel("new label")来设置子网格的标签

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM