简体   繁体   中英

javascript - Make all fields on a form required

I want to be able to loop through all the fields on a form and make them required in a bit of javascript. I have been able to do a similar thing to make them disabled and have retrieved them all with var controls = Xrm.Page.ui.controls.get(); , but I know to set requirement level I need to get the attribute rather than the UI control, how can get get all attributes at once so I can loop through them?

Thanks

Copied almost exactly from the CRM SDK :

function MakeAllAttributesRequired() {
    var attributes = Xrm.Page.data.entity.attributes.get();
    for (var i in attributes) {
        attributes[i].setRequiredLevel("required");
    }
}

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