I created a Typescript function in the Code Repositories application:
@Edits(TableCell)
@OntologyEditFunction
public setTableCellValue(tableCellId: string, value: string): void {
const tableCell = Objects.search().tableCell()
.filter(c => c.id.exactMatch(tableCellId)).all()[0];
tableCell.value = value;
}
I then created a function-backed action type in the Ontology Manager application:
In Slate, I open the Platform dialog and add a Foundry function and select my function:
I have two questions:
- How do I pass the arguments from a Code Sandbox widget to use as the Function Inputs?
- Why does Function Output say “List of Unsupported types: Ontology edits”?
Thanks,
David
Your function edits the ontology. So you need to wrap it in an Action for the edits to actually take effect.
The only thing that can edits object in Foundry are Actions (can be a function in an action, an AIP Logic called from Action, something else, but always the main parent context is “an action”).
1 Like
Functions labeled with @OntologyEditFunction
only edit the Ontology when ran from an Action. You are correct to create a Function-backed Action to apply the edits, but in Slate you’ll want to trigger the Action via the Action Widget, not using Foundry Functions.
In order to get data from a Code Sandbox Widget, you’ll want to configure the widget’s State properties such that the Code Sandbox writes the relevant data to the State, which can then be referenced throughout the rest of your Slate app via Handlebars references like <widgetId>.state.<stateProperty>
. Then in your Action Widget, use the Handlebars references to refer to the Code Sandbox Widget state.
1 Like
Thank you, @VincentF and @jchomicki ! I’m getting very close. I’m still having one problem though. Here’s my setup:
Action widget:
Code Sandbox Javascript:
SlateFunctions.setState('cell_edit_id', 'id01');
SlateFunctions.setState('cell_edit_value', 'a_value');
SlateFunctions.triggerEvent('setTableCellValue');
The setTableCellValue event triggers the w_foundry_action_1.submit action.
The problem is that the function in the function-backed action gets the previous edit value rather than the new one. It’s as if the handlebars expressions for the action widget are evaluated before the state edits complete. Is that possible?
Thanks again,
David