In the previous post, we created the entity ‘Assets’. These assets can be tradable, and when they are tradable, we want to automatically update their price. To achieve this, we need something in the records to change so that the update flow can be triggered.
To implement this, we’ll add a new No/Yes field in the assets table. Each time this switch changes from No to Yes, the update will be triggered:

Let’s also add a command to change the state of this field. I’m doing this from the app because Power FX wasn’t available directly in the entity:






Now, let’s make it visible only when the asset type is set to Stock.


Self.Selected.Item.'Asset type' = 'Asset type'.Stock
Now, let’s add the formula for when the button is clicked. I’ll always change the value to No first and then to Yes. This ensures it doesn’t get stuck in Yes if a flow fails. The first parameter is the table, the second is our current record, and the last one is the field to be changed. Since it’s inside {}
, we could add more fields, separated by commas.

Patch(Assets, Self.Selected.Item, { 'Update Price': 'Update Price (Assets)'.No});
Patch(Assets, Self.Selected.Item, { 'Update Price': 'Update Price (Assets)'.Yes});
Now we can save and publish it. In our form, we should see the button; if not, try pressing CTRL+F5. Let’s click it and check if the field changes.


Let’s also change the asset type to non-tradable and save it to see if the button disappears.

In the next post, we’ll create a flow that updates the price whenever the Update Price field changes to Yes. Additionally, we’ll create a second flow that periodically sets this field to Yes, triggering the first flow automatically. This way, our system will maintain up-to-date prices without human intervention.
Extra
We could follow almost the same steps to add the button to the grid:




Leave a Reply