1

My org has workflow for lead that is triggered based on the created user. I created a visualforce form that my users are filling out to create new leads. Is it possible to change the created user?

Three options I thought of:

  1. Set createdBy value - this doesn't work, it's a read only field
  2. Use System.runAs - this works only in testing.
  3. Use apex to login as that user and then create the lead.

The first two options are out, does anyone know if the third will work? Or alternatively, does anyone have any other ideas?

2 Answers 2

3

You could ask SF support to unlock the "CreatedBy" field for you so you can set it (I never had to use it but as far as I know you have only 1 chance, during insert. Subsequent updates can't modify this field).

I'm intrigued to see your workflow though, maybe there's something we could modify in it to make it work. Are there some fields that only certain users can fill maybe?

1
  • The workflow is proprietary, too bad. It would be great if you could have a look at it. I'm going to ask SF support to unlock the field - I didn't know that was possible. Thanks.
    – hgolov
    Commented Dec 22, 2013 at 19:49
0

Rather than the CreatedBy value can you set the OwnerId?

1
  • I also set the owner id, and that impacts other aspects of the workflow :)
    – hgolov
    Commented Dec 22, 2013 at 19:48

You must log in to answer this question.

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