Patch Codeset
  • 22 Nov 2024
  • 5 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Patch Codeset

  • Dark
    Light
  • PDF

Article summary

Patch Codeset

/v1/codesets

Maintain Codeset

Example for calling:

http://server/v1/codesets
http://server/v1/codesets?owner=safransa

Request Body = {….} see request fields below

Allowed methods:

[PATCH]

API Controller: codeset

Description:

Update the single codeset with the details provided; all other details remain as is. The codeset must be present, as must the resources which are to be patched. Should the codeset ID be missing, API will attempt to identify the codeset using the name and owner. API will only allow to patch one codeset per call; it will accept to patch 0, 1 or many field types. Some details are not possible to patch. It is possible to add new field types if the given details do not already exist.

Parameters:

NameTypeDescriptionNotes
idintegerCodeset ID
network_idintegerNetwork IDMandatory when "SafranWebApiOwnerVerificationDuringApiCalls" is in use.
ownerstringOwner of the code setRelates to "SafranWebApiOwnerVerificationDuringApiCalls" in "Application Settings".
  • Combining id with network_id is not supported
  • When "SafranWebApiOwnerVerificationDuringApiCalls" is in use, the Codeset retrieved can only be linked to projects owned by the same owner as the Codeset. Should the Codeset be linked to other projects, owned by others, the API will return failure.
  • Id will be used to identify the code set; if missing, the combination of name and owner will be used.
  • It is not possible to patch a field linked to another set.
    • Unless only patching these fields:
      • visible
      • enabled
      • inherit_label
    • In the case of the patch with more than one field, where one field is prevented from being patched, the whole operation will be prevented.

Request Fields:


Syntax of the fields are similar to what is found when using GET /v1/codesets with additional elements, see codesets.

CodeSet

NameTypeDescriptionNotes
RowIdIntegerSequential number used in the communication with the API,which identifies a row in this request that lines up with the response.
idintegerId of the code set
namestringName of the codeset
OwnerstringOwner of the codeset
date_fieldsgeneric_field[]Collection of defined generic_field objects of type dateSee codesets for details
reference_fieldsreference_field[]Collection of defined reference_field objectsSee codesets for details
flag_fieldsgeneric_field[]Collection of defined generic_field objects of type flagSee codesets for details
decimal_fieldsgeneric_field[]Collection of defined generic_field objects of type decimalSee codesets for details
duration_fieldsgeneric_field[]Collection of defined generic_field objects of type durationSee codesets for details
text_fieldsgeneric_field[]Collection of defined generic_field objects of type textSee codesets for details
outline_codesoutline_code[]Collection of defined outline_code objectsSee codesets for details
  • When network_id is provided, and id is null or 0, API will attempt to get the id from the network identified with the given network_id.
  • When "SafranWebApiOwnerVerificationDuringApiCalls" as per "Application Settings" is in use, the Codeset must not exist in other networks.
  • Where id is missing, API will identify the Codeset using name and owner.
  • Reference fields only support simple reference types, not referencing other references.


Field Types:

The details can be altered using this API.

NameTypeDescriptionNotes
reference_fieldsreference_field[]Collection of defined reference_field objects
text_fieldsgeneric_field[]Collection of defined generic_field objects of type text
date_fieldsgeneric_field[]Collection of defined generic_field objects of type date
flag_fieldsgeneric_field[]Collection of defined generic_field objects of type flag
decimal_fieldsgeneric_field[]Collection of defined generic_field objects of type duration
duration_fieldsgeneric_field[]Collection of defined generic_field objects of type decimal
outlinecodeoutlinecode[]Collection of defined outline_code objects


outlinecode

  • The outline codes can be inserted, deleted, moved and updated during the patch action.
  • It is possible to move an outline code from one parent to another within the same field number, provided that the new parent does not already have an outline code with the same short value.
  • Inserting new outlinecode is possible as long as the new short value is not already present for the same parent.
  • Moving or adding an outlinecode to a parent is possible as long as the new level depth does not go beyond the maximum allowed depth.
  • Deleting of a outlinecode is possible as long as it is unused, e.g. not present on an activitiy.
  • See outline_code[] response for more details.

Restriction:

The following details cannot be patched:

NameTypeDescriptionNotes
idintegerUnique CodeSet Id
namestringProject name
ownerstringOwner (Username)
field_nrintegerReference field number.Any field_nr in any field_types cannot be modified.
_shortstringReference value short identifierThe _short value of reference_values for a reference_field cannot be modified.


Response Fields:

NameTypeDescriptionNotes
Config_IdIntegerConfiguration identification
RowIdIntegerLines up with the RowId in Request Fields
ResultStringIndicate the success or failure of the actionS = success, F = failure


Sample Call Patch

json result

[
   {
      "RowId":1,
      "name":"UserfieldSets 002",
      "owner":"SAFRANSA",
      "reference_fields":[
         {
            "reference_values":[
               {
                  "description":"Reference 2.1, short 02.1",
                  "_short":"Short 02.1",
                  "sort_field":2
               },
               {
                  "description":"Reference 2.2, short 02.2",
                  "_short":"Short 02.2",
                  "sort_field":3
               }
            ],
            "field_nr":2,
            "label":"Reference 2**",
            "visible":true,
            "enabled":true
         }
      ]
   }
]

Sample Call Patch (Insert new top node)

json input to the API

[
  {
    "rowId": 1,
    "codeSetAction": "C",
    "updateIfExists": true,
    "id": 100011,
    "name": "Api Test Patch",
    "owner": "SAFRANSA",
    "outline_codes": [
      {
        "field_nr": 3,
        "outline_values": [
          {
            "description": "Top level node",
            "_short": "001",
            "seq": 0
          }
        ]
      }
    ]
  }
]

Sample Call Patch (Add new, alter description for existing and move to a new parent)

json input to the API

[
   {
      "RowId":1,
      "CodeSetAction":"C",
      "UpdateIfExists":true,
      "outline_codes":[
         {
            "oc_levels":3,
            "outline_values":[
               {
                  "description":"New item",
                  "_short":"O1-P0-S1§O1-P1-S2§O1-P2-S5",
                  "seq":0,
                  "level":3,
                  "delimiter_char":"§"
               },
               {
                  "description":"B.Update item",
                  "_short":"O1-P0-S1§O1-P1-S2.NewShort",
                  "seq":2,
                  "parent_seq":1,
                  "delimiter_char":"§"
               },
               {
                  "description":"C.Moved Item to P1",
                  "_short":"O1-P0-S1§O1-P1-S3",
                  "seq":3,
                  "parent_seq":1,
                  "delimiter_char":"§"
               }
            ],
            "field_nr":1,
            "label":"API Test.O1 Master",
            "inherit_label":false,
            "visible":true,
            "enabled":true
         }
      ],
      "id":100011,
      "name":"Api Test Patch",
      "owner":"SAFRANSA"
   }
]

Sample Call Patch (Move one outline code)

json input to the API

[
   {
      "RowId":1,
      "CodeSetAction":"U",
      "UpdateIfExists":false,
      "outline_codes":[
         {
            "oc_levels":3,
            "outline_values":[
               {
                  "description":"Description G, Can be moved",
                  "_short":"O1-P1-S2§O1-P1-S4",
                  "newparent_short":"O1-P0-S1",
                  "seq":0,
                  "delimiter_char":"§"
               }
            ],
            "field_nr":1,
            "label":"API Test.O1 Master",
            "inherit_label":false,
            "visible":true,
            "enabled":true
         }
      ],
      "id":100011,
      "name":"Api Test Patch",
      "owner":"SAFRANSA"
   }
]

Sample Call Patch (Delete using seq and another using short)

json input to the API

[
   {
      "RowId":1,
      "CodeSetAction":"D",
      "UpdateIfExists":false,
      "outline_codes":[
         {
            "oc_levels":3,
            "outline_values":[
               {
                  "_short":"",
                  "seq":1,
               },
               {
                  "_short":"O2-P0-S3",
                  "seq":0,
                  "delimiter_char":"§"
               }
            ],
            "field_nr":2,
            "label":"API Test.O1 Master",
            "inherit_label":false,
            "visible":true,
            "enabled":true
         }
      ],
      "id":100011,
      "name":"Api Test Patch",
      "owner":"SAFRANSA"
   }
]


Was this article helpful?

ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence