Can a script be triggered automatically on certain events, like when an entity is created or updated?
For example, if I am writing in a “Meeting” entity description and I create a new Task inline, I would like to have a script that runs automatically to populate certain fields of the new Task.
The script could be part of the Meeting type, or the Task type. But if the script is part of the Task type then it will need to know the context of where the new task was created from (i.e., this specific “Meeting” entity where I created it).
The purpose is to have my new tasks automatically reference the Meeting entity where they were created. But in general I can see many other uses for such an ability to write scripts that are automatically triggered.
This is not possible yet, to my knowledge. But I think it should (eventually) be part of upcoming “automations” functions which are being worked on for release later this year. For now you need to use a Button that you script to perform your desired actions. It’s a few more steps, but may be workable in the short-term. So you would create the task in the meeting, open it, press the button to populate fields, then close it. That is after you configure the button of course. There are various discussions and shared examples here in the forums for how to setup buttons.
I’m assuming that when you write this that you mean that the Task is created from the meeting entity by using a #mention.
If that’s the case, then you can probably use Integromat/Zapier to do some magic on the Task when it is created.
I think the trick is that you need a way to be able to find the referring Meeting, and this can be done in principle by using a formula field in the Task type that returns only the referring entity that is of the Meeting type.
Problem is, in practice I haven’t fathomed out how to handle this in Integromat (and haven’t yet tried in Zapier).
I can’t say that I fully understand what you’re trying to achieve, but it would certainly be possible to create a button for the Meeting type, so that, when pressed, a Task is created, it has some of its fields set to specific values (which can be determined from the Meeting entity where the button was pressed) and is then automatically linked to that Meeting.
I don’t think a button can open the newly created Task, but since it will have been linked to the Meeting, it will show up in the collection of Tasks, so you can directly click on it to open.