Asked by:
CRM 4.0 Plugin for Account Entity

Question
-
Hi professionals! I want to create account from CRM 4.0 form, i want to set "phone number field 123456" by default through plugin?
How can i achieve this functionality?
Wednesday, September 18, 2013 1:21 PM
All replies
-
You can do this using a a Pre-Create plugin on Account. You can check if the phone number is entered by the user; if not, then you could set the default value.
Please refer http://msdn.microsoft.com/en-us/library/bb955365.aspx
If my response helps you in finding your answer then please click 'Mark as Answer' and 'Vote as Helpful'
Wednesday, September 18, 2013 2:06 PM -
Hi,
In addition to plugin you can also write a simple JS code if you always want to set phone number to default and call in onload of the form
if(Xrm.Page.ui.getFormType()==1)
{
Xrm.Page.getControl(
"fieldname"
).setDisabled(
123456);
}
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, September 18, 2013 4:34 PMModerator -
Hi,
I assume you want this for CRM 4.0.
You can use the below JavaScript. You can call your JavaScript function On load of the form while creating new record.
if(crmForm.FormType == 1)
{
crmForm.all.description.DataValue =7890;
}Thanks!
Wednesday, September 18, 2013 5:57 PM -
No dear i want to set this field from plugin this is requirement for some reason?
Thursday, September 19, 2013 5:47 AM -
I have checked out this but how can i get the current entity value in crm 4.0?
Thursday, September 19, 2013 5:49 AM -
Hi Adeel,
What do you mean by Current Entity value?
You can read the target property as given below.
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
{
entity = (DynamicEntity)context.InputParameters.Properties["Target"];}
You will get the fields those were populated while creating record in the entity (Target).
You can read the fields value from entity object .
- Edited by Kalim Khan Thursday, September 19, 2013 5:15 PM
Thursday, September 19, 2013 5:15 PM