![Placeholder Image](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37c0e/64b177d7207a0b5e76f37c11_placeholder.jpg)
![](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b854562f5ee595832d5f2_youtube-video-tmb.jpg)
Like with all Ontologize tutorials, all data shown in this tutorial, which may include including names and emails is notional data generated solely for teaching purposes.
Before you begin...
This article assumes familiarity with Foundry ontology objects and the links between them. As a refresher, object properties refer to the attributes of an object. For example, if we had a “dog” object, breed, height, weight, color, and age would be properties. This is akin to how you have multiple columns for a single row of data.
Why does Foundry have Actions? What are they?
When you create object types and their links in Foundry, you won’t be able to modify or create new objects automatically. Foundry has Actions so that users can create, modify and delete objects. In the example in this article, we will be building and using Actions in a passenger railroad issue management workflow.
Let’s say that we have a train company, and we need to keep track of train issues. Train issues may come from many sources – reports from riders, mechanics’ work orders, or maybe even via automated processes. Regardless, there may need to be a human who can manually add new issues and modify existing ones. By using Actions, organizations can enable users to make manual edits where it is necessary to do so.
What do Actions allow users to do and what problems do they solve?
Let’s get more specific. In this case, riders will call the train company to report issues, and an operator on the other end will record details about the issue in Foundry. Moreover, they’ll want to update existing issues. For example, an operator may want to change the priority of an issue, or assign it to another individual who is better equipped to handle it.
Actions address all these needs. They let users create, edit, and delete objects. They also provide a user-friendly form interface that can be used in Workshop applications, Quiver, wherever else Actions are used in Foundry.
Who uses Actions?
Many Foundry users will use Actions, but how they engage with Actions depends on their role:
- Workflow builders will configure them for other people to use.
- Operational users will use the built Actions to carry out their jobs – but all they’ll see is the front-end, which is a form.
- Developers may interact with Actions via API calls.
How do you build an Action?
What kind of Actions do we have?
First, there are several classes of Actions – Actions on objects, actions on links, function-backed Actions, and Actions that call webhooks. In this post, I’ll be focusing on Actions on objects.
Within Actions on objects, there are three different operations you can perform:
- Add – Add a new object to an existing object set. In our example, that would be adding a new issue to the issues object set.
- Note: The object set must already exist. You cannot create a new object set by an Action.
- Modify – Modify properties of an existing object. You can modify all properties of an object except for its primary key. In our example, that could mean changing the priority of an issue or re-assigning it to a different team.
- Delete – Delete an existing object.
![Configuring an Action to create objects](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb98f242f7207b040e_75e4ca4b7c1dd72436c15d55d1290a56a384fdaae384eb5c3303e21551ab3794bdb431cb6348c45ca5b4b57628efbae99e87a0369dd5866b27c96e92b2166da283b796f70c4a093d29af01b6adbf1b1815e4860d84716e39b28b72d170bb5e644d5a3c35.png)
Setting up your Action
Before you select which type of Action you’d like to build, you’ll need to select which object set you’d like to be able to take the Action on. You’ll see here that I’ve searched for my “Train Issues” object that I created, but I can’t select it.
![Picking which object type this Action is for](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fda3acaa088a94c5d1d_ac986e22dd5b77380703207dfa32b8ebc2e09b8d1eedb7be33c21d7fa8e5c38a3d65cfcd765225296a17b0e18a4bec1e252882ae92c94aef9e4c351d9a03b07c98e3ccd72c7bc82c449f4bf0d797d1b9a062152c8570484d4e15f99df3b06dda6448a0fe.png)
That’s because before you create an Action on an object, you must enable edits on the object type. Note that creation and deletion of new objects is considered an edit to an object set. You can do this by navigating to the object type in the Ontology Management Application, selecting the “Datasources” tab, and toggling to enable edits. Remember to save the change after you complete this step.
![You can enable an object type to receive edits in the Datasources tab of that object type's configuration view in the Ontology Manager app.](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb60643306a264859c_9cf49140e5764964db7033b30494415a0dc1b4ffebe4cb593c67e9444eef74241274cca92476280192b7c24476d09f383f01e6a357817aae4116db9f36b19dd9725de9230b867acc5a9fb632934f0a01279216772d8ad96c5b8178355702f584ffd9b9c1.png)
Now that I’ve enabled edits, I'll be able to select the object I want to make an Action for. We’ll start with creating an “Add” Action. Again, this is the Action that will create a new train issue in our system.
Set-up
Something to keep in mind: if the operator is going to make new objects or modify existing ones, they’ll need a form with fields to fill out. First, you’ll need to select the object properties that you’d like to populate when a user executes this Action. When you’re making a new object, you must specify a value for the primary key property, which I’ve circled (and it must be unique from any of the other objects), but the rest of the parameters do not necessarily need to be mapped. If you don’t give a property a mapping, it will simply be null in the resulting object, which may be just fine depending on the use-case.
![Mapping Action parameters to object type properties](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb60643306a2648523_b34ae8490c2a3b135f0d763c1b25e878d0ca7e0886b2bb10ac932371256b5b533a8eca8e822df208b4b0dce35268281b271aede263db4f0ee1fbf64b207f7c335c037b3f03d4cadf4325358658df600117acdd3f984a1f2223837d465b13234c2ad999a4.png)
In this case, I am mapping all of the properties. You can continue to add properties to map using the “Add property” button.
Next, you’ll need to configure who can execute this action. Note that these permissions are specific to the Action itself – a user must have access to the application where this form is being surfaced. In this case, I’ve selected myself. You can also select a group. Later in the setup process, you can configure more complex security and submission criteria. Note: don’t forget to update this! It’s easy to set it to yourself by default and forget to change it, and then your users won’t be able to use the Action.
![Selecting which users are permitted to apply an action](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb77b8c38e11b7fd24_a2e2e06f754ffbe88cfdd54b8314ff66625b62ece1529c81e13521ad8e8a153a2d72a19e83c826ec33e90857bdc9781c476a3eda36e13850bb76e2e5946dfb122bdc10ca6a6baa0b8d4717ad581b30a4679d076e60a70cff10a2b69a6298ef7b58ce8bee.png)
Now, we can do a more detailed configuration for how each property gets filled in. Some of these fields should be editable, but others should not. For the latter, it’s your job (as the creator of the Action) to specify what the value for the field should be.
![Configuring the logic of the Action using Rules](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb690953ceec1c7fff_40b0a34f584fac10bc7ad0696258a8d795f95d82634c47032ffb03f443b693385a9ca809ab58e132604a0aad6cb737a9905a00dc6ecbe5eb2be6e05384f7e180ff04a2a3693559b64687a533638b5ffd56b43b160f75f906b1b4b39273c02e27633c10b8.png)
When you click the dropdown next to each property, you’ll see that there are several ways to populate the property. For strings, you can map to a field in the form (in the configuration, this is called a parameter – that's what will happen by default), a static value, a random unique identifier, or the current user. In this example, we don’t want the user filling out the primary key field, because they might not enter a unique value. For the primary key, I recommend using the generated unique identifier. Similarly, our users shouldn’t need to write their name or the time at which they are submitting the form, because that’s information that we can easily collect. For the “Reported By” and “Updated By” fields, we’ll make use of the “Current user” option.
![Configuring the Action form to generate a primary key for new object instances](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdbd0ba237057c2b846_6d18a177a66c65d62bba20614cca0f4f8112bf6620025350d02fa7f514850dca1f20db4ac6b54e57d6817f5fbf4baab3f4cdfcad353f01b1228b580bb8efa54ea610be5691620c8299abca2de48ee45cb158910d7850613964cffbdc9fafa5b906bca9fd.png)
For timestamps, you have the option to input the current time in addition to populating with a parameter or a static value. We’ll select the “Current Time” option.
![Configuring the Action form to record the current time as the Reported At field value](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdbaca2907b66979fdb_b54999bc5a2c02ffbbfb120a68294409a42fb05693738f1ec88cb3d1f3ccad1263d14f1e7b8e2985aa6d43c8879fd7d1d12f10336bca7f1e19e7b6a19808e58ede4df51f538dae25eed5625ebdfc6a4f45d94e135a27d4b7e934d55d7083a494c10906fe.png)
Building the Form
Once you’ve configured what your Action does, you can configure how the user does it via the form. The form is the next tab after rules. As you configure the form, you can see a form preview on the side. This is how it will look when you incorporate it into an application.
![The Action Form preview](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdaf19eb3e7cdd5e9a8_cd93096076e9fdcb910880a157caf914a5255a64cea1a013ad000a40efd481063235bd2ec4c917d6c11e5f9c2401187caf7087b26b4b3778c087ca2eb10fa30a90726ecf86e7c3edce75ef8feaa0c3455ca61b1a6492feeb2e6b632eaa567cd3ebd9f3c9.png)
Once we click into a parameter, you can see that there are many ways to customize the way a parameter is input. Remember, a parameter is a field in the form. We’ll look specifically at “Assigned Priority” and “Train ID.”
Making a Field Multiple Choice
When configuring the constraints of the parameter, you have an option to make the field multiple choice. You can manually enter the options (if there aren’t too many, or they aren’t going to change) – or, you can pull the choices from a property of any object set. The latter can be a great way to future-proof your Action against data changes. In this case, we only have three options, and they likely won’t change, so manually entering the options will work for us.
Overrides
As you design your form, you might want users to have different options based on what they've selected earlier, or who they are. With all forms, Foundry lets you dynamically present which field should be shown to the user and how that field should be populated.
![Got the Overrides tab to change the visibility, disabled state, whether the field is required, and default values.](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdbc1be96cb2adda67c_466cf1fe20ca94311014ca7b9c527a5aa59e3e5d0e81da0e8c2e7a90b0410dd53863a4f84602bd05deabe9706b556007820c2cd1c0b1ce15e31d0d7d50b4178a957b9dae9e8c21f19c49ff036829c37f56a357fa9105069abf3067661dd4f3380084bcd8.png)
When we click into “Assigned Priority,” you’ll see that you can control whether the input is visible, disabled, and required, as shown in the first circled section.
We may choose to hide or disable parameters for several reasons – for example, if there is a default static value, or we collect the user id or current timestamp, or simply set a random ID, there may not be a need to show it to the user. A shorter form may be less overwhelming for users.
For each of these controls, we can add overrides. Let’s say for example that Gena is allowed to enter a priority for an issue, but Taylor is not (even if he is allowed to create an issue.) I can configure that by doing the following:
![Changing which users are able to apply the action using overrides](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb910f8f01cc0e4f58_a0496fc44ef016895ac4f5106cfa632ddd1bf6c44c6d4e50d434087973b8140df372d3ce22ddbf8cb6e185bfaac9ac15b0ca38b81f3ade9b06fc481a81431d66e1fc128148c3e33841804f61b88cf3c08c83eb654c0eb39c5da1f642372f29139167f43f.png)
Note that you can also make these qualities dependent on other parameters, but if you choose to do this, that parameter must precede this one in the form. If a parameter will be conditionally available for a user to populate (and won’t be populated otherwise, say, with a default) do not make it a required property, as this can result in unexpected behavior – unless you add conditional logic to make the field non-required for certain users.
Finally, you can add overrides for the content of a field. While we already covered overrides for determining if a field is visible, disabled, or required, you can use the overrides tab to configure more complex specifications. In our example, perhaps if the issue source is “Mechanic Report,” we may want to default the priority level to high. We can also set additional conditional requirements using RegEx. For example – say we are collecting contact information as part of a survey. Respondents can choose either “phone” or “email” as preferred contact method. Depending on their choice, we can configure RegEx to require either a phone number or email format.
![Overriding default values based on the value of a form field](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb9e48b9458ddbf841_06b92510e55496347456530f163395108c991a15b2d3e4077dab384661042d65a7c0271a59dc1b043403c04c9ac68b26484d2881fe3c2aedd886376354f16c8e32be9a603272b5ab5a65d0cf594805921764f4cc0cc8c7637d5047626ffa95f105466eaa.png)
Object References
In our example, each train issue will be associated (or “linked”) to a train. They are linked by the “train_id” column. When your user is filling in which train is associated with an issue, they may not remember the full identifier of the train (the primary key.) Even if they do, they might not format it correctly. If that happens, the link between the objects won’t work.
This is why we use object references. We can avoid issues here by making the “train_id” column an object reference. This means that your user will see a dropdown of actual trains. We do this by changing the type to “Object Reference.”
![Use and Object Reference field type instead of manually inputting the primary key of an object](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb50cc3d60c66e7252_5ca38e70ac65e64a729947322264ea8d75ff9447dc180228782e296f77c5b9fd1c7fb3fb90662bbc504aec65a2684ae4e9ac61080231ccfd11886d1414dc2e255852119b409fb44b6508c2195bb682b100cadb550eec475c4fd1d6260ea6a77be9721566.png)
You’ll be prompted to select which object you want to reference. We’ll select “Train.”
Once we’ve set the field to take an object reference, it will show up in the form as a dropdown of objects.
![An object reference field type generates a dropdown menu for users of the Action so they can select object instances](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdbbc4e9c236f12d2d7_f3226e444a68d36438de94ba4c914a7bc497ad266e955582200de775e83c3292526a186f0f5dea23e077a8cd0122341429797c465e558dafd7a3d679ed42f9e1ee05f1884d0414041160aff073f8ef297c4f378d13a7b302c19f813a82b04ec1333fd8a8.png)
Making a Modify Action
There are a few differences when you’re making a Modify Action. For starters, you’ll choose “Modify” instead of Add. Just like when you’re making an Add Action, you’ll select which properties you want the user to be able to modify. I tend to restrict this to the properties that a user would feasibly need. In this case, the user will likely need the ability to edit the priority, status, and potentially the description. We’ll also want to record who updates it, and when, but just like when we created the Add Action, we’ll record it automatically and won’t show those fields.
![Making an Action to edit objects is a similar process](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb49a11138a11f55b1_36850ea3e53c34bf0cc4df3ceed478ce0c3dbf0b5691c0516cd495472a6e485f0494d9abd086e9ce7d74d4c8fae11fb2159ca72ad04e901925c7d6400aa1e4402d31cd1c3bc020dc6c49b10284f4f287894dd0d789a3bd46dd09f55784214a8117c9a14e.png)
The next difference is that the train issue ontology object is now a parameter in your form. After all, if a user wants to modify a train issue, they’ll need to select at least one. At this point, you can make this a bulk Modify Action by toggling “Allow multiple values.” Note that if you do configure the Action to work on multiple objects, it will give the same updates to all of the selected objects.
![You can also modify multiple objects at one time](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdaf19eb3e7cdd5e9ad_d94770a2caf1e19fe4760f8d1910113d14e3d4fb1966a11384863b34a5eca9e3abfd01cb58fcf4ce4be24d4de6dba9475049dea0ec519c6c9049ded91b6052c37211da0815fbfc6ea266575bd5f9110fba87c2aa3f5430eff5ed3f485f32ec995050e99d.png)
The other difference is that the default for every other field will be automatically set to the corresponding property of the object in question. This is generally a good practice – it's convenient if, when your user opens the form, it’s filled out with its prior values.
Otherwise, when configuring a Modify Action, you’ll have all the same configuration opportunities that we discussed in the Add Action section.
Logging
Sometimes the history of changes that are made to an object is a valuable source of data itself. You can easily switch this on in the Action configuration by toggling “Enable Logging” in the capabilities tab. By doing this, you’ll be able to create a row of data every time the object set receives an edit.
![Actions logging is enabled on the Capabilities tab for an Action type in the Ontology Manager app](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb22403d4ffaa15278_14adcd64925a54bccbf75fb984b75ed9cece8a036ba1c762877c4cd9194db96a8af036038a7aa6f1b8924c74ab6cdab3f6c3cf3dcfe1a6d6c5ab9e602df669d301055a2e11038ef9184f7fac3e4f252fda73584fba11ea62b1e7d7b49a3cac70272d9a7f.png)
Your Next Steps
Now that we’ve covered the fundamentals of how to create an Action, there’s still more to consider. For people who are building applications for others to use, we’ll cover the basics of integrating Actions into applications. For people who have more technical experience, we have outlined future learning.
Surfacing an Action
You can think of the form as a packageable component that you can put where you want. So, once we have determined what an action does and have designed the form that users will interact with, we’ll want to put it somewhere that they can use it. Right off the bat, the Modify Action will appear as an option in the object view in object explorer. This is automatic – all Modify or Delete Actions will appear in the “Actions” dropdown on the object view for the object they act on.
![Using an Action from Object Explorer](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb5ddae2badf79bc20_c1196a1ae27bc736404f3aa2baba85ad12388aecd2801b843e02d750dd51ddd0b67187ce4501440b8108704539f7742f1cbaf47534c0b6ab5d882b4994fe03a23712512e60303502a89555820ac02206c1154409b88189d3584c13aec320c018430b9153.png)
Most often, you’ll want to surface your Action in a workshop application. You can surface an Action in as many applications as you like.
Here is a very simple workshop application where the user might want to carry out the “add train issue” and “edit train issue” Actions. We have a table of train issues, and a few filters to narrow it down.
![Adding an Action to a Workshop application](https://cdn.prod.website-files.com/64b177d7207a0b5e76f37bc9/650b1fdb1517e191434dc11c_9c13c4a541559bb017fbe0f0223abe2e7a05183f6e79bb0c68e2ca91f5f36dbaded881b1b863bea1c0407cc1cb14ca11dc3e8f73451b353659c7509502014f2abd45f4d0302b0777816f145cd60bee3b4dc5dfeccf057aa9243f52080b14feb41e01cf08.png)
First, we’ll give the user the ability to add a new train issue. There are several ways to surface an Action: a button, an in-line Action, and in-line editing in a table.
Buttons
Buttons are one of the most common ways to integrate an Action into a workflow.
In-Line Action Form
In line-line Action forms give the user the ability to fill out the form without clicking a button to open it.
In-Line Table Edits
In-line table edits are great if the user will want to make multiple modifications to many objects at once.
Future Learning
As we discussed, Actions on objects are only one kind of Action. Additionally, there are multiple ways to interact with Actions.
- For specifically modifying links between objects, you can apply an action on links.
- If you need more advanced functionality out of an Action, such deriving a value from other properties and storing it, a function-backed Action may be an appropriate solution.
- If you need to edit or notify external systems, you’ll need to use a webhook.
- Object monitors can submit actions automatically when conditions are met.