Solved

Dynamics 2011 JScript - Function to make fields readonly

Posted on 2013-02-07
4
287 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

791 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