Flow to check and redirect to create / edit if…

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

Example:
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

strategy:
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).

steps:
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

results:
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)

Button:
/flow/test_flow_w_optional_redirect?vaContactId={!Contact.Id}&retURL={!Contact.test_Flow_retURL__c}

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

Flow:
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…

 
4
Kudos
 
4
Kudos

Now read this

Testing Permission Set Deployment Changes

The Summer17 release made a rather significant change to permission set deployment. https://releasenotes.docs.salesforce.com/en-us/summer17/release-notes/rn_forcecom_permission_metadata_behavior.htm In API 40.0 and later, when you deploy... Continue →