Hello everyone, i have to create a warning message that shows if a user tries to change a name of an input field to one that already exists in the recorded structure.
An example of the duplicate record warning message
On this form that handles the writing of the information from the user input fields to the structure, is a save button with functionality, Save button logic flow.
Now I understand that I need to include an If statement within this process to check for existing records that match the user inputs for the record. For example, if there's already a record named 'record1' and the user attempts to input the same name for another record, I want to prompt a popup showing an error message.
If anyone cloud share an example of advise me on best practice to go about implementing this that would be greatly appreciated, thanks!
Hi Morgan,
To clarify: are you talking about a structure or a DB entity?In case you're talking about a DB record, you could create an aggregate with the Fetch property set to 'Only on demand' and on or more filters to check if a similar record already exists (e.g. Record.Name = FormRecord.Name). Then in your save button action, include a refresh action for that aggregate and then check if the aggregate returns any records. If not, there is no similar record and you can save the new record.
Hi Jeroen, sorry for the slow reply, yes the original data is being written to a table, i wasn't able to track this down originally as it was being consumed from another application via an API, all i had as reference was a structure, hence why i was confused about the implementation for this.
I have since tracked down the table and within said table there is a CRUD folder with an action that checks for Duplicated records, on within that aggregate i shall add a filter, thank you!
I shall then update the frontend save function that reads the table with an refresh action for said aggregate, as you suggested, and then add an If with the logic accordingly. Thanks for your response on this, as it was a real headscratcher!
although this solution will work, it involves going to the server twice instead of once, The solution suggested by Kharlo would have my preference.
Also, know that for creating robust applications, you should check at server side right before saving anyway, even if you have that aggregate being run first.
Dorine
Agreed. I went a bit too fast writing down my solution and only focused on the situation that was already described. Looking at the bigger picture, Kharlo's solution would be preferable.
Hey @Morgan Kemp I would do the record validation on the SaveRecord (Server Side Logic) and return a message to the Client Side to display if the Record already exists.
On Server Side:
On Client Side:
HI @Morgan Kemp
you can use list filter or list any or you can loop if existing on the list with client and/or server action
if you need to check duplicates on saved data on DB @Jeroen Barnhoorn should be the best approach to filter (e.g. Record.Name = FormRecord.Name