Solved

Dynamics 2011 JScript - Function to make fields readonly

Posted on 2013-02-07
4
282 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
Comment Utility
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
feridun earned 250 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now