1

i dont know how to update the composite fields like fullname,address in ms crm using c#

if (dataRow[i].ToString() == string.Empty)
{
    selectedEntity["fullname"] = null;
}
else
{
    selectedEntity["fullname"] = "ms crm";
    //error
}

//it is not getting fullname in entity
josliber
  • 43,891
  • 12
  • 98
  • 133
Ajit004
  • 65
  • 7
  • If you have additional questions, please use the "Ask Question" button instead of editing your current post to ask something else. – josliber Jan 12 '16 at 14:26

1 Answers1

4

You cannot set the values of composite fields directly. You will need to set the underlying fields instead (e.g. setting firstname and lastname will change the value of fullname in a Contact).

The following quote from MSDN explains this (though in the context of scripting on forms):

Although you can read the value of the composite value using getValue, you can’t use setValue to change the value of the composite attribute directly; you must set one or more of the attributes referenced by the composite attribute.

Henrik H
  • 5,747
  • 1
  • 21
  • 33
  • for this we have to hard code to recognise and handle composite fields . .is there any dynamic way to do this – Ajit004 Jan 07 '16 at 04:44
  • I am not quite following you. In the above example you already hard code the string "fullname". Feel free to make a new question where you elaborate on your specific scenario. – Henrik H Jan 07 '16 at 07:25
  • thnks for reply Henrik . .i just updated the question . . plz go through it. – Ajit004 Jan 07 '16 at 08:56
  • 1
    I Think you need to explain what it is you're trying to do. For example, in the above code you're mapping datarow[i] to "fullname" of "selectedentity". How do you indata look and why does it have a field with the name "fullname". There really aren't that many Composite fields in CRM, fullname on Contact, systemuser and lead of the top of my head. You can bypass that by not having a fullname in the indata. I'd say that you have worse challenges in optionsets for example. – Rickard N Jan 12 '16 at 07:10