hi can anyone tell me how to Retrieve the currency field value from contact (ie) lookup field in account entity and must show the contact currency field value should update while saving in account entity currency field save using plugins .
hi can anyone tell me how to Retrieve the currency field value from contact (ie) lookup field in account entity and must show the contact currency field value should update while saving in account entity currency field save using plugins .
I am stuck in it i retrieved the account and contact after that i need to retrieve attribute Money from contact and update in Account money Field . here is my plugin code
namespace Moneyretrieveing
{
public class Class1 : IPlugin
{
private object entity;
private object targetEntity;
public object guidAccountId { get; private set; }
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
QueryExpression queryAccounts = new QueryExpression("account");
queryAccounts.ColumnSet = new ColumnSet(true);
EntityCollection Accounts = service.RetrieveMultiple(queryAccounts);
QueryExpression queryAccounts1 = new QueryExpression("contact");
queryAccounts1.ColumnSet = new ColumnSet(true);
queryAccounts1.Criteria.AddCondition("parentcustomerid", ConditionOperator.Equal, new Guid("7C23E73A-2A4E-EA11-A812-000D3AF26E41"));
EntityCollection contacts = service.RetrieveMultiple(queryAccounts);
queryAccounts.ColumnSet = new ColumnSet("primarycontactid");
EntityCollection retrieved = service.RetrieveMultiple(queryAccounts1);
if (queryAccounts1.Attributes.Contains("new_money"))
{
Money money = (Money)((contacts.Attributes["new_money"]));
}
for (int i = 0; i < retrieved.; i++)
{
}
}
}
}
You need to write a java-script code
Code will try to get associated currency value which is set on contact record and set the value in account entity form.
Refer following
https://vjcity.blogspot.com/2019/07/how-to-get-and-set-value-for-different.html
https://vjcity.blogspot.com/2019/08/guidelines-to-write-good-javascript.html
If you change the currency value on Account entity, then you can update the currency value on contact entity from java-script.
You should go for Plugin if these operations are being done to CRM from external end.
André Arnaud de Cal...
292,494
Super User 2025 Season 1
Martin Dráb
231,305
Most Valuable Professional
nmaenpaa
101,156