How Do I Create an Application Record List Field GUID for Use with the Swimlane API?
To use the Swimlane API to create or update list fields in an application record, e.g. a Text or Numeric List field, a GUID must be generated to add to the API PUT/POST request, for example:
- POST or PUT requests to the /app/{id}/record endpoint for Text or Numeric List record field values
- POST or PUT requests to the /app/{id} endpoint for creating/updating Selection field definitions
These endpoints serve different purposes, but use the same GUID generation technique.
When the Swimlane UI saves a record with Text or Numeric List fields, it generates a GUID for each of the values in the list:
"values": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"ail82": [
{
"$type": "Core.Models.Record.ListItem`1[[System.String]], Core",
"value": "1",
"id": "5f2d4a05d1f737f282b679f6"
},
{
"$type": "Core.Models.Record.ListItem`1[[System.String]], Core",
"value": "2",
"id": "5f2d4a07bc0744013faeb137"
},
{
"$type": "Core.Models.Record.ListItem`1[[System.String]], Core",
"value": "3",
"id": "5f2d4a09b5051c345cc94842"
}
],
"ae5v9": [
{
"$type": "Core.Models.Record.ListItem`1[[System.Double]], Core",
"value": 4,
"id": "5f2d4a0de779783a09497131"
},
{
"$type": "Core.Models.Record.ListItem`1[[System.Double]], Core",
"value": 5,
"id": "5f2d4a0e8f92749bc9132b9b"
},
{
"$type": "Core.Models.Record.ListItem`1[[System.Double]], Core",
"value": 6,
"id": "5f2d4a0fb51a4e0cb7c88db0"
}
]
},
Note the βidβ fields.
These GUIDs must be provided by the user if creating or updating these types of record fields with the API. To do so, use this Python code to generate a GUID - a new GUID must be generated for each field:
import time
import binascii
import os
def random_objectid():
"""Returns a randomly generated MongoDB ObjectId."""
timestamp = '{0:x}'.format(int(time.time()))
rest = binascii.b2a_hex(os.urandom(8)).decode('ascii')
return timestamp + rest