CodeSets

Prev Next

Codeset Configuration

/v1/codesets/{id}

Codeset Configuration

Example for calling:

http://server/v1/codesets/9 - retrieves codeset related to network with network Id = 9

http://server/v1/codesets?id=1 - retrieves codeset having Id = 1

http://server/v1/codesets?network_id=9 - retrieves codeset related to network with network id = 9

http://server/v1/codesets?network_id=9&meta_field_select=DLF - retrieves codeset related to network with network id = 9 limited to date, flag and text fields

http://server/v1/codesets?network_id=9&meta_field_select=D,L,F - retrieves codeset related to network with network id = 9 limited to date, flag and text fields

http://server/v1/codesets?network_id=9&meta_field_select=R1,R2,D - retrieves codeset related to network with network id = 9 limited to R field 1 and 2 and all date fields

http://server/v1/codesets - retrieves all codesets

Allowed Methods:

[GET]
API Controller: Codeset

Description:

Retrieves the configuration detail for specified codeset or all codesets if no ID is specified. Only defined userfields are included.

Codeset and master codeset

A definition of a "codeset" could be connected to another "codeset", here referred to as a "master codeset". When requesting details for a "code set" connected to a "master codeset", the "reference value" will be retrieved from the "master codeset". The "reference fields" values will be retrieved from the "codeset". When a "codeset" is not connected to other codesets, all values will be retrieved from the "codeset" it selves.

Using Reference Fields in Safran Solution

In the Safran Solution (such as Safran Project), "Reference Fields" can reference not only their local set or a master set but also other database tables. This is achieved through an "Advanced SQL" configuration within the Safran Solution.

When using the API, it expects the SQL query to return three columns with the following data types:

  1. Integer
  2. String
  3. String

If your columns are of different types, you need to cast them within the SQL command to match the expected types.

Example for MS SQL:

SELECT seq, CONVERT(nvarchar(50), wpn) AS wpn, an 
FROM activities 
WHERE net_id = 2 AND seq = 3;

Example for Oracle:

SELECT SEQ, TO_CHAR(WPN) AS WPN, an
FROM ACTIVITIES
WHERE NET_ID = 2 AND SEQ = 3;

In this example:

  • seq is an integer.
  • wpn is converted to a string using CONVERT(nvarchar(50), wpn).
  • an is a string.

Ensure that your SQL query aligns with these requirements to avoid any issues.

Parameters:

Name Type Description Notes
id integer Codeset ID
network_id integer Network ID Mandatory when "SafranWebApiOwnerVerificationDuringApiCalls" is in use.
owner string Owner of the code set Relates to "SafranWebApiOwnerVerificationDuringApiCalls" in Application Settings
meta_field_select string List of fields to include in the response, see Response Fields If empty or missing, all fields will be included.
D = All date_fields
F = All text_fields
L = All flag_fields
N = All decimal_fields
O = All outline_codes
R = All reference_fields
U = All duration_fields
0 = Do not include any of the above elements.
Dx = Date field number x
Fx = Text field number x
Lx = Flag field number x
Nx = Decimal field number x
Ox = Outline code number x
Rx = Reference field number x
Ux = Duration field number x
ExcludeValues = Suppress details as "outline_codes.outline_values" and "reference_fields.reference_values"
  • Combining id with network_id is not supported
  • When "SafranWebApiOwnerVerificationDuringApiCalls" is used, the CodeSet retrieved can only be linked to projects owned by the same owner as the CodeSet. Should the CodeSet be linked to other projets, owned by others, the API will return failure. Unless meta_field_select=0.
  • When meta_field_select=0 and the "SafranWebApiOwnerVerificationDuringApiCalls" are in use, the owner is mandatory, but neither of the IDs is.
  • When specifying meta_field_select and leaving out some fields, the JSON will still contain the fields left out. The element for the fields left out will be empty.
  • When specifying meta_field_select with "ExcludeValues", the "outline_code" will contain empty "outline_values[]" and the "reference_field" will contain empty "reference_value[]" elements.
  • When specifying meta_field_select with the combination of "ExcludeValues" and "0" as in "0, ExcludeValues" makes no sense and will be responded with "Bad Request".

Response Fields:

Name Type Description Notes
id integer Unique CodeSet Id
name string Project name
owner string Owner (Username)
reference_fields reference_field[] Collection of defined reference_field objects
text_fields generic_field[] Collection of defined generic_field objects of type text
date_fields generic_field[] Collection of defined generic_field objects of type date
flag_fields generic_field[] Collection of defined generic_field objects of type flag
number_fields generic_field[] Collection of defined generic_field objects of type number These are obsolete since 7.1.00, 30 June 2016.
decimal_fields generic_field[] Collection of defined generic_field objects of type decimal
duration_fields generic_field[] Collection of defined generic_field objects of type duration
outline_codes generic_field[] Collection of defined outline_code objects



