I'm using the following gem to connect to Microsoft Dynamics CRM: https://github.com/TinderBox/dynamics_crm. I was able to connect and add contacts, leads and a few other things just fine. My problem is, I can't figure out how to add an order and order details. Here is the code I am using to create an order detail:
details = Hash.new
details = {
'quantity' => 1000.0,
'productid' => product,
'salesorderid' => DynamicsCRM::XML::EntityReference.new("salesorder", order.id),
'uomid' => DynamicsCRM::XML::EntityReference.new("uom", 'F5AE673D-5D8E-E211-8AD0-78E3B5101E8F'),
'createdon' => Time.now.getutc,
'salesorderstatecode' => 1,
'description' => 'This is just a test order',
}
orderDetail = client.create('salesorderdetail', details)
This runs fine, but when I check in the CRM backend, there is no record under Order Details. I also can't figure out how to send custom fields, I have tried 'new_shirtsize' => 'XL', but I just get an error that the field 'new_shirtsize' doesn't exist for the entity 'salesorderdetail'.
I can only guess, but I had a look in the specs of the gem you mentioned. Looks like the two parameters need to be written like so:
details = {}
details['salesorderid'] = {}
details['salesorderid']['Id'] = order.id
details['salesorderid']['LogicalName'] = 'salesorder'
client.create('orderdetail', details)
Btw, you can make this a little more compact:
client.create('orderdetail', salesorderid:
{'Id' => order.id, 'LogicalName' => 'salesorder'} )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With