+ Reply to Thread
Results 1 to 6 of 6

Thread: Can you define a workflow rule to execute a trigger?

  1. #1

    Can you define a workflow rule to execute a trigger?

    Salesforce says that it can define Time-Dependent Workflow Actions, but can you define a workflow rule to execute a trigger?

    Summary:
    I have a "project" object with a status field, and custom user object ("web_user") associated to it (project only renders the ID of the "web_user")

    When the status of a project is X, Y, or Z, I would like to hit an Apex Trigger seven days after that status changed.

    In short, shoot a follow up email to the user associated to the project 7 days after it completed.

    Is this possible? If so, how do you define the workflow rule to execute a trigger?
    Are there any examples out there?

    Any help would be much appreciated.

  2. #2
    Join Date
    May 2007
    Posts
    506
    Blog Entries
    3
    I remember asking that at DreaForce and on the developer forums and really never received an answer, but our administrator asked our sales rep to find out and the answer was now. As you know, Triggers are designed to fire after an update, insert... etc.

    Are you willing to use PHP to accomplish this task?

    Let me know because if you are, I may have a solution for you

    Hint: Now I have never used a time based workflow, but we use the regular workflows to kick off an outbound message and with that you could accomplish what you are looking to do

    ~Mike

  3. #3
    yeah i'm willing to use PHP

    As of right now, the only way i see it being done is have the workflow rule execute after 7 days, and send an outbound (SOAP) message to my server. at that point queue up the message for parsing and processing (i have individual crons for each)

    what solution did you have in mind?

  4. #4
    Join Date
    Feb 2010
    Location
    Sunnyvale, CA
    Posts
    3
    Blog Entries
    3
    Benbac:

    You sort of hinted at the preferable course in your post regarding time-based workflows. If you're looking to send someone a reminder e-mail when they've reached "Stage X" on a project, you can simply define that in the workflow rule by adding a workflow action to do so.

    I set up a test Workflow rule that says:

    When the "Stage equals X" initiate this workflow. In the actual workflow, there is a button that says, "Add Time Trigger." From there, you can define that the workflow ACTION occur 7 days after the workflow is triggered. In theory, if the project now enters stage X, the workflow will trigger and then send the action (the e-mail alert) 7 days later. You can define the e-mail template in the workflow as well.

    Note: You can only make workflows time dependent if you DO NOT select the "Every time a record is created or edited"

    I hope this helps.

    ~Will

    PS: I work with Mike and he asked me to register to see if I could help with your question.

  5. #5
    Hey Will,
    Thanks for the input but the workflow email alert action allows you to send ONLY to a standard User object (Contact or Lead as well), NOT a custom object. I'm not using standard User objects. (i have different types of users, 1 is an actual standard salesforce user, the other 2 are custom "user" objects associated with other custom objects, basically my entire app is comprised of custom objects associated with other custom objects).

    the "Project" has a custom "WebUser" object associated to it which contains the email address i would like to send to, and also task an activity to that same object.

    Is there a way to send a templated email to a custom object via the time-dependent workflow email alert action? or send an email to a custom object via the api for that matter (SingleEmailMessage, MassEmailMessage)?

    The only solution i came up with is to:
    1. Define a "New Outbound Message" under "Time-Dependant Workflow Actions",
    2. Send a SOAP message containing the WebUser ID to my endpoint URL
    3. Store and Process the message (separately via crons)
    4. Pull the user via the API (on my servers)
    5. Send email (from my servers)
    6. Update SF with tasks for those WebUsers (via the API)
    Last edited by benbac; 02-02-2010 at 06:26 PM.

  6. #6
    I might approach this by creating a custom field on the object where your trigger is. Then set up your "7 days later" Time-Dependent Work Flow and add a "New Field Update" to that Work Flow rule. For the field update use "Use a formula to select the new value" and enter "Now()" or some other formula that will enter a different value each time. When the workflow runs it would update your new custom field firing the trigger. The next time the work-flow runs the update field value should be different so it should also fire the trigger. I have never tried this -- so think it through first to see if I am missing something.

+ Reply to Thread

Similar Threads

  1. Soap Server with Workflow rules
    By Patrick Aubé in forum Salesforce Coding Discussions
    Replies: 3
    Last Post: 12-18-2007, 03:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.0 RC1 PL1