My Workshop application allows users to input answer to 10 different topics. I would like those to populate an object set with one row for each topics, without clicking 10 times on submit buttons to create new objects.
I tried to create a batch function in code repositories, but get this error in the Actions panel of the Ontology Manager : “The following input is currently not supported: batch.”
Does anyone have a workaround?
Hi @camilleb !
What have you typed your batch
parameter as? You should be able to pass arrays of object references or strings into a function which you could loop over in order to create multiple instances of an object type.
Hello, the batch uses FunctionsMap. I don’t have any errors in code repository, but when attempting to create a rule backed by this function, I get the error message:The following input is currently not supported: batch.
Here is the beginning of my code. I redacted objects names for confidentiality. and removed the @
import { OntologyEditFunction, Edits, FunctionsMap } from “atfoundry/functions-api”;
import { Objects, ObjectName } from “atfoundry/ontology-api”;
import { Uuid } from “atfoundry/functions-utils”;
import { Timestamp } from “atfoundry/functions-api”;
export class MyFunctions {
atEdits(ObjectName)
atOntologyEditFunction()
public CreateOrUpdateObjectName(batch: FunctionsMap<string, {
userId: string,
teamId: string,
meetingDate: Timestamp,
topicId: string,
answer: boolean,
comment?: string
}>): void {
// Input validation
if (batch.size === 0) {
throw new Error(“Invalid input: non-empty batch is required”);
}
The FunctionsMap return type is “reserved” for displaying custom values in new columns within Workshop’s Object Table widget in a read-only fashion, so I don’t think it’s what you want in this case.
Do you have a Question Object Type and your users fill out an “answer” property on it? Or are you having them create a linked “Answer” instance of another Object Type?
I think something that might work is looking into In-line edits. You can use a standard action type or a function-backed action type and it would allow a user to fill in selected properties in an object table for multiple objects at a time (if they already exist).
Thank you for your reply.
I have indeed a Question Object Type where my users fill out an “answer” property on it.
More precisely, users select radio buttons (string selector widget with yes/no) that I transform into Boolean variables, and fill out a free text variable through a text entry widget.
I save those answer in variables in workshop. There are a total of 10 questions.
My object set is a vertical database, with properties as : Primary key, Answer (bool), Comment, TeamID, MeetingID, QuestionID, UserID.
I built it this way because questions can change and we should be able to update them easily.
Then, I’d like to have a single “Save All” button, that would trigger the action of creating a new entry in the object set 10 times, as I have exactly 10 topics to be populated right now.
However, the goal is to create new objects in the object set. Modifying existing ones is just a security measure to avoid duplicates entries, so I’m not sure in-line edits are the best choice here.
Thanks for the additional info, that makes sense!
I have a hacky solution that will work (we’ve implemented something similar before in another context): everything in the Ontology (including Action Types) has an API endpoint that you can hit. This means that you can create a separate function-backed action that calls your “Create Object/Answer” action type N (i.e., 10) times, and is gated by just one button in your Workshop application.
What you would do is:
- Create a TypeScript repository and configure it to work with Data Connection Sources
- Create a Data Connection source (REST API Protocol) that hits your Foundry environment (i.e., https://{HOST_NAME}.palantirfoundry.com) and uses a Token you create from Settings > Tokens
- Create a webhook for the source in step 2 that hits your “Create Object/Answer” Action Type via its API endpoint
- Create an OntologyEditFunction in your TypeScript repository that hits this DC webhook via code N times, passing in the correct arguments (i.e., Answer, Comment, TeamID, MeetingID, QuestionID, and UserID) to each webhook invocation.
- Create a separate action type that is backed by the published function in step 4, and add a button group widget in your Workshop that executes this action type.
As you can imagine, your TypeScript function will have a lot of arguments (required and maybe optional) along the lines of answerQ1 (bool), commentQ1 (string), answerQ2 (bool), commentQ2 (string), etc. However, some of the arguments each webhook invocation will be the same (i.e., UserID).
In the configuration panel for the submit/save all button group widget, you would then map the correct local Workshop variables to the correct arguments expected by your new action type.
All in all, while tedious, the above should achieve what you’re trying to implement.