Skip to main content
Planview Customer Success Center

Updating a single configurable field via API

There are 3 configurable fields for the resource entity: Department, Id and Level. When a resource is created via API it is possible to set the values of these configurable fields. However, when updating only one configurable field (i.e. Level) by the APIResource.Update() method, it sets the value of "Level" but then "Department" and "Id" become empty.

How can we update only one field while the values of the remaining fields are preserved?



Resolution:
ApiResource.GetUDF() retrieves the existing values in a format that can directly be passed on to ApiResource.SaveUDF(). The VB code sample below modifies the value of the “Text3” field before saving. This method will help preserve the values in other fields while modifying only the Text3 field value.

Dim Result As Integer = myResource.GetById("...")

Dim oXML As String = myResource.GetUDF("...", "...", "...", CPUDFReturnType.WithStructure)

oXML = oXML.Substring(0, oXML.IndexOf("value=""", oXML.IndexOf("<cptext name=""Text3"""))) + "value=""5""" + oXML.Substring(oXML.IndexOf(" mandatory=", oXML.IndexOf("<cptext name=""Text3""")))

Result = myResource.SaveUDF(oXML, CPMetadataCheck.BypassAll)