Change requirement level at runtime

I've made quite some posts around how to dynamically modify the form by using JavaScript. One thing I haven't posted around yet, but what I do use quite often, is to modify the requirement level of attributes on the form at runtime. Based on a selection in the system, another field could become required. Also if the selection changes again, then the field should not be required anymore. Here is the code for making a field optional, recommended or required:


// Set field to not required
crmForm.SetFieldReqLevel("fieldname", 0);

// Set field to business required
crmForm.SetFieldReqLevel("fieldname", 1);

// Set field to business recommended
crmForm.SetFieldReqLevel("fieldname", 2);


Update: new code placed based on the comment by Peter. Before the update I had this piece of code:


// set the field required (i.e. show error message when field is not filled in)
crmForm.all.fieldname.req = 2;

// modify the label to be red
crmForm.all.fieldname_c.className = 'req';



Expert on Avanade.com

Avanade has create a profile for me on their public website in the experts section. It's quite a honer to be listed within the same list as Matt Joe, Dennis Mulder and Matt Parks. http://www.avanade.com/people/expert_detail.aspx?expertid=98

If you want to become an Avanade expert as well, feel free to contact me (ronaldl at avanade dot com) and I'll make sure that you get in contact with the correct HR person.



Reawarded MVP

Hi Guys,

As a reward for community work last year, Microsoft has reawarded me the Microsoft CRM MVP!

My community work includes:
- Around 1000 newsgroup and forum posts.
- Around 75 blog posts, of which 35 self written articles. The blog had more than 75k visitors.
- Writing the article "Many to many relationships" for the CRM Team blog and the article "The power of choice" for CRN.
- Working as 'Ask the Expert' at the Convergence both in San Diego and Munich.
- Other tasks like participating in the Titan beta, answering hunderds of direct mails and delivering product team feedback.

This year again I plan on continuing my community work. Also, if you see a question somewhere and you have the answer? Please take the time to answer the question and help this person out. We all started with questions, including myself, and helping people with your knowledge is one of the greatest things you can do. And one day you might even get awarded an MVP award as well :)

See you in the community!