You need to sign in to do that
Don't have an account?
Jyosi jyosi
Trigger Help on case object
Hello Everyone,
I have a custom object which is related to case via lookup relation.
when case is created the status will be "New" .if the custom object has alteast one records,when the user should be able to change the status to "Ready ".if he tries to chnage with out any record it should prompt the error .
Thanks
Regards,
Jyo
I have a custom object which is related to case via lookup relation.
when case is created the status will be "New" .if the custom object has alteast one records,when the user should be able to change the status to "Ready ".if he tries to chnage with out any record it should prompt the error .
Thanks
Regards,
Jyo
In the trigger you will need construct a list of all the IDs for the items being updated from the trigger.new field.
Do a SOQL select using a Count() and get the number of children for each record and put them into a map (map(Id, Integer) with the key being the ID of the record, and the Integer being the count of children).
Then loop through all the records being updated (trigger.new). Using the Id of the current record, look it up in the map. If the count value is 0 then set set the record's AddError method with your error mesage. By the error field having a value, that inhibits the update and the error message will buble up to the UI