I have an app where i add peoples details. I dont want to have duplicate people within the database so when i add a person i want the duplicate to be identified and then have the option to select the person already in the database instead of the new person.
For Example
John Smith 09/09/2009 White male - already in database
John Peter Smith 09/09/2009 WHite male - being added to database.
When i press add new person button my work flow creates new thing (person) but i want a pop up to tell me this person is already in the database (without adding the new person), and check details of the person already in the database and give the user an option to add the person already in the database.
How do i do this on the workflow please?
If you need more info please let me know.
These two examples are not duplicates of each other, since John Smith is not John Peter Smith and it would be impossible to know if the user who is listed in the database as John Smith is actually the same John Smith as John Peter Smith.
This can be do and the middle name would be irrelevant.
So, database structure would be to have a field for First Name and another field for Last Name (you can keep a field for Full name if you want, but unless a middle name is somehow essential to your app function, don’t bother collecting as most apps do not)
Also in database, do not use a field of text value for the ethnicity (since your example shows a real world possibility of mistypings with WHite instead of White, so better to use an option set that the user selects from) and this field should be related to an option set you create of ‘ethnicity’.
You will also need a date field. In the UI use a date only date picker so the time component of the date is 12AM, and make sure the timezone is set to a static value so no matter where the user is, inside of the database the dates are seen as the same, because when you need to compare the dates to each other in a search constraint, the time component would be different and therefore the dates would be seen as different…and yes, multiple ways to save date information to avoid time components interfering with date comparisons, but the above is one way.
So, UI, need an input for first name, input for last name, dropdown for ethnicity selection and date picker for date selection.
Then, when you setup your popup, you will make the popup have a type of data the same as the type of data these values are associated with, and in my experience this would cause me to believe it is a User data type that has the name, ethnicity and date, so your popup should have a type of data of User…leave the datasource empty.
Then, when you press the new person button, your first action is to ‘make changes to a thing’ and the thing to change is a ‘do a search for user’ with constraints to match first name to the inputs value, last name to inputs value, date to date pickers value and ethnicity to dropdowns value.
Thing about name, is that you should save it originally to the database as entered if you really care about capitalization of names for display purposes, but in the goal of this setup, you should save it as lowercase, to make it such that when you go to compare the first name input value, to the first name in the data field for search constraint, you can do ‘first name inputs value:lowercase = first name data field’, since the capitalization would impact this…an alternative is to use a search constraint of ‘first name data field contains first names input value’…but also important, don’t forget to use the :trimmed operator to remove any spaces accidentally added by the user at beginning or end of name, so that :trimmed operator is used to save the values and also in the search constraints.
So, second action in series is to display data in popup and you will display the result of step 1:first item…if the search returned no results than the popup User value is empty, indicating no user exists, but if there is a matching result the popup User value will not be empty, indicating a user exists.
So, in popup, you can tie all functionality to the popups’ user value as is empty or is not empty to determine if you should add the user or not.
Thank you for the quick detailed response.
I think I understand what you are proposing I will try this later.
Currently I don’t have name split into first name and second name I presume splitting them would make this work more accurate?
When you say I need a date field do I need to have this displayed on the app somewhere as I currently don’t have anything with a date. Thanks Sean
Secondly
Also you mentioned the :trimmed when saving the value, where else do i need to add :trimmed other than where I have put it in the name contains…
I have added the display the result of step 1 as my second workflow, but dont get the first item option. How do i then have a message on my pop up stating “this person already exists do you want to use the original person’s data?” I can then have option of yes to select the the original data or no use new data
Yes, use the :first item if you are needing only a single item
But, you are not making changes, instead just using the make changes action to do a search and have a result within the workflows to reference in subsequent steps
Yes, I’d use it to save and then to compare in constraints as you have it in the screenshot
You would not because your step 1 is make changes to a thing, and not things as in more than 1.
Conditionals based on whether the popup user value is empty or not.
I then have my pop up display with the below wording if there is a match.
I want to display the mayched persons details on the pop up and if click yes it adds the person it lists on the pop up, if i select no it adds the original details i was adding. How do i get the conditional to do this? I may need abit of a step by step sorry.
Also if there is no match right at the start i dont need the pop up to show but just add the original details inputted.
On the workflow trigger for when Yes button is clicked put the condition for when the popup user is empty to then create a new user with details…Have another trigger for when button yes is clicked with condition for when user popup is not empty to use the user listed on the popup.
I haven’t been able to resolve this. I hope someone can help resolve it i have been trying all week,
Below is a walk through of what i have set up from start to finish. I wondered if you are able to see what the problem is at all?
I have the inputs below and the button add new person in a pop up. This pop up has type of content as “incident”.
I then only want a new pop up to displayonly if the below 4 inputs match with 4 items below:
Name, Date of Birth, Ethnicity and Gender.
I cant get this condition to work i did have Workflow below but the pop up didnt show when there were duplicates: