You need to sign in to do that
Don't have an account?
Sai Gupta
Can we throw a validation by checking the existing records values with new values?
Hi Team,
I have a scenario that needs to through a validation using validation rules or flows. Please help me to achieve this.
I have an appointment object, where I have a start date and an end date. If any new appointment dates have already existed in the system. I have to throw an error saying already an appointment got booked on the same slot.
I have a scenario that needs to through a validation using validation rules or flows. Please help me to achieve this.
I have an appointment object, where I have a start date and an end date. If any new appointment dates have already existed in the system. I have to throw an error saying already an appointment got booked on the same slot.
Please refer the below articles:
https://www.linkedin.com/pulse/using-before-save-flow-prevent-record-creationupdate-based-gidi/
https://www.accidentalcodersf.com/2020/06/before-save-update-flows.html
Thanks,
Maharajan.C
All Answers
As per my understanding, you would like to check if the date is already present if so then have an error added.
So there could be many ways to have this implemented but one way I could think of is you could follow the below steps:
>>You could have a trigger on that appointment object and then you could have a soql query to get the pre-existing dates and then add them into a set so that there are no duplicates.
>> now you can check if the new date is present in this created set and if it is present then you can show an error using the below line:
Trigger.new[0].addError('bad');
I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be useful for others in the future.
Regards,
Anutej
Thanks for the reply,
Really I appreciate your suggestion. But, I am looking to achieve this scenario through flow or validation. Is this possible?
Please refer the below articles:
https://www.linkedin.com/pulse/using-before-save-flow-prevent-record-creationupdate-based-gidi/
https://www.accidentalcodersf.com/2020/06/before-save-update-flows.html
Thanks,
Maharajan.C
Thanks for the reply. It's working perfectly fine.