最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dynamics crm 2011 - javascript - Make all fields on a form required - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question asked Nov 28, 2012 at 11:49 jimminybobjimminybob 1,4422 gold badges28 silver badges62 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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");
    }
}
发布评论

评论列表(0)

  1. 暂无评论