Hi,
i have
entity A with field a(currency)
entity B with field b(decimal)
entity c with field c(currency)
i want to calculate percentage in c= a*b/100
store value in field C
can help me
*This post is locked for comments
Hi,
i have
entity A with field a(currency)
entity B with field b(decimal)
entity c with field c(currency)
i want to calculate percentage in c= a*b/100
store value in field C
can help me
*This post is locked for comments
Hi Chaitu can you please give full solution i am facing the same issue
Hi chaitu, can you please provide full solution i am facing same issue.
Hi Michael,
You are 100% correct, I forgot that was available... apologies!
You can actually use other related entity fields in calculated fields by identifying the lookup field first. In the example below, I have created a sample calculated text field on the case entity, and show how to retrieve field values on the related contact record:
Using calculated fields is likely the preferred method of doing this.
Hi Barry..
Thank you so much for the response.Its working.
Hi Chaitu,
The first thing I want to point is that its hard to store a value in the same field you are retrieving a value from. I would definitely suggest created another field alongside field C to ensure no looping effects are experienced with whichever solution you undertake. (i.e. trigger an OnChange event on field C, which will trigger again after the calculation is triggered, and again and again etc.)
That being said, as you've stated, calculated fields only work on off the data that is stored on the entity itself, it will not be able to pull data from associated records. The best solution is the one suggested by Ramzi Ghribi through a plugin or Javascript.
It is however possible to run the calculation from a single workflow that has the following conditions:
Then add a business rule in place to conduct the calculations (Set its scope to entity to ensure its done even in the background). The business rule must conduct the following:
1. update the duplicate field C's value with the calculation; FieldA*FieldB
2. set the current field C's value to the duplicate field C's value/100 and you should be good to go.
That is a solution that does not require any dev and can be updated by either the customer or yourself with little disruption to the current records.
If you are able to create a plugin, then use the following fetch structure seen on my blog (www.ec.co.za/.../dynamics-crm-plugins-the-basics) to build the fetch for Entity A and Entity B and conduct the calculation:
if (EntityAEntity != null)
{
//EntityA
String fetchEntityA = String.Format(@"", EntityARef.Id.ToString());
EntityCollection EntityAresults = service.RetrieveMultiple(new FetchExpression(fetchEntityA));
if (EntityAresults.Entities.Count == 1)
{
entityC["fieldaschema"] = new Money(FieldARef);
service.Update(entityC);
}
}
if (EntityB != null)
{
//EntityB
String fetchEntityB = String.Format(@"", EntityBRef.Id.ToString());
EntityCollection EntityBresults = service.RetrieveMultiple(new FetchExpression(fetchEntityB));
if (EntityBresults.Entities.Count == 1)
{
entityC["fieldbschema"] = new Money(FieldARef);
service.Update(entityC);
}
}
Decimal FieldA = EntityCRef.Attributes.Contains("fieldaschema") ? ((Money)EntityCRef["fieldaschema"]).Value : 0;
Decimal FieldB = EntityCRef.Attributes.Contains("fieldbschema") ? ((Decimal)EntityCRef["fieldbschema"]).Value : 0;
decimal calculation = (FieldA * FieldB) / 100;
entityC["fieldC"] = new Money(calculation);
Obviously it's hard to determine any of the values outside of the initial requirement.
Hope this helps.
Hi Sandeep ,Thank you for reply,
i am not able call the different entity field values in calculated fields
Hi,
You can use calculate field www.encorebusiness.com/.../dynamics-crm-calculated-fields. If it does not helps. You can use CRM workflow/business rule which run on create or update of entities and calculate value based on conditions.
I would like to know your requirement in detail and relationship between entities.
Thank you..Ramzi
can u help me how to query the two different field values from two entitys
Hi,
You need to create a plugin or call the web Api using Javascript .
Not possible with a workflow .
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156