locked
Workflow creates a task when a custom entity record is deactivated RRS feed

  • Question

  • I have a workflow that creates a new Task when a record of a custom entity ("Offers") is deactivated.  This workflow inserts the new Task in the Account's history showing that the Offer record was deactivated, including details from the Offer record built dynamically within the task.

    My problem is, the "Created By" of the Task created by the workflow always shows as me, as the owner of the workflow.   To make sure our reporting/dashboards show the true number of tasks created by a user, I need for the Task to show created by the user that deactivated the Offer record (which was the triggering event for the workflow).

    I'm not able to find a way in researching this to cause the "Created By" of the new Task record to be anyone other than the owner of the workflow.  Is this possible??  Thanks!!

    Wednesday, July 14, 2010 3:01 PM

Answers

  • Hi,

     

    The Created By and the Owner are by default set to the owner of the workflow. You can change the owner by assigning the record after creation (even in the same workflow), but the "created by" field is not updateable. The question is - why do you report by created by, not the owners?

    If you really need to have the "createdby" field set not to the workflow owner, you may consider writing a custom workflow assembly in which you would impersonate the user. Since you have to write custom code, you may also just write a plugin and use the CallerId property to impersonate the user.

    Kind regards,

    Jakub


    -- Kuba Skałbania, Netwise
    Wednesday, July 14, 2010 3:19 PM
  • Another way to do this would be to have each user in your system publish a user-scoped workflow that all do the same thing -- creates the task. That way, each user would own their own instance of the workflow and would satisfy the requirement. Unfortunately, this can be a bad idea if you would like to restrict publish workflow rights to your users. To solve this, you could temporarily grant your users publish workflow rights, and then remove it after each of the workflows are published.

    Not elegant, but it works.


    Phil Edry – Altriva Solutions – Solution Developer
    • Marked as answer by Jim Glass Jr Tuesday, July 20, 2010 6:14 PM
    Wednesday, July 14, 2010 4:13 PM

All replies

  • Hi,

     

    The Created By and the Owner are by default set to the owner of the workflow. You can change the owner by assigning the record after creation (even in the same workflow), but the "created by" field is not updateable. The question is - why do you report by created by, not the owners?

    If you really need to have the "createdby" field set not to the workflow owner, you may consider writing a custom workflow assembly in which you would impersonate the user. Since you have to write custom code, you may also just write a plugin and use the CallerId property to impersonate the user.

    Kind regards,

    Jakub


    -- Kuba Skałbania, Netwise
    Wednesday, July 14, 2010 3:19 PM
  • Another way to do this would be to have each user in your system publish a user-scoped workflow that all do the same thing -- creates the task. That way, each user would own their own instance of the workflow and would satisfy the requirement. Unfortunately, this can be a bad idea if you would like to restrict publish workflow rights to your users. To solve this, you could temporarily grant your users publish workflow rights, and then remove it after each of the workflows are published.

    Not elegant, but it works.


    Phil Edry – Altriva Solutions – Solution Developer
    • Marked as answer by Jim Glass Jr Tuesday, July 20, 2010 6:14 PM
    Wednesday, July 14, 2010 4:13 PM
  • Hi,

    I've configured a workflow that runs our sales pipeline process each time a salesperson creates a new opportunity.  The workflow works great and as the salesperson progresses the sales opportunity, various activities are created (i.e. phone calls to customer, meeting appointments, etc).  The problem though is that all of these automatically created activities belong to me, the workflow owner.  This means that all of these calls/meetings appear under my activites in workplace and not that of the salesperson, so they're then not performing the activity.

    Any advice would be appreciated!

    Thanks.

    Tuesday, July 20, 2010 5:03 PM
  • Jakub - thanks for the confirmation.  You are correct - users should be reporting on Owners, but I was inquiring about Created By just to be safe.  What I've done should work for most and just be a training issue for a handful who might try to query on Created By.  Thanks - PMG.
    Monday, July 26, 2010 4:17 PM