Take Control of Dynamics CRM 2015 by Setting Default Values
CRM allows you to indicate a default value if the field type is an option set. However, there are many business cases that require a default value to be set to other field types. By using Business Rules in CRM 2015, you can accomplish this. The business scenario used in this example is as follows:
The minimum credit limit granted to an Account is $20,000. At the time an account is set up, the user creating the record doesn’t always know what the finance department will approve for the credit limit.
Instead of having users type the minimum value of $20,000 in the ‘Credit Limit’ field each time, we are going to set a Default Value for this field via Business Rules.
- Navigate to the Account Entity and access the ‘Form’
- Select Business Rules and click the New Business Rule button
- Give the Business Rule a descriptive name, set the Condition (in this case we want the credit limit field to default to our company’s minimum value of $20,000 when there is no other limit specified)
- To set the default value, add an action as shown below
- Click Save. Click Activate.
Now, each time an account record does not contain a value in the ‘Credit Limit’ field, CRM will automatically populate it with $20,000.
Happy CRMing
CRM FORM PRESENTATION
We have always known the Retrieve request to be able to retrieve the data of the requested entity based on the id provided. However in CRM 2011, the Retrieve request can read not only the properties of the primary entity but also the referenced entity like in a 1-N or N-N or N-1 relationship. Given that it supports all the three types of relationships it could be an advantage over the LinkEntity feature.For example, if we want to retrieve the active contacts related to an account then, we can design the query as shown in the below code,
using (OrganizationServiceProxy _orgserviceproxy = new OrganizationServiceProxy(new Uri(OrganizationUri), null, Credentials, null))
{
//create the query expression object
QueryExpression query = new QueryExpression();
//Query on reated entity records
query.EntityName = “contact”;
//Retrieve the all attributes of the related record
query.ColumnSet = new ColumnSet(true);
//create the relationship object
Relationship relationship = new Relationship();
//add the condition where you can retrieve only the account related active contacts
query.Criteria = new FilterExpression();
query.Criteria.AddCondition(new ConditionExpression(“statecode”, ConditionOperator.Equal,“Active”));
// name of relationship between account & contact
relationship.SchemaName = “contact_customer_accounts”;
//create relationshipQueryCollection Object
RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection();
//Add the your relation and query to the RelationshipQueryCollection
relatedEntity.Add(relationship, query);
//create the retrieve request object
RetrieveRequest request = new RetrieveRequest();
//add the relatedentities query
request.RelatedEntitiesQuery = relatedEntity;
//set column to and the condition for the account
request.ColumnSet = new ColumnSet(“accountid”);
request.Target = new EntityReference { Id = accountID, LogicalName = “account” };
//execute the request
RetrieveResponse response = (RetrieveResponse)_orgserviceproxy.Execute(request);
// here you can check collection count
if (((DataCollection<Relationship, EntityCollection>)(((RelatedEntityCollection)(response.Entity.RelatedEntities)))).Contains(new Relationship(“contact_customer_accounts”)) &&((DataCollection<Relationship, EntityCollection>)(((RelatedEntityCollection)(response.Entity.RelatedEntities))))[new Relationship(“contact_customer_accounts”)].Entities.Count > 0)
return true;
else
return false;
}
One limitation though, is that it is only available with the Retrieve Request and not the Retrieve Multiple request. Wonder why this has not be added for Retrieve Multiple request as this can be of great help to return all the data required in one request.