cktool: parent, reference, and record name fields

A few questions about advanced use of cktool for record creation and filtering.

Is it possible to filter by record name? I.e query for a record with a specific recordName?

Is there any way to specify record parent and reference fields when creating a record? All the examples of JSON fields so far that I have seen are of simple value types.

Is there any way to filter/query by reference-type field?

Answered by Apple Staff in 687376022

Hi Jaanus,

Thanks for using cktool! Please see responses below:

Is it possible to filter by record name? I.e query for a record with a specific recordName?

Yes, you can use the ___recordID system field, and specify the field type (referenceType) to filter on explicitly. e.g.:

xcrun cktool query-records \
      --team-id $TEAM \
      --container-id $CONTAINER \
      --environment development \
      --database-type public \
      --record-type $TYPE \
      --filters "___recordID == referenceType:{\"recordName\": \"$SOME_RECORD_UUID\"}"

Is there any way to specify record parent and reference fields when creating a record? All the examples of JSON fields so far that I have seen are of simple value types.

Reference fields can be expressed similar to the above sample. The JSON would look like:

--fields-json '{"referenceFieldName": { "type": "referenceType", "value": {"recordName": "$ID_OF_REFERENCE_RECORD"} }}'

We don’t currently support setting parent on record creation via cktool, but if you require this I’d recommend filing feedback via the Feedback Assistant and we can track the request internally.

Is there any way to filter/query by reference-type field?

Filter syntax currently only supports querying against field names directly, not sub-values such as reference type. One way to accomplish this would be to pipe the query JSON output to a something like jq to filter by reference type in a post-process step.

Hope that helps, and please reach out if there are any other questions we can help with.

Accepted Answer

Hi Jaanus,

Thanks for using cktool! Please see responses below:

Is it possible to filter by record name? I.e query for a record with a specific recordName?

Yes, you can use the ___recordID system field, and specify the field type (referenceType) to filter on explicitly. e.g.:

xcrun cktool query-records \
      --team-id $TEAM \
      --container-id $CONTAINER \
      --environment development \
      --database-type public \
      --record-type $TYPE \
      --filters "___recordID == referenceType:{\"recordName\": \"$SOME_RECORD_UUID\"}"

Is there any way to specify record parent and reference fields when creating a record? All the examples of JSON fields so far that I have seen are of simple value types.

Reference fields can be expressed similar to the above sample. The JSON would look like:

--fields-json '{"referenceFieldName": { "type": "referenceType", "value": {"recordName": "$ID_OF_REFERENCE_RECORD"} }}'

We don’t currently support setting parent on record creation via cktool, but if you require this I’d recommend filing feedback via the Feedback Assistant and we can track the request internally.

Is there any way to filter/query by reference-type field?

Filter syntax currently only supports querying against field names directly, not sub-values such as reference type. One way to accomplish this would be to pipe the query JSON output to a something like jq to filter by reference type in a post-process step.

Hope that helps, and please reach out if there are any other questions we can help with.

cktool: parent, reference, and record name fields
 
 
Q