TypeScript equivalent of throwing an exception for cell data validation

Hello,

In the documentation for cell data validation, there is a method where we can throw an exception.

However, I am getting an error when defining this method in my index module.
image

Do I need to import a certain module to access the throw keyword?

Thanks,

Alex

This is a mistake in the documentation, and would also produce an error in JavaScript apps. Remove the “return” keyword, and just use this:

throw new Exception("Name cannot be empty");

I’m getting this error when attempting to build with the code you provided above

Sort of related, but is there a way to “require” a cell? Currently, I just change the icon and icon-color based on the value of the object.

I know there are callouts, but I don’t really understand how to use it. Could you give a typescript example of how to use it?

I get this error when I call showCallouts()

image

Sorry, that’s another error in the documentation I missed. It should be throw new Error, instead of Exception.

1 Like

Regarding your question about callouts, note that there is a regression since runtime version 4.83+ that is preventing callouts from showing. We’ll announce once this is fixed.

You could test callouts in an earlier runtime version. Your code is nearly there. You are receiving the null error because view.selected_user is null. It’s null because the view.users query is missing an await.

You should be able to update the corresponding code to:

view.users = await DB.user.all().toArray(); // also update view.users type to array
view.selected_user = view.users[0];

And in your showCallouts function add a // @ts-ignore to the column property, and assign it a number, e.g.:

component.objectTable({ id: "callout-table" }).setState({ 
        callouts: [
            {
                id: view.selected_user.id,
                // @ts-ignore
                column: 0,
                message: "Test message",
                color: "#02cf72"
            }
        ] 
    });

The column property is currently incorrectly typed as a string in OXIDE - we’ll also get that fixed.

1 Like