1

My approval process works on leads when a role(Eg salesrep role) based user submits records for sequential approval from different role based users in a queue.

As per my business i am suppose to fire and email alert (Escalation Email) to the very same users in queue where it it pending at approval after a certain time and need to change the owner ship of the those escalated records to their managers.

So for escalation email : I have written time based workflow such that an email fires to respective role users according to their pending stage.

but for changing the ownership, i am banging my head how to get do it. If i am trying to print the ownership of the record, i am getting the admin name in debug or in email template. adding more, i cannot possible change the ownership if a record is submitted for approval as the record is locked during an approval process.

Any idea or suggestion are greatly appreciated.

Regards, RAJ

4
  • chops - 1) Changing ownership should be possible via success.salesforce.com/answers?id=90630000000goL9AAI ; 2) Does the time-based wf user have the privileges as described by 1) ? 3) You can verify this by putting a record into the approval process and, logging is as the time-based WF user, attempt to change ownership
    – cropredy
    Commented Dec 1, 2014 at 19:04
  • Crop Thanks for your reply, (1)AS per my approval process the admin or the current approver can edit the record. however the wf should be able to change the owner ship based on time depend action rather than the user changing the ownership manually. (2) the time based wf will fire and escalation email to role based users, as there are the very same role based users mapped to queues during the approval stages. so these users also have the same access like that of in approval process (3) looking forward to change the ownership through wf or any other automation process than manual approach.
    – chops
    Commented Dec 2, 2014 at 4:33
  • 4) Is it the salesrep user that kicks off the time-based workflows? That is, you have both an approval process and a time-based workflow running in 'parallel'?
    – cropredy
    Commented Dec 2, 2014 at 17:49
  • (4)salesrep kicks the approval on submission. then the wf based on the status of the lead will run an hourly action like sending the escalation email and changing the ownership. AS the current record is in approval process the record is not being edited to change the ownership through wf
    – chops
    Commented Dec 4, 2014 at 15:18

2 Answers 2

0

@chops

The running user for the time-based workflow will be the user associated with the Lead DML event that fires the workflow. If this is the same user as the user that starts the approval process, then the time-based workflow's user won't be able to change the ownership of the Lead object as the record is locked

This seems to be what you observe.

So, rather than use a time-based workflow, use a scheduled batch job that was scheduled by a user with system administrator privileges. The batch job looks for Leads that qualify for ownership change and change the ownerId field accordingly via DML. As the running user will be a system administrator, ownership of locked records can be changed.

By the way, you can tell if a record is locked in an approval process by following this tip.

This would be a good use of the Dan Appleman Advanced Async pattern as described here and with updated code samples and narrative here

1
  • wow, this idea could be my game changer. thanks a lot crop1645. will get back on successful done.
    – chops
    Commented Dec 5, 2014 at 6:40
0

You can make use of process builder and set scheduled actions and invoke apex code which could have some of your code in without sharing and there you would be able to change owner.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .