You need to sign in to do that
Don't have an account?
Carrlos Boyd
Prevent opening a new record on a custom object depending on "status" field
I have a custom object (object1) that has multiple objects from another custom object (object2). There are three statuses for records object2: In Progress, Cancelled, and Completed. As long as there is an In Progress or Cancelled record, I want to avoid the creation of a new record related to a single object1 record. The idea is for there to only be one step/process "In Progress" at any given time until the object1 record is "completed".
Hope it helps.
Please like if it helps, .
Please mark solved if it works.
Mahalo,
Aamir AH Khan,
Salesforce Expert
All Answers
As I understood you have 2 objects, Object 1 and Object 2. Which relationship is between both objects?
As I assum that Object 1 is parent and Object 2 is child, so you want to avoid creation of parent until the status of child equals "Completed".
If you want to achive this with configuration for that you need to make sure that the realtionship shpuld be Master-Details relationship between both objects.
Then create a Rollup Summary formula on Object 1 (Parent) which count the child records with filter criteria i.e. Status equals Completed or not equals "Completed" (Based on your criteria).
Hope it helps.
Please like and mark solved if it works.
Mahalo,
Aamir AH Khan,
Salesforce Expert
Hope it helps.
Please like if it helps, .
Please mark solved if it works.
Mahalo,
Aamir AH Khan,
Salesforce Expert
For "In Progress" you can go with Duplicate Rule.
Go to Setup> Quick Find Box> Type "Duplicate Rules" > Select your Object and Create New Rule>
Select you picklist field and the value (In Progress).
Hope it helps.
OR
You can go with Rollup Summary which I described in first comment.
OR
We need to write a trigger to get all those records which have status = In Progress and then show the error message usin addError method.
You can go with anyone which is good according to your business process.
Mahalo.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm