'Is it possible to change the title property of an object via a derived value from an edit form in Foundry?

I created an object that is backed by a Foundry Form and I would like to provide a user to change the properties of that object. I linked the form to the object and created a title property that is a hidden/ derived value in the object creation form. A user can edit property a and property b and the title of the object will be ab.

When the user updates the object in the edit form the title does not update. Is there a configuration I need to change?



Solution 1:[1]

Yes, this is possible. There's actually two ways to achieve this, I'll list them in order of my preference:

Using an action

The modern way of achieving this is to use an action. Actions allow you to flexibly "intercept" events like writes from users and do extra actions (hence the name) or prevent things from happening. They are a fairly new feature in foundry.

The basic concept is that you write a little piece of code (a function on an object) that gets executed when the object is modified. The function can then modify the object further or prevent the modification.

This is very flexible, because it will allow you to automatically update the title of the object regardless of how and when the object was edited. You can also apply more complex logic to derive the title from e.g. multiple properties with fallbacks, or modify a property in a certain way before you put it into the title, et cetera.

The drawback is that this requires you to write some code.

On your stack, if you navigate to https://www.palantir.com/docs/foundry/functions/use-functions/#actions you will find an introduction on how to get started with actions. The example solves the exact use-case you're asking for.

Using form templates

Another approach that's simpler and does not require writing any code, but is much less flexible, is to use a template in the form. You can create a template form widget that's invisible, and is automatically populated by values from other form fields.

setup

in action

The advantage is that this is very easy and quick to set up, but the disadvantage is that it will only apply when the object is edited through the form, and you can really only do concatenation, not much else.

It sounds like this is what you attempted to do, and I believe this should work. If it doesn't, I would check the following things:

  • make the template visible to see that it gets filled out like you expect it to
  • make sure the template is set to store its response into the right property on the object
  • make sure the user is using the form to edit the object, not some other way (like editing the property directly in hubble)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fmsf