UpdateObject not changing Custom Fields in Version objects
Sorry if this is duplicate, didn't find a matching existing issue.
Using Redmine.Net.Api version 4.3.0 and Redmine version 4.2.4.stable
I have custom fields for versions. Their values are correctly read through Redmine API. But I can neither update nor replace their values.
RedmineManager.UpdateObject( string, Version? ) executes correctly, it just doesn't apply the changes to those custom fields.
Hi, The only fields that you can update for a version are the following: Name, Status, Sharing, DueDate and Description.
For updating version's custom fields you have to run the following command:
RedmineManager.UpdateObject<IssueCustomField>(<IssueCustomFieldId>, <IssueCustomFieldEntity>);
for every custom field that has been changed.
Hmm, are you sure? I try the following code and it fails with an Unauthorized Exception from WebClient:
foreach (IssueCustomField? customField in version.CustomFields)
{
if (customField.Id == releasedVersionId)
{
// If list null, create
customField.Values ??= new List<CustomFieldValue>();
// If list not empty, clear
customField.Values.Clear();
// Add new value
customField.Values.Add(new CustomFieldValue(versionName));
// Update object
manager.UpdateObject<IssueCustomField>(customField.Id.ToString(), customField);
}
}