Edit inline Object properties Ontology with Action Typescript

Hello,

I’m using inline editing on several properties, but I’m encountering a problem because some properties need to be calculated based on others. For example: a date, Forecast Date = T0 + 3 days. So when I perform inline editing on T0, the Forecast Date needs to update.

How can I perform this calculation within my editable action without using a TypeScript function? Because inline editing doesn’t support TypeScript. Thank you for your help.

Hey,

In-line edits support function-backed actions (e.g., TSv1, TSv2, or Python-backed functions) so you can write + publish your function normally, create an action backed by it, and then enable in-line editing in your Object Table widget as needed.

The code might look something like:

import { Edits, OntologyEditFunction, LocalDate } from "@foundry/functions-api";
import { MyObjectType } from "@foundry/ontology-api";

export class MyFunctions {

    @Edits(MyObjectType)
    @OntologyEditFunction()
    public inlineEditExample(
        myObjectInstance: MyObjectType,
        newDateValue: LocalDate
    ): void {
        myObjectInstance.targetDate = newDateValue;
        myObjectInstance.forecastDate = newDateValue.plusDays(3);
    }

}

If you don’t want to go the function route still, you can:

  1. Create a plain Action Type where you indicate in the Rules page all properties that are expected to receive edits
  2. For a property whose new value is determined by other user-provided values, you can optionally set its visibility to either “Disabled” or “Hidden” to prevent direct user edits
  3. In Workshop, create a new variable (whose data type matches the target property) and use the Variable Transformation option – this should work for Date/Timestamp Arithmetic
  4. In the widget configuration panel for the in-line edit where you call the action, you can pass in the variable from step 3 as a parameter default/override
1 Like

Hello ,

I think that it is not the same. In my AIP Assit, we can find this with “createEditBatch

Inline Edits with TypeScript Functions in Foundry

In Foundry, you can create inline edits using TypeScript functions by building function-backed actions that can be used in Workshop widgets and other applications. Here’s how to implement this:

Creating TypeScript Functions for Inline Edits

TypeScript v2 Function Structure

To create a TypeScript function that supports inline editing, you need to define an Ontology edit function using the createEditBatch approach [_mnV1]:

import { Client } from "@osdk/client";
import { Employee } from "@ontology/sdk";
import { Edits, createEditBatch } from "@osdk/functions";

type OntologyEdit = Edits.Object<Employee>;

export default function updateEmployeeProperty(
    client: Client,
    employee: Employee,
    newValue: string
): OntologyEdit[] {
    const batch = createEditBatch<OntologyEdit>(client);
    
    // Update the property
    batch.update(employee, { propertyName: newValue });
    
    return batch.getEdits();
}

Key Requirements for Inline Edit Functions

For a TypeScript function to work with inline edits, the resulting action must meet specific criteria [_MGMv]:

  • Single object modification: May only modify a single object of a single object type
  • Default values enabled: Default values must be enabled and come from the object reference parameter
  • No static mappings: Properties being changed cannot be mapped to static values or special values like “Current User” or “Current Time”
  • No side effects: Side effect webhooks or notifications cannot be enabled

Configuration Process

1. Create the Function-Backed Action

After creating your TypeScript function, configure it as a function-backed action in the Ontology Manager [_mnV1]. This is required for the edits to actually be applied to objects.

2. Configure Inline Editing

For Object Explorer

Navigate to the Properties tab of your object type in Ontology Manager, then to the Interaction tab. Select a property and configure the Inline edit option to use your function-backed action [_MGMv].

For Workshop Widgets

No additional configuration is required in Workshop itself - the inline edit capability is automatically available once the action is properly configured [_MGMv].

Advanced TypeScript Function Examples

Updating Multiple Properties

export default function updateEmployeeDetails(
    client: Client,
    employee: Employee,
    firstName: string,
    lastName: string
): OntologyEdit[] {
    const batch = createEditBatch<OntologyEdit>(client);
    
    batch.update(employee, { 
        firstName: firstName,
        lastName: lastName 
    });
    
    return batch.getEdits();
}

Working with Struct Properties

interface Address {
    street: string;
    city: string;
    state: string;
    zipcode: string;
}

export default function updateEmployeeAddress(
    client: Client,
    employee: Employee,
    newAddress: Address
): OntologyEdit[] {
    const batch = createEditBatch<OntologyEdit>(client);
    batch.update(employee, { address: newAddress });
    return batch.getEdits();
}

Important Considerations

Validation and Submission

  • Bulk submission: Inline edits are validated and submitted in bulk rather than sequentially [_MGMv]
  • Parameter validation: Each edit is validated individually, but submission criteria that reference shared or linked objects are not compatible with inline edits [_MGMv]
  • Default values: Every parameter is optional and defaults to the existing value of the object [_MGMv]

Limitations

  • No conflicting edits: Multiple actions cannot write to the same object [_MGMv]
  • No aggregate consistency: Actions that attempt to keep aggregate values consistent are not suitable for inline edits [_MGMv]
  • Search limitations: Changes are propagated to object search APIs after function execution, so Objects.search() may not reflect recent edits [_mnV1]

Testing Your Functions

You can test your TypeScript edit functions in the functions helper in Authoring without actually applying edits to objects. The edits will only be applied when the function is executed through a properly configured action [_mnV1].

This approach allows you to create powerful inline editing capabilities in your Foundry applications while maintaining data integrity and providing a smooth user experience.

Hey,

Yup – what your AIP Assist returned is the syntax that’s used for TypeScript v2 (TSv2) which is newer and aligned with the syntax that’s used for TS/JS React apps in the OSDK. The example function I provided (I should have clarified) is written using TypeScript v1 (TSv1) and functions the same way.

Functions on Objects (FoO) – which is what are used for function-backed action types – can be written using TSv1, TSv2, and now Python as well!