What would be the best way to do an auto send of a survey in salesforce?
i.e. say I have a project management custom app I have written in force.com. I have a custom object called project. Projects have a status (i.e. under work, completed, etc). Projects have contacts as look-up fields (i.e. project manager, client contact, etc).
I have a survey that is meant to be sent to gather feedback on completed projects.
I would like to have an e-mail automatically sent either:
a) Whenever a project is set to status of complete, an e-mail will be sent to the client contact that has the correct embedded URL that will allow the user to launch the survey and get passed in the id of the project custom object (so the response data of the survey can be stored with a survey object tied to the project)
b) Some sort of monthly batch that will select all projects that have been set to status of completed each month and for each one automatically send out the e-mail as described above to solicit feedback on the project
This should actually be pretty easy to do, provided you have a solid understanding of the Force.com platform, though it does take a good number of steps. Here is what I would recommend:
Scenario A will be easier to do, since you can take advantage of workflow rules to do the heavy lifting. You will want to set up a workflow rule to trigger an email alert when a project is set to "Complete." Your email alert should be set up to use information from the Project object. The tricky part is in accessing your Contact's email for the "To:" field. This is best done by creating an email field in your Project object that uses a workflow to set to the parent Contact's email whenever the record is saved. Once that is created, you'll be able to set the "To:" address to that email field. You will also need to create an email template that creates a URL with the necessary fields embedded (e.g. the Project ID) and set as key-value pairs with your FormAssembly form's field IDs.
Please let me know if any of the above does not make sense and I'll be happy to elaborate.
A couple of other questions relating to this approach:
a) When setting up the e-mail to be sent as a result of the workflow trigger, do you know if there is a way to set the sender of the e-mail to be based on a field on the object? Using the above, I am able to set the TO: of the e-mail to be the field added to the project to represent the client contact e-mail. Lets say I also add an e-mail field to the project to represent the manager e-mail. Is there a way to set it up so the e-mail FROM: can be set to the manager e-mail field? Right now it seems to just let me pick the current user (which I assume is the user logged in while creating the workflow) as the FROM: address.
b) If the scenario was that I was sending the survey out to internal people (i.e. people that would have a salesforce id), I would like to use the above approach but instead have the worklflow trigger a task. On the project I'll setup a lookup relationship field so I can pick a salesforce user to be associated with the project (i.e. project sponsor). If I use a workflow to trigger off a task, it only appears to let me select a named user, role, or the object owner as the person to be assigned to the task. Do you know how I can set it up to be able to use the project sponsor user associated with the object?
Glad it's working. I have had to do something similar for our organization many times, so I know how useful it can be!
Regarding your other questions:
A) This one is tough because SFDC doesn't offer a ton of out-of-the box flexibility in this area. What is possible without custom coding is to send it from a special global address that you can specify in Setup | Email Administration | Organization-Wide Addresses. That way you can set it to send from something like projects@yourcompany.com or something similar. If you absolutely need it to come from an individual, you will likely have to set up a VisualForce email template with some custom APEX script.
B) This is also tough just because of the limitations of the workflow engine. The easiest way to tackle it would be to simply have the project sponsor (assuming there is only one) be the Project record owner. If it needs to be owned by someone other than the sponsor, then you will need to set up a separate task assignment rule for EACH potential sponsor, with the task assigned to their named user. So for example, if your sponsor is Lisa Smith, then your workflow formula would be something like IF(Project__c.Sponsor__c = [Lisa Smith's SF ID], TRUE, FALSE) and when that evaluates to TRUE, the workflow would trigger a task that is sent to Lisa Smith. You would do this for every potential sponsor. This is obviously cumbersome and annoying, so if flexibility is a key parameter you will want to look at the next (much more difficult) option of custom APEX.