?
Solved

Dynamics 2011 JScript - Function to make fields readonly

Posted on 2013-02-07
4
Medium Priority
?
293 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
2 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 1000 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 30

Assisted Solution

by:Feridun Kadir
Feridun Kadir earned 1000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

839 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