2

I can successfully create entries in contour programmatically(C#) but I am not able to update the created record using the record ID. After digging my head around can’t find a reason why the following code doesn’t work. It’s very basic and all That I am trying to do is get the record that exist in the contour.

 RecordStorage recordStorage = new RecordStorage();
 Record r = recordStorage.GetRecord(new Guid("15d654cb-a7c6-4f1f-8b55-0ecd7d19b0e3"));
 recordStorage.Dispose();

Just to start with the update process, I am trying to get the record object using it’s id but can’t proceed further as it throws a weird error “An item with the same key has already been added.” I can’t understand while it’s trying to set the value when I call the “storage.GetRecord()”. Following is the stack trace

**An item with the same key has already been added.**
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Umbraco.Forms.Data.Storage.RecordFieldStorage.GetAllRecordFields(Record record)
   at Umbraco.Forms.Data.Storage.RecordStorage.GetRecord(Object id)
   at MauriceBlackburn.Service.ContourFormService.InsertRecord(ContourFormFields unionContourForm)

Any thoughts, have I missed something, I have been digging all day around and still not able to figure this out. Thanks in advance.

Much Appreciated.

Aneesh
  • 187
  • 1
  • 3
  • 18

2 Answers2

0

First off, try deleting the workflow and re-adding it.

You could also create two simple workflows, one that will write the record and a second to manipulate it (using the id when written).

madebybear
  • 359
  • 4
  • 8
  • Hi @madebybear, thanks for your reply. Sorry I am bit confused, how can I edit a record using workflows. I am doing everything programmatically i.e inserting the record and updating it. The form fields actually comes from a mobile App. Is there any other way to achieve this ? – Aneesh May 14 '13 at 23:09
0

Make sure that there are no records with the same ID in database. You might have inserted them before.

Dzianis Yafimau
  • 2,034
  • 1
  • 27
  • 38