Answered by:
inserting multiple rows into crm 4.0 entity

Question
-
I have a table with 4 rows. I need to save these rows as new rows of an existing custom entity. Can anyone provide a code sample (preferable in VB but C# will do)?Wednesday, August 11, 2010 9:09 PM
Answers
-
I tried this but I keep getting prompted for credential when I execute the '.send' method. Where should I specify these credentials in the xml string? On a different note, is there an ASP way to do this? I mean using vb or C#?
- Marked as answer by Barucho1 Thursday, August 12, 2010 7:29 PM
Thursday, August 12, 2010 1:30 PM
All replies
-
Hi.
What kind of rows do you have?
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)Wednesday, August 11, 2010 9:18 PMModerator -
I am not sure what you mean by 'kind of rows'? These are rows in a dynamic entity some which are of type string (nvarchar) and some of boolean (int). I mainly strugle with the syntax and the object model as I am quite new to CRM. So a code example would be very much appreciated.
Wednesday, August 11, 2010 9:55 PM -
For example:
foreach(DynamicEntity de in <your rows here>)
{
DynamicEntity newentity = new DynamicEntity(<your new entity name here>);
if (de.Properties.Contains(<your string field>))
newentity[<your string field>] = de[<your string field here>];
if (de.Properties.Contains(<your boolean field>))
newentity[<your boolean field>] = de[<your boolean field>];
crmservice.Create(newentity);
}
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)- Proposed as answer by VikranthP Thursday, August 12, 2010 6:48 AM
Wednesday, August 11, 2010 10:06 PMModerator -
Hi,
See the below link form MS CRM SDK:
CrmService.Create Method Using JScript
http://msdn.microsoft.com/en-us/library/cc677070.aspx
Hope this helps.
Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM ConsultantThursday, August 12, 2010 4:23 AM -
I tried this but I keep getting prompted for credential when I execute the '.send' method. Where should I specify these credentials in the xml string? On a different note, is there an ASP way to do this? I mean using vb or C#?
- Marked as answer by Barucho1 Thursday, August 12, 2010 7:29 PM
Thursday, August 12, 2010 1:30 PM -
I found my own problem. I apparently created one of the entity attributes using a type of 'UniqueIdentifier' (as it was the databse column type) instead of type 'LoopUp' as it is the CRM form type. The 'Create' method choked but the SoapException message was too generic and therefore useless. Once I changed to correct type, it went through OK.Thursday, August 12, 2010 7:29 PM