Solved

Dynamics 2011 JScript - Function to make fields readonly

Posted on 2013-02-07
4
284 Views
Last Modified: 2013-11-27
I am trying to determine if there is a way for me to use one field on my form and based upon it's value make a load more fields readonly or active (depending upon the value in the field)?

I know I can write a whole host of individual functions to make this happen but does anyone know of a way that I could have a function (or 2 perhaps) that would allow me to pass a fieldname, determine it's value and based upon this go through another list of parameter passed fields to make them readonly or active (again depending upon the value).

Hope that makes sense.

Any advice greatly appreciated
0
Comment
Question by:Steven O'Neill
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 38863868
function lockFields(fieldname, determine_it_s_value, another_list_of_parameter) {

if( document.getElementsByName("fieldname")[0].value == determine_it_s_value ) {
     // another_list_of_parameter is an array of fields name : [ "name1", "name2", "name3" ]
     for(var i=0;i<another_list_of_parameter.length;i++) {
          document.getElementsByName(another_list_of_parameter[ i ]).readOnly = "readOnly";
     }
}

}
0
 
LVL 29

Assisted Solution

by:Feridun Kadir
Feridun Kadir earned 250 total points
ID: 38864730
Have a look at the CRM 2011 SDK, http://www.microsoft.com/en-gb/download/details.aspx?id=24004, in the Client Side Programming Reference, in particular the Xrm.Page.ui.Control methods topic.

You can write a Jscript function that will receive a CRM field as a parameter and a list of parameters along the lines proposed by leakim971 but for CRM modifying document elements directly is not supported.

You must reference each field (control) using Xrm.Page as described in the SDK.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now