I want to prevent users from submitting a new Job Applicant if they already applied within the last 6 month.
- If the last application is within 6 month → block new submission.
- If older than 6 month → update the existing application instead of creating a new one.
- If no existing record → create a new application.
I tried using a before_insert
method in the Job Applicant
DocType to check existing records, but it still creates duplicate entries when older than 6 month instead of updating the old record.
I also wrote a server-side API method (submit_or_update_job_applicant
) to handle insert/update logic, but I’m unsure how to integrate it with the Web Form properly.
Hello
,
You can easily add those logic in server side scripts. The question is how you will identify that user uniquely, according to me you can use entered email or phone number.
Now if a user ABC apply for the first time and will enter some email and phone number. First time the new entry will get created. Now after one week he applied again so you can do one thing before the new entry creation you have to check is this user email or phone number exists in any previous documents in a given range from 6th month ago to today.
If you not found then you can create a New entry else if found any entry so just update the data in that.
PS: you also add a validation like if that user is applying for the same role with in 6 month so then don’t create new entry and if that user is applying for different role then create a new entry.