Hi all
I am trying to create an account in CRM 2015 using the OrganizationService from BizTalk. It almost works - I have issues getting values into fields that are of the "Money"-type. In order to test, I have created a small .NET application to simulate creating the XML BizTalk will be creating and in this small .NET application I cannot get values into Money-fields either.
My sample code is as this:
void CreateAccount()
{
OrganizationServiceClient client = new OrganizationServiceClient();
client.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Entity entity = new Entity() { LogicalName = "account" };
AttributeCollection contactAttCollection = new AttributeCollection();
contactAttCollection.Add(new KeyValuePair<string, object>("accountnumber", "98269828"));
contactAttCollection.Add(new KeyValuePair<string, object>("creditlimit", 1000.00));
contactAttCollection.Add(new KeyValuePair<string, object>("name", "Jan Eliasen Dummy Corp"));
entity.Attributes = contactAttCollection;
Guid g = client.Create(entity);
}
I do not get any exceptions, but the value for "creditlimit" is null in the AccountBase-table in the database, whereas other fields, such as name, telephone number and so on are added just fine. I have researched and found that I probably need to set a currency for the amount in order to let CRM know how to understand the amount. I have tried setting it in two ways:
contactAttCollection.Add(new KeyValuePair<string, object>("transactioncurrencyidname", "DKK"));
contactAttCollection.Add(new KeyValuePair<string, object>("transactioncurrencyid", new Guid("A9CFECC5-0970-E511-80CB-005056814687")));
where the guid-value is the one I found for the DKK-currency in the "TransactionCurrency"-table in the CRM-database.
Neither seem to work, as the value for TransactionCurrencyId stays null in the created row in the AccountBase-table.
I cannot use the SDK-classes and the Money-class because this is not supported by BizTalk - I need to create the XML for the OrganizationService my self.
Does anyone know how I can specify the currency? Or get Money-fields to work in another way?
Thanks!