You need to sign in to do that
Don't have an account?
Campbell Stras
Workflow rule, process or trigger to prevent daily record duplication.
Attempting to create a Weekly Time Sheet system where users have to create Daily Time Card records. If there is a Daily Time Card detail record already created for that day on the Weekly TIme Sheet master record, is there a way to use a validation rule or perhaps a beforeinsert trigger to prevent a duplicate record from being created on the same day by that user?
Do this in two ways:
Config:
1.Create a new field on Daily Time Cards, say 'uDay', set the field as unique and case sensitive as true.
2. Create a workflow with on the Daily Time cards which triggers on create of the record and updates the unique field
"employee name/employee id"+ "today"
Activate the workflow.
3. Now each time the record is created it would check if the value in the uDay field is unique, if the same user tries to create the card for the same day, it would through a validation error.
Code:
You would have to write a before insert trigger, which checks if for the current user the day card exists, and stop the records create
Please follow the link (https://help.salesforce.com/articleView?id=custom_field_attributes.htm&type=0)to know more about the unique fields
Hope it helps
RD
All Answers
Do this in two ways:
Config:
1.Create a new field on Daily Time Cards, say 'uDay', set the field as unique and case sensitive as true.
2. Create a workflow with on the Daily Time cards which triggers on create of the record and updates the unique field
"employee name/employee id"+ "today"
Activate the workflow.
3. Now each time the record is created it would check if the value in the uDay field is unique, if the same user tries to create the card for the same day, it would through a validation error.
Code:
You would have to write a before insert trigger, which checks if for the current user the day card exists, and stop the records create
Please follow the link (https://help.salesforce.com/articleView?id=custom_field_attributes.htm&type=0)to know more about the unique fields
Hope it helps
RD
Happy to help
RD
Tha's a great question. I do not know of any way to change the error message that appears.
Campbell