Reference Fields:

Name Type Description Notes
field_nr integer Reference field number
label string Field label of this field
reference_values reference_value[] Collection of defined reference_value objects
visible boolean Tell if field is visible, values true or false
enabled boolean Tell if field is enabled, values true or false
inherit_label boolean Tell if (true) the label is inherited from the master set. It will be shown in Safran UI. Else (false) the label of this field will shown. The default value is false
inherit_field_nr integer If the set is inherited, this tells which field it is inherited from. Which field number in the master set.
inherit_id integer If the set is inherited, this tells which set it is inherited from Which ID in the master set.
inherit_sql string This will contain the Standard Safran SQL, or the Advanced SQL, where the field is inherited from.



Reference Value:

Name Type Description
_short string Reference value short identifier
description string Reference value description
sort_field integer Sort order of the reference_value[]


Example for reference fields and reference_values

API Methods CodeSets Userfield Config

API Methods CodeSets Reference Fields


Generic Field:

Name Type Description Notes
field_nr integer Reference field number
label string This fields' label
visible boolean Tell if field is visible, values true or false
enabled boolean Tell if field is enabled, values true or false
inherit_label boolean Tell if (true) the label is inherited from the master set. It will be shown in Safran UI. Else (false), the label of this field will shown. The default value is false
inherit_field_nr integer If the set is inherited, this tells which field it is inherited from. Which field number in the master set.
inherit_id integer If the set is inherited, this tells which set it is inherited from Which ID in the master set.


This generic field structure is present where generic user fields have been defined in the codeset (date_fields, decimal_fields, duration_fields, flag_fields, number_fields, or text_fields).

number fields are no longer used in Safran 7. Decimal fields are used instead.


outline_code:

Name Type Description Notes
field_nr integer Reference field number
label string Field label
oc_levels integer Number of maximum levels of depth in outline
levels level[] Collection of defined outline_code levels
outline_values outline_value[] Collection of defined outline_code values
visible boolean Tell if field is visible, values true or false
enabled boolean Tell if field is enabled, values true or false
inherit_label boolean Tell if label is inherited from the master set.

Level:

Name Type Description
level_nr int outline level number
label string outline level label
char_type integer Character type of level’s short value. Possible types: Any character, Uppercase, Lowercase, Numeric
field_length integer Length of level’s short value. Possible lengths: Any, 1, 2, 3, 4, 5
divider_char string Character separating level from next level when displaying full path.
Possible values: '.' ';' ':' '*' '\' '+' '-'


Outline_Value:

Name Type Description Notes
description string outline value description
_short string outline value code
seq integer outline value sequence value
parent_seq integer Refers to a seq which acts as a parent for this outline value. 0 means no parent.
level integer Level of the item in the hierarchy list. Level = 1 means root level.
delimiter_char char Delimiter character separates the short elements in a string of full path items. This is used to communicate between the caller and API.
This cannot be set to the same as "divider_char" as found in "Level".
The API will use '§' as delimiter_char in GET calls..


Example for outline Code fields

API Methods Outline Codes

API Methods Outline Codes 2


Sample JSON Response

json result

[
  {
    "date_fields": [
    ],
    "flag_fields": [
    ],
    "number_fields": [
    ],
    "decimal_fields": [
    ],
    "duration_fields": [
    ],
    "outline_codes": [
    ],
    "id": 1,
    "name": "Safran Software Solutions AS - 1",
    "owner": "SAFRANSA",
    "reference_fields": [
      {
        "reference_values": [
          {
            "description": "Procurement (Master)",
            "_short": "PO (M)"
          }
        ],
        "field_nr": 1,
        "label": "API Test.R1 (Local)",
        "inherit_label": false,
        "visible": true,
        "enabled": true,
        "inherit_field_nr": 44,
        "inherit_id": 141,
        "inherit_sql": "SELECT code, short, description FROM codeset WHERE rfield_nr = 44 and config_id = 141"
      }
      
    ],
    "text_fields": [
      {
        "field_nr": 1,
        "label": "ABC Activity Code",
        "visible": true,
        "enabled": true
        "inherit_field_nr": 1,
        "inherit_id": 141,
      },
      {
        "field_nr": 2,
        "label": "DEF no",
        "visible": true,
        "enabled": true
        
      }
      
    ]
    
  }
]