how to make the field to be updated only once CRM 2011
-
Tuesday, 8 May, 2012 1:49 PM
Hi, just like static fields, is there a way to make the field to be updated only once. Say for e.g. I have customer business type (that stays the same for ever assuming) as a custom dropdown field.
When I create a new customer, I select the custom dropdown for business type. I choose a type "LLC". Once I save, the field should be read only. ie. user cannot be changing the business type every time he/she open the account form. I can possibly use a javascript, I think but want to ask the forum to see any workarounds or better ideas.
All Replies
-
Tuesday, 8 May, 2012 2:04 PMModerator
Hello,
JavaScript will cover only client side. What about webservices?
As for me you should combine JavaScript to close field for editing at the form and Plugin which will remove possibility of field change just with removing of field from context.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed As Answer by Andrii ButenkoMVP, Moderator Tuesday, 8 May, 2012 3:46 PM
- Marked As Answer by CRM elite Tuesday, 8 May, 2012 10:07 PM
-
Tuesday, 8 May, 2012 2:59 PM
You could use the Xrm.Page.ui.getFormType propery to only make this field editable on create of a new record as a possible solution?
var formType = Xrm.Page.ui.getFormType();
if (formType == 1)
{ //Set field non Read Only }
else
{ //Set field Read Only }
- Edited by Dave_T_7791 Tuesday, 8 May, 2012 2:59 PM
- Proposed As Answer by Dave_T_7791 Tuesday, 8 May, 2012 3:00 PM
-
Tuesday, 8 May, 2012 3:12 PMModerator
Would your script work in case this field would not be populated during creation of the record?You could use the Xrm.Page.ui.getFormType propery to only make this field editable on create of a new record as a possible solution?
var formType = Xrm.Page.ui.getFormType();
if (formType == 1)
{ //Set field non Read Only }
else
{ //Set field Read Only }
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
-
Tuesday, 8 May, 2012 3:17 PMAgreed, it would only allow the field to be edited on creation.
-
Tuesday, 8 May, 2012 3:44 PMI agree Andrii, we should have both Jscript and a plug-in combination
-
Wednesday, 9 May, 2012 9:34 PMHi Andri, on a related note, where would the code be placed to prevent update for this particular field and what is the code to cancel the update for this field but allow update for all other fields as usual. is it pre-operation on update message or pre-image on update message? also, what will the code be like. I could take the pre update reading for that field and pass it as new value.
-
Wednesday, 9 May, 2012 11:50 PM
Instead of writing code for this, use Field-Level Security.
Enable Security on the "Business Type" Field
Create a Security Role "Business Type Role" with these setting:
- Allow Read - Yes
- Allow Update - No
- Allow Create - Yes
Assign the Security Role to the approriate teams.
-
Thursday, 10 May, 2012 1:47 AMI thought about this David, but as Andri pointed out, does it prevent plug-in, webservice or workflows being able to update this field in the database (though its crm online).