Solved

Dynamics 2011 JScript - Function to make fields readonly

Posted on 2013-02-07
4
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

733 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