I am working in Freedom UI and need to hide a custom button on the Add Record page.
The requirement is:
- The button should be hidden when creating a new record
- The button should be visible after the record is saved (Edit mode)
I tried using a business rule with the condition:
Page is opened or one of the attributes in conditions changed.
And checked whether a specific field is filled in. However, I would like to confirm the best and recommended approach to detect Add mode properly in Freedom UI.
Is checking whether the Id field is filled in the correct way to handle this scenario?
Or is there a better way to control button visibility based on Add/Edit mode?
Like
Hello,
Please note that there is no difference between a saved and unsaved record in the system - even all of the system fields like Id, CreatedOn, CreatedBy etc are already pre-filled in before saving. So there's no field that would automatically change after saving, that we could base such a business rule on.
The best solution in such case would be to create separate pages - one for adding new records where this button would be absent, and another page for editing records where this button would be present.
We will also register this idea for our R&D team and they will review the possibility of adding such functionality in future.
I typically hide buttons based on whether all the necessary fields have been completed. You can also set the button set to save data before running a process so if mandatory fields not populated it will not save and run. Alternatively as you have said you can do it in a business process by populating a hidden field when new record is created and then having a business rule based on that. I am not sure you can use ID for this as it is pre-populated like other fields
This is a point of frustration. Previously you could use something like CreatedOn for this, but that no longer works. I typically use an attribute bound to the visibility of the button and set the attribute based on changes to request.$context.CardState, but when adding a new record, the CardState doesn't change once saved, so you have to also set the attribute in the save request also. It's a lot of extra work that should not be necessary, but the only way it works currently.
Ryan
Hello,
Thank you for all the suggestions. I created a custom field for order and set that field using business process. Then added the field on form and based on that field made the button hidden.
This worked well. Now, I did the same thing for invoice. Initially, when new record page opens the button is hidden as expected but as soon as I enter value in Account field, button gets visible without saving the record.
What can be the possible cause of this behaviour?
Hello,
Can't we use PrimaryModelMode attribute as it contain create if page is opened for adding record and update if page is opened for updating record.
We can use it with custom convertor like
"visible": "$PrimaryModelMode | Usr.isvisible"
if mode is create then return false or else true.