Update ticket extra field via NetServer

Hi all,

How I can set extra field via NetServer? I'm trying find and update fields using following code: 

TicketRow.CustomSearch query = new TicketRow.CustomSearch();
query.Restriction = query.TableInfo.x_extra_field.Equal("value");  // doesn't work 
TicketRow ticket = TicketRow.GetFromCustomSearch(query);
ticket.x_extra_field = "new value"; // doesn't work 
ticket.Save();

TIA

RE: Update ticket extra field via NetServer

Old post but I was looking the same thing. So is this possible nowadays?

Av: Mikko Tillikainen 25. nov 2019

RE: Update ticket extra field via NetServer

Hi MIkko,

Yes, you are now able to update extra fields in REST and WCF classes, and archive providers. See christians post for examples.

Best regards.

Av: Tony Yates 25. nov 2019

RE: Update ticket extra field via NetServer

You can't do this

query.Restriction = query.TableInfo.x_extra_field.Equal("value");  // doesn't work

ticket.x_extra_field = "new value"; // doesn't work

because NetServer cannot know the names of the extra fields at compile time.

You need to look up the fields indirectly - by name:

TicketRow.CustomSearch query = new TicketRow.CustomSearch();
var X_extra_field = query.TableInfo.FindField("x_extra_field"); // Look up by name
query.Restriction = X_extra_field.Equal(S.Parameter("value"));  // does work
TicketRow ticket = TicketRow.GetFromCustomSearch(query);
ticket["x_extra_field"] = "new value"; // does work - look up by name
ticket.Save();
Av: Christian Mogensen 25. nov 2019