1

I'm trying to update parent record when current record is 'finally approved'. I've master-detail relationship between parent child

was trying to achieve this in following ways :

1) Firing Cross object field update when record is finally approved- Found this is not possible

2) Writing trigger on child, which query processIntance object ProcessInstance somethng like this :

Select ID, Status, TargetObject.Name From ProcessInstance Where TargetObjectID = '' AND Status in ('Approved', 'Rejected')

TargetObjectID -> current record ID

But seems like status of record is still not approved , when trigger is firing.so query is not returning anything

3) Thinking to writer a scheduler which will fire same code i'm writing in trigger. I'm going to implement this which I think, will work But just thinking If community has any other efficient way to achieve same

Thanks !

  • What are you even updating on the parent? Are you sure it can't be achieved with rollups? – Adrian Larson Apr 21 '15 at 21:34
1

I an confused why you are querying ProcessInstance. Are you not setting a status field when the record is approved? If you have one, just use an after trigger to look for it changing to Approved (or whatever) then query for the parent and update that.

Strictly speaking a status field isn't necessary, but I have never implemented an approval process where the business didn't want a status field on the object. I suppose your proposed way would work, but I hope you have a strong reason to avoid adding a status field. If not, you are just creating a headache for yourself!

  • Thanks for your response. See -We've created a custom status field and updating its value to say 'approved' via ' field update' through Approval process. I was trying to fire trigger to update parent. But issue is - 'After trigger' seems to be firing first and it was not getting value 'approved' on the record. – curious_techy Apr 22 '15 at 3:46
  • You have your trigger on the child, right? And you are sure you are using the correct map/list in the trigger? – raffters Apr 23 '15 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.