Early Commit Functions

I have three functions that progress an Object-Type through discrete processing stages (NEW > TAGGED > SUMMARY > COMPLETE).

Each function depends on some properties that are modified by the previous stage. Ex: TAGGED adds a “target stock quantity”, and SUMMARY uses that target stock quantity to come up with a distribution plan, etc.

Is it possible for me to execute all of these processing stages within a single function? Calling these sequentially from within a “wrapper” function by default doesn’t have the intended effect because the TAGGED Ontology Edits aren’t actually committed to the Ontology when SUMMARY function runs, so it finds no “target stock quantity”.

This works well using Automate on each sub-Function (like an assembly line) since the Edits are committed between Automate executions, but we’d like a manual “Full Process the entire thing” button for users in the front-end. Is there a way to do this? Some kind of “commit edits early” function, or similar? We’re using the normal Functions/Ontology TypeScript API, but could use the OSDK, if that provides an option.

Cheers,
Graham

1 Like

Hey there @gmutter!

If you can output the results of each processing step to a map using the logic of your function such that you have a Map<string, EditedProperties>, with:

  • Map keys relating to the id of each object being edited
  • EditedProperties being a pre-defined interface for all your desired editable properties

then you could convert your current three functions to private functions and call them sequentially in the wrapper function you’re suggesting.
You can also add some logic for checking if “target stock quantity” (or any other property) has a valid value in EditedProperties for that id.

That way, you could retrieve the results from each individual function ahead of the next step, and if all three functions run successfully then you apply the end-state edits with the “completed” stage. You could even have intermediate checks to output some intermediate stage edits if stages fail to propagate.

Hope this helps!

Best,