Search code examples
javascriptdynamics-crm-4

How to set the requirement level for a field


Following this blog I'm trying to set the requirement level to business recommended but I fail miserably. I only get the the red star indicating that the field is business required.

crmForm.SetFieldReqLevel("new_bamsegurka", 0);
crmForm.SetFieldReqLevel("new_bamsegurka", 1);    
crmForm.SetFieldReqLevel("new_bamsegurka", 2);

The first line turns the red star off. The other two, turn it on. There's no seemingly way to set the blue cross, though... What do I miss?


Solution

  • As you already found the right code to set a field business recommended (blue cross) is with parameter 2

    crmForm.SetFieldReqLevel("new_bamsegurka", 2);
    

    It can be an issue with the rollup of your CRM 4.0 environment. I saw a similar bug (a required didn't set properly by javascript) with a CRM 2011 with an early rollup.

    For the corresponding operation of getting requirement level of a field, there's no supported method. One needs to hack around as follows.

    crmForm.all["new_bamsegurka_c"].className.indexOf("Rec") >= 0
    

    Note the _c part as well as Rec, as opposed to Req.