if(opportunity.customerid.type == EntityName.account.ToString())
{
account account = (account)service.Retrieve(EntityName.account.ToString(), opportunity.customerid.Value, new AllColumns());
if(account.revenue != null)
{
opportunity.new_accountvalue = new CrmMoney();
opportunity.new_accountvalue.Value = account.revenue.Value;
}
}
else if(opportunity.customerid.type == EntityName.contact.ToString())
{
contact contact = (contact)service.Retrieve(EntityName.contact.ToString(), opportunity.customerid.Value, new AllColumns());
if(contact.creditlimit != null)
{
opportunity.new_accountvalue = new CrmMoney();
opportunity.new_accountvalue.Value = contact.creditlimit.Value;
}
}
service.Update(opportunity);
No comments:
Post a Comment