I have a VisualFlow that creates a parent record (Cohort) and 10 child records (Class).

Almost all of the fields are the same from class to class. The one notable exception is the date of the class. I'm capturing the date of the first class from the user (via the first screen), but I need each subsequent class to have previous class's date + 7 days.

I've saw the post about using Assignment, but it assumes you're updating an existing record. I'm creating net new records.

Here's a screenshot of the flow: flow in question

Any help is appreciated!

  • You mention you are getting a date value from user. Do you mean it is a screen value that the user provides?
    – pchittum
    Aug 19 '13 at 23:53
  • Yes, the user is prompted for the date of the first class. I need to calculate the rest. Aug 20 '13 at 0:09

Ok...probably not what you'll want to hear, but this sounds like a really good use case for an Apex plugin. Not that you'd have to, just that it would move a ton of complexity out of your workflow, and you could ensure that a failure on one of your records would not commit any previously created records.

But that doesn't help you with the flow. So to solve the problem at hand. You're right, you need an assign. Here's what you also need.

  1. 9 variables. Data type date. Add them in the resources tab. Name them v_date_plus_7, v_date_plus_14, etc. Or whatever makes sense to you. Prefixing is useful since names have to be unique across components in your flow.
  2. For each variable, set the default value to your screen input date field. create date variables with default values set to your field value
  3. An assign step that comes after your screen, but before your first Class record create. In that step, add assigns for every variable you created that adds the number of days you want to have apply to that variable (7, 14, 21, 28, etc). So you'll end up with something like this:

assign step with multiple "add" assignments

Then, in each record create, you use your variables to set the values of the records that are being added. The first will obviously have the raw screen input field value, but the rest use each variable value in sequence with the appropriate date field.

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.