Konrad Viltersten
Konrad Viltersten

Reputation: 39148

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?

Upvotes: 1

Views: 768

Answers (2)

JayRizzo
JayRizzo

Reputation: 3616

You can also try,

// Requirement level

crmForm.all.new_bamsegurka.setAttribute("req", 2);
crmForm.all.new_bamsegurka_c.className = "req";
crmForm.all.new_bamsegurka_c.innerHTML = crmForm.all.new_bamsegurka_c.innerText + "<img  alt='Required' src='/_imgs/frm_required.gif'/>";

crmForm.all.new_bamsegurka.setAttribute("req", 1);
crmForm.all.new_bamsegurka_c.className = "n";
crmForm.all.new_bamsegurka_c.innerHTML = crmForm.all.new_bamsegurka_c.innerText + "<img  alt='Recommended' src='/_imgs/frm_recommended.gif'/>";

crmForm.all.new_bamsegurka.setAttribute("req", 0);
crmForm.all.new_bamsegurka_c.className = "n";
crmForm.all.new_bamsegurka_c.innerHTML = crmForm.all.new_bamsegurka_c.innerText;

This should be a better fit.
Be sure to change only the "new_bamsegurka" for each to match your field name.

Upvotes: 1

Guido Preite
Guido Preite

Reputation: 15128

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.

Upvotes: 2

Related Questions