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?

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