Flow to check and redirect to create / edit if…

Check if record (meeting certain criteria) already exists, if not redirect to standard create new page, else redirect to view record

client services - wants all records for a client from a single day under a single case. so if case already exists for a contact for today, display message and redirect to record on finish, else allow user to create new case

This can be done w/ visualforce. Testing to see how it works w visual workflow.

Trying a few approaches:
A) flow + use retURL to redirect to new case page based

Use retURL on button that launches flow to redirect to new case page
If case exists, use screen to display link to case (and no finish button so no redirect possible)
If no case exists, go straight to redirect (no screen).

pass contactID to flow variable in button
use fast lookup to check if case exists
Use decision to evaluate whether record found
If true, direct to page that says case already exists w link to case.

If false, do nothing (no step after decision), which will redirect to new case

this worked w a custom button and a URL hack. had to use a formula field on contact button for retURL. would not work using {!URLFOR($Action.Case.NewCase)} w/ or w/out parameters, or by stringing together the retURL in the button (would not set the contact ID)


Formula Field
Return type: text
Value: “/500/e?cas3=”& FirstName &“ ”& LastName &“&cas3_lkid=”&Id&“&RecordType=012400000009RRD”&“&cancelURL=”&Id

3 steps

  1. fast lookup (lookup case where contactID = vaContactId)
  2. decision element to evaluate if fast lookup = globalconstant.true
  3. if true -> go to screen, else (nothing)

B) flow w controller that sets finish location to a variable
wont require any custom formula fields / hackery
will require a visualforce page and a custom controller, but pretty lightweight
coming soon-ish…


Now read this

Using a dynamic choice to select multiple records in visual workflow

With a small trick, Dynamic choice elements in visual workflow can be used to display multiple records, and only act on the selected record(s). In a previous post, I described how to create a button that could copy all attachments from... Continue →