Special Cases

Special cases arising when working on transforms in Faros

If you find yourself trying to write a transform and it isn't succeeding, your transform might fall into these special cases.

The "jsonb" case will occur when you're trying to write to a derived category - this is the case if you see within the schema there is a "jsonb" somewhere.

jsonb

First is the case when a field type is "jsonb", for example in the case of the ims_Incident fields "severity" and "priority":

Notice that when we query "severity" and "priority" we get an object that contains the fields "detail" and "category" inside it. If we wanted to write to the "severityCategory", "severityDetail", "priorityCategory", and "priorityDetail" fields, we'd need to write out to objects which contain the following somewhere within them (although you don't need to include both category and detail).

...
  "severity": {
    "category": "my new severity category",
     "detail": "my new severity detail"

  },
  "priority": {
    "category": "my new priority category",
    "detail": "my new priority detail",
  }
...
    

The following is a working example of JSONata and related data creating an ims_Incident object with severity "category" and "detail" properly generated:

(
$getCreator := function($name){
	$name ? $name : "unknown"
};
data.tms_Task.{
	"uid": "incident-" & uid,
  "source": "incident-transform-" & source,
	"resolvedAt": resolvedAt,
  "title": name,
	"url": "https://foo.com/" & uid,
  "description": $getCreator(creator.name) & ": " & createdAt,
  "severity": {
  	"category": priority.category,
    "detail": creator.name
  },
  "priority": {
  "category": "fixed category value"
  }

}
)

And here is the associated GraphQL (same as in the main Transforms Doc page):

query MyQuery {
  tms_Task {
    additionalFields
    createdAt
    creator {
      uid
      name
    }
    name
    uid
    source
    resolvedAt
    priority
    resolutionStatus
    refreshedAt
    type
  }
}

The result structure will be able to write the fields "severity"/"priority" to the output objects properly.