• Home
  • Microsoft Dynamics CRM
  • Office 365
  • Services
  • Contact Us
  • Blog
NetriSoft
Call Today:  (810) 299-2259

Setting the Business Requirement status of an attribute in CRM 2011

10/21/2012

0 Comments

 
Sometimes when building forms you are going to run into a situation where you may need to set or remove the business requirement of an attribute on a form.  This comes in handy when you are using multiple forms for different types of users.  For instance, a salesmen may only need the ability to add basic customer information on one screen, but on another screen you may have information not visible to the salesman, such as financial information.  This financial information may include fields that MUST be entered by the finance folks.  So, what you do in these situations is remove the requirement at the attribute level and add the following code to a page load event on your page:
 1   var myAttribute = Xrm.Page.getAttribute("new_MyAttribute");
2
3 //Check to make sure there is an attribute by that name
4 if(myAttribute != null)
5 {
6 myAttribute.setRequiredLevel('required');
7 }
You could also remove the required level by:
 1   var myAttribute = Xrm.Page.getAttribute("new_MyAttribute");
2
3 //Check to make sure there is an attribute by that name
4 if(myAttribute != null)
5 {
6 myAttribute.setRequiredLevel('none');
7 }
Or even set it as Business Recommended:
 1   var myAttribute = Xrm.Page.getAttribute("new_MyAttribute");
2
3 //Check to make sure there is an attribute by that name
4 if(myAttribute != null)
5 {
6 myAttribute.setRequiredLevel('recommended');
7 }
Hope this quick snippet can help!
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Author

    Brian Greig

    Archives

    August 2013
    December 2012
    October 2012
    September 2012
    June 2012
    April 2011
    January 2011

    Categories

    All
    CRM
    CRM 4
    CRM For Outlook
    CRM Online
    CRM On-Premise
    Expanding CRM UI
    JavaScript

    RSS Feed

NetriSoft, LLC
8702 N. Second Street
Brighton, MI  48116
Phone:  (810) 299-2259
Fax:  (810) 299-2766
Email: [email protected]
Picture
©2015 Netrisoft, LLC. All rights reserved.  Please read our Privacy Policy and Terms of Use
Site design by
Second Son Solutions