Create, Update or Delete CodeSets
  • 18 Jul 2024
  • 5 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Create, Update or Delete CodeSets

  • Dark
    Light
  • PDF

Article summary

Create, Update or Delete CodeSets

/v1/codesets

Create new code set, update or delete existing code set.

Safran Project ILAP Gateway

This API is only available in the Safran Project ILAP Gateway product.

Example for calling:

http://server/v1/codesets
http://server/v1/codesets?network_id=92
http://server/v1/codesets?network_id=92&owner=safransa

Allowed Methods:

[POST]
API Controller: CodeSet

Description:

Create new codeset is done in one single Web Service call with indicator to specify Create or Update or Delete.

API allows to add the following details:

  1. Date fields
  2. Referense fields
  3. Number fields
  4. Decimal fields
  5. Duration fields
  6. Text fields
  7. Outline codes


    Notice that the API allows creation of Outline codes with "Create new OutlineCodes". That is still present, however this "Create codesets" will also allow creation of outline codes.

Update action

Delete action

  • Delete of a codeset is prevented if there are dependencies to the codeset.

Parameters:

NameTypeDescriptionNotes
network_idintegerNetwork IDMandatory when "SafranWebApiOwnerVerificationDuringApiCalls" is in use, for delete and update actions.
ownerstringOwner of the code setRelates to the "SafranWebApiOwnerVerificationDuringApiCalls" in the "Application Settings"



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.
CodeSetActioncharAction to be performed using these data, valid chartacters 'c', 'u' and 'd'c = Create
u = Update
d = Delete
UpdateIfExistsbooleanIf action is create and codeset already is present, setting this to true will invoke update action instead.
idintegerId of the code set Set to null when using create action
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
number_fieldsgeneric_field[]Collection of defined generic_field objects of type numberThese are obsolete
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 in the Parameters, only one CodeSet can be sent to the API.
  • When network_id is provided and id is null or 0, API will attempt getting the id from the network identified with the given network_id.
  • When "SafranWebApiOwnerVerificationDuringApiCalls" as per "Application Settings" is in use, the CodeSet being deleted or updated (including create with UpdateIfExists) must not exist in other networks.
  • For update and delete actions where id is missing, API will identify the CodeSet using name and Owner.
  • Reference_fields only support simple reference type, not referencing to other references.

Note for outline_codes


For "outline codes" "seq" and "parent_seq" are not used. When specifying the short attribute, it needs to host the full path of the item.

"outline_values": [
  {
    "description": "Description 1.1.1",
    "_short": "Level 1.Level 2.Level 3",
    "sort_field": 3,
    "delimiter_char": "."
  },
  {
    "description": "Description 1.1",
    "_short": "Level 1.Level 2",
    "sort_field": 2,
    "delimiter_char": "."
  },
  {
    "description": "Description 1",
    "_short": "Level 1",
    "sort_field": 1,
    "delimiter_char": "."
  }
]



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 Create sample
[
   {
      "RowId":1,
      "CodeSetAction":"C",
      "UpdateIfExists":false,
      "id":null,
      "name":"CodeSet API 11",
      "Owner":"SAFRANSA",
      "date_fields":[
         {
            "field_nr":1,
            "label":"Date 1",
            "visible":true,
            "enabled":true
         },
         {
            "field_nr":2,
            "label":"Date 2",
            "visible":true,
            "enabled":true
         }
      ],
      "reference_fields":[
         {
            "reference_values":[
               {
                  "description":"Ref 01",
                  "_short":"001"
               }
            ],
            "field_nr":1,
            "label":"Reference 1 (Local Label)",
            "visible":true,
            "enabled":true
         }
      ],
      "flag_fields":[
         {
            "field_nr":1,
            "label":"Flag 1",
            "visible":true,
            "enabled":true
         },
         {
            "field_nr":2,
            "label":"Flag 2",
            "visible":true,
            "enabled":true
         }
      ],
      "decimal_fields":[
         {
            "field_nr":1,
            "label":"Decimal 1",
            "visible":true,
            "enabled":true
         },
         {
            "field_nr":2,
            "label":"Decimal 2",
            "visible":true,
            "enabled":true
         },
         {
            "field_nr":3,
            "label":"Decimal 3",
            "visible":true,
            "enabled":true
         }
      ],
      "duration_fields":[
         {
            "field_nr":1,
            "label":"Duration 1",
            "visible":true,
            "enabled":true
         },
         {
            "field_nr":2,
            "label":"Duration 2",
            "visible":true,
            "enabled":true
         },
         {
            "field_nr":3,
            "label":"Duration 3",
            "visible":true,
            "enabled":true
         }
      ],
      "text_fields":[
         {
            "field_nr":1,
            "label":"Text 1",
            "visible":true,
            "enabled":true
         }
      ],
      "outline_codes":[
         {
            "field_nr":1,
            "label":"Outline Code 1",
            "visible":true,
            "enabled":true,
            "oc_levels":4,
            "levels":[
               {
                  "level_nr":1,
                  "label":"Level 1",
                  "char_type":"3",
                  "field_length":"0",
                  "divider_char":"."
               },
               {
                  "level_nr":2,
                  "label":"Level 2",
                  "char_type":"3",
                  "field_length":"0",
                  "divider_char":"."
               },
               {
                  "level_nr":3,
                  "label":"Level 3",
                  "char_type":"3",
                  "field_length":"0",
                  "divider_char":"."
               },
               {
                  "level_nr":4,
                  "label":"Level 4",
                  "char_type":"3",
                  "field_length":"0",
                  "divider_char":"."
               }
            ],
            "outline_values":[
               {
                  "description":"Description 1.1.1",
                  "_short":"Level 1.Level 2.Level 3",
                  "sort_field":3,
                  "seq":1,
                  "parent_seq":2,
                  "delimiter_char":"."
               },
               {
                  "description":"Description 1.1",
                  "_short":"Level 1.Level 2",
                  "sort_field":2,
                  "seq":2,
                  "parent_seq":3,
                  "delimiter_char":"."
               },
               {
                  "description":"Descritpion 1",
                  "_short":"Level 1",
                  "sort_field":1,
                  "seq":3,
                  "parent_seq":0,
                  "delimiter_char":"."
               }
            ]
         }
      ]
   }
]


Sample Call Update sample
[
  {
    "RowId":1,
    "CodeSetAction":"U",
    "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
        }
      ],
     "outline_codes": [
       {
         "oc_levels": 2,
         "field_nr": 1,
         "label": "Outline Code 1",
         "visible": true,
         "enabled": true,
         "levels": [
           {
             "level_nr": 1,
             "label": "Level 1",
             "char_type": "3",
             "field_length": "0",
             "divider_char": "."
           },
           {
             "level_nr": 2,
             "label": "Level 2",
             "char_type": "3",
             "field_length": "0",
             "divider_char": "."
           }
         ],
         "outline_values": [
           {
             "description": "Node 1 - Description",
             "_short": "Node 1",
             "sort_field": 1,
             "level": 1,
             "delimiter_char": "§"
           },
           {
             "description": "Node 1.1 - Description",
             "_short": "Node 1§Node 1.1",
             "sort_field": 2,
             "level": 2,
             "delimiter_char": "§"
           },
           {
             "description": "Node 1.2 - Description",
             "_short": "Node 1§Node 1.2",
             "sort_field": 3,
             "level": 2,
             "delimiter_char": "§"
           }
         ]
       }
     ]
   }
]


Sample Call Delete sample
[
  {
    "RowId":1,
    "CodeSetAction":"D",
    "name": "UserfieldSets 002",
    "owner": "SAFRANSA"
  }
]


Was this article helpful?

ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence