Pass an object set from Workshop to Slate

I have a simple Slate app which is supposed to render items in a calendar. I also have an object type with a timestamp property. I now use workshop to identify the relevant objects in question. An iframe is then used in Workshop to bring in the Slate App. The relevant objects are passed in as object set:

2024-08-06_14-33-33

In Slate I have a getMessage event defined with the following code to read the object set into a variable.

const payload = {{slEventValue}};
console.log(payload["events"]);
return payload["events"];

Now, the challenge is to access the objects in Slate. Instead of a list of objects from where I can access “<object_set>.data.property” I get a weird structure, such as

{
    "filtered": {
        "objectSet": {
            "searchAround": {
                "objectSet": {
                    "searchAround": {
                        "objectSet": {
                            "static": {
                                "objectRids": [
                                    "ri.phonograph2-objects.main.object.0000-11111-2222-3333-4444-5555"
                                ]
                            },
                            "type": "static"
                        },
                        "relationId": "abc",
                        "relationSide": "SOURCE"
                    },
                    "type": "searchAround"
                },
                "relationId": "xyz",
                "relationSide": "SOURCE"
            },
            "type": "searchAround"
        },
        "filter": {
            "relativeTimeRange": {
                "propertyId": "start",
                "propertyIdentifier": null,
                "sinceRelativeMillis": 0,
                "untilRelativeMillis": null
            },
            "type": "relativeTimeRange"
        }
    },
    "type": "filtered"
}

How to I access the actual objects in Slate? What step am I missing?

1 Like

To retrieve the data from your ObjectSet in Foundry, you’ll need to use the ‘Get Objects’ endpoint from the Object Storage Service in Phonograph2. Here’s a typical workflow:

  1. Pass the ObjectSet from Workshop to a variable in Slate. Use a function to store your objectSet definition. You can pluck the objectSet definition from Workshop directly for testing - example: `
{
  "type": "filtered",
  "filtered": {
    "objectSet": {
      "type": "base",
      "base": {
        "objectTypeId": “your-object-type-id”
      }
    },
    "filter": {
      "type": "and",
      "and": {
        "filters": [
          {
            "type": "or",
            "or": {
              "filters": [
                {
                  "type": "exactMatch",
                  "exactMatch": {
                    "propertyId": “your property”,
                    "terms": [
                      “Someterm”,
                      “Someterm2”
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}
  1. Use the ObjectSetService’s ‘Get Objects Page’ endpoint to obtain the object RIDs (Resource Identifiers).

  2. Utilize the Object Storage Service’s ‘Get Objects’ endpoint in Phonograph2 to fetch the actual data using these RIDs.

An alternative approach is to use a TypeScript function to resolve the JSON of the returned objects directly.

A similar approach would be to use ObjectSetService’s Create Temporary Object Set endpoint, with the following argument:

{
  objectSet: {
    "type": "filtered",
    "filtered": {...}
  },
  timeToLive: "ONE_DAY",
  objectSetFilterContext: {}
}

Then it will return a response like:

{
  "objectSetRid":"ri.object-set.main.temporary-object-set.1234"
}

And you can use this objectSetRid in the platform tab to create a new object set.

I find that object sets created via the platform tab can be easier to use than the format of what other endpoints return.

Is it also possible to do it the other way round, i.e. receive data from slate in workshop?

Yes this is possible by setting an output parameter (docs)

Thank you, Maxi.

Unfortunately, I only get an error message, when I try to plug in the Message Payload into the “Get Objects Page” request.

{“errorCode”:“INVALID_ARGUMENT”,“errorName”:“Default:InvalidArgument”,“errorInstanceId”:“475bd0b8-b754-4534-a56c-1be7adccb59e”,“parameters”:{}}

@comew - I like this approach but the only downside is that a Palantir administrator has to expose the versionedObject endpoint to slate, which I don’t have available in my instance.

@SimonH
This is the structure of my call to the getObjectsPage endpoint

For reference this is the endpoint Slate

Get Objects Page
PUT
/objectSets/objects
Fetches object rids on requested page of evaluated object set. If more objects are available, the returned pageToken can be used to fetch the subsequent page. Note that page tokens are not long-lived and may get invalidated (for example following updates to the underlying index or indices, or after a few minutes). Note that the service currently does not provide guarantees around the consistency of returned results. In particular, any state changes to the underlying indices can cause duplicate results to be returned or some results to be skipped between subsequent page requests.

#
{
  "objectSet": "{{f_my_object_set}}",
  "pageSize": 50,
  "sort": [
    {
      "propertyId": "myproperty",
      "sortOrder": "ASCENDING"
    }
  ]}

And my function is:

var data = {{v_ObjectSet}}

return data

Unfortunately, I also get an error message with your code:

{“errorCode”:“INVALID_ARGUMENT”,“errorName”:“Default:InvalidArgument”,“errorInstanceId”:“3c4aaeee-a895-4446-a3c4-79b240c9bd24”,“parameters”:{}}

Okay, in the first step I am able to retrieve the object RIDs (not sure why you go through a function. I use the variable directly and that also works). Now I try to use Phonograph2 API and tried to get a single object (Get Object). However, I get an error about the object type not being registered. Could it be an issue with OSv2 (which I am using)?

{“errorCode”:“INVALID_ARGUMENT”,“errorName”:“Phonograph2:ObjectTypesNotRegistered”,“errorInstanceId”:“3e24f759-0e3e-473e-ab55-1cfe214379a6”,“parameters”:{“objectTypeIds”:“[some-object-type-id]”}}

Apologies @SimonH for lack of clarity

For Objects synced in the ObjectSetServiceV1 then the endpoint in slate to use to convert a list of objectrids into a readable form is:

However for Objects synced using OSv2 the correct service to use to convert the objectRids is

1 Like

Another way would be to pass the ids as a string from workshop to slate. And then re-create the object set in slate based on the ids.

  1. Create an array of ids of the object set.

  2. Convert the array of ids into a string (so that it can be passed in as an input variable to the slate).
    Foo:

@Function()
public arrayToString(arr: Array<string>): string {
    return JSON.stringify(arr);
}

  1. Pass the string ids variable into your slate as an input parameter (not a url parameter) with the key ids_string.

  2. Define a variable in slate that will hold your ids. We’ll call this ids.

  3. Receive the ids_string input parameter in slate and set the ids variable by creating a new event and action with event slate.getMessage and action ids.set.

const payload = {{slEventValue}}
const ids = payload["ids_string"];
const ids_array = JSON.parse(ids);
if (ids_array.length === 0){
    return [""]
}
return ids_array
  1. Define your object set.