3

Who is the "Current User" when a time based workflow fires in the future? I have Entitlement Milestone email alerts scheduled in the future, and the "From" (on behalf of) appears to be selected randomly. I have seen instances where it is not the creator or owner of the Case record being alerted on, nor did that user ever own or edit the record (from what I can see in the history).

I reference the current user twice in the template, once as the from, and once in the body of the message. It is a VF email template, that looks like this:

<messaging:emailTemplate 
    subject="CASE: {!relatedTo.casenumber}  has exceeded 60% of SLA time"
    recipientType="User" 
    relatedToType="Case" >
<messaging:HtmlEmailBody >
   Please review and resolve. 
   {!relatedTo.Subject} Case {!relatedTo.CaseNumber} will exceed its SLA level on:<br/> 
   <apex:repeat value="{!relatedTo.casemilestones}" var="cm">
      <apex:outputfield value="{!cm.Milestonetype.name }" /> -
         <c:VFEmailDateTime date_time_value="{!cm.TargetDate}" />
   </apex:repeat><br/><br/>

   Submitting Agent: {!$User.FirstName} {!$User.LastName}<br/>
   Case Owner: {!relatedTo.Owner.Name}  {!IF(relatedTo.Owner.Type=="Queue","Queue","")}
   <br/>
   To access the case, use this link: <br/>
   <apex:outputlink 
      value="!LEFT($Api.Partner_Server_URL_140,
      FIND('.com',$Api.Partner_Server_URL_140)+4)+relatedTo.Id}">
      {!relatedTo.CaseNumber}
    </apex:outputlink><br/>
</messaging:HtmlEmailBody>
</messaging:emailTemplate>

This random user also appears on the "Submitting Agent" line. I assumed it would be the user that caused the condition to be true for the milestone (and alert) to be queued.

Thanks!

1

According to my knowledge workflows are always run in context of user who triggered it.

1

This isn't particularly well documented, but from my investigations it will be the user that triggered the time based workflow (i.e. took the action that caused it to be queued) unless the user has been deactivated, in which case it will be the default workflow user.

https://help.salesforce.com/HTViewHelpDoc?id=workflow_defaultuser.htm&language=en_US

The key section is:

When the user who triggered the rule isn’t active, Salesforce displays the username of the default workflow user in the Created By field for tasks, the Sending User field for email, and the Last Modified By field for field updates.

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.