1

I am using Sharepoint 2010 Data Services to create items on a table.

My table has a column called Priority which has High, Medium, and Low items in it.

When I try to create an item in this table via listdata.svc service in c#, Priority field value is not submitted, but the ticket is created on the server. My code is below:

TicketItem obj = new TicketItem();
obj.Title = "test";
IMGCustomerPortalDataContext dataContext = new IMGCustomerPortalDataContext(new Uri("http://server/site/_vti_bin/listdata.svc", UriKind.Absolute));
dataContext.Credentials = System.Net.CredentialCache.DefaultCredentials;
///Tried both of them
//obj.Priority = dataContext.TicketPriority.Where(k => k.Value == "Low").First();
obj.Priority = TicketPriorityValue.CreateTicketPriorityValue("Low");
dataContext.AddToTicket(obj);
dataContext.SaveChanges();

Is there anything I am missing?

1 Answer 1

2

after a detailed research I have figured this out.

the link between objects needs to be set explicitly

So, the line below sorted it...

dataContext.SetLink(obj, "Priority", pri);

or

ticket.PriorityValue = "Low";

did the same job...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.