June 24, 2021

Salesforce Flow – Credit Card Application

By Daryl Moon

Credit Card Application

  1. Build a screen form (two columns with conditional fields)
  2. Create an Account record
  3. Create a Contact record (and link to account)
  4. Create an Opportunity (and link to account/contact)
  5. Depending on card type and the limit applied for:
    1. Automatically approve -OR-
    2. Create a case for credit checking (linked to Opp)
    3. Case owner performs a credit check
    4. Case owner Approves/rejects Opportunity  (closed/won or closed/lost)
  6. Close Case Advise applicant of approval/rejection by email

Before we start building flows:

  1. Create queue “Credit Check Queue” for cases
  2. Add new Lookup on Case to Opportunity
  3. Create a Card Type picklist on Opportunity
  4. Update Case list view for “Credit Check Queue” to include Opportunity
  5. Upload images for cards to static resources
  6. Install and Configure Flow Magic
  7. Configure card images for Card Type picklist

Create a new Queue:

Setup -> Queue

Create Lookup between Case and Opportunity

Setup -> Object Manager -> Case

Add a new field of type lookup to the Opportunity object. This will relate the opportunity to a case.

Create a new picklist field on Opportunity

Setup -> Object Manager -> Opportunity

Configure the Case List View for Credit Check Queue

Add the Opportunity field:

Right click and Download these three (3) images and save to your computer:

Continue your preparation

Upload the three (3) images to Static Resources

Name them:

  • astro_card
  • smart_card
  • party_card


Setup -> Static Resources

Make sure you set the Cache Control to Public.

When completed, you should have three images

Install the Flow Magic App from the App Exchange

https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FeFBAUA3

Install the Navigation Button from Gravity Labs

https://gravitylab.nz/lightning-navigation-button/

Run the Flow Magic Editor (app)

Select the object: Opportunity

Select the picklist field: Card Type

Click edit and change the Image Source to: Image URL

Enter the URL as shown for the three images

Click Save.

1st Flow: Credit Card Application

This is the Screen flow we will create first:

Start Flow and create a new Screen Flow

Setup -> Flow

Select Screen Flow:


Select Auto Layout:


Add a new Screen element to the page by clicking the “+” sign under start.


Complete the properties for this screen, note we removed both Show Header and Show Footer.

Save the form we will come back to it shortly.

Create these three variables:

Create this formula:

Create these choice values:

New Resource: Choice

Note: The first three are currency data type and the next two are Boolean.


Boolean choices:

Create New Sections on the Page

Drag a new Section to the canvas:


Configure two columns, one with a width of 5 units and the other with 7 units.


Drag a Name field to the canvas and place it in the left column:


Drag an address to the right column:


Create another new section and add email and phone fields:


Create another new 2 column section and add a Radio Buttons field to the left, configuring as follows:

Note: Here we use those two choice values we previously defined.


Add a currency field and configure as follows:

Note: The use of the Component Visibility to only show this field if the applicant is currently employed.


Add another new 2 column section and drag Radio buttons to the first column, configured as follows:


Drag a File Upload field to the second column:

Note: We use conditional formatting to only display if the applicant is currently employed.



To create the heading label, drag a Display Text field to the canvas:


Next, you need to scroll down the components list to find the custom Picklist. This is a bit confusing as it has the same name as the standard one!


To finish off our form, drag a new section and create three columns:


Drag the Navigate field into the middle section to centre our button.


Now you can click done
, the hardest part of the flow is done!

Add a Create Records element and configure as follows:

Add a create records element to create the Contact record and configure as follows:

Create the Opportunity record as follows:

Create a Decision

This is the first decision we need to configure:

Add a new Decision element and configure as follows:

Click Done to save

Add Assignments

For each decision add either the Approval NO or Approval YES Assignments:
(refer to the first diagram)

No Approval required:


Yes Approval is required:

(only required for the Party Card)

Create another Decision Element

Configure as follows:

Add Assignments

Add the YES/No assignments we did on the previous decision.

Add the Final Decision Element

Based on the Approval Required variable, what do you want to do next?


Save

The YES Branch

Get the Case Queue ID

To be able to add the case to the Queue you need to know the ID of the queue first.

Create the Case

Create the case record and assign to the queue:

Update the Opportunity

Update the Opportunity stage to Negotiation/Review

Create the No Branch

The no branch is pretty simple:

Change the Opportunity to Closed/Won as it does not require any approval.


The flow is finished now so save it as: Credit Card Application

2nd Flow: Credit Card Approval

Credit Card Approval flow

Create a new flow (Record Triggered).

We want this flow to start when an Opportunity is Updated and the stage is equal to Closed.


Triggered by when a record is updated and after the record save:


The Object is the Opportunity when it is set to Closed (but only the first time).

Add a Decision Element

The decision we need to check is was the Opportunity approved or not?

If approved, the stage will equal Closed/Won if rejected it will be Closed/Lost.

Send the Approved Email

First, we need to create a text template:


New Resource -> Text Template:


Now we can format the APPROVAL email:

Format the REJECTED email

Create the text template:


Format the email:


Save the flow as: Credit Card Approval

And now for the final tests!


Test 1 – Manual Approval

  1. Run the Credit Card Application flow (debug mode is fine) and enter a new record. Choose the 10k credit limit and any card type.
  2. A case should be created to approve the Opportunity.
  3. Open the case, click the link to the opportunity and change the stage to Closed/Won.
  4. Close the case.
  5. An email (Approval) should be received at the email address you specified.

Test 2 – Rejection

  1. Run the Credit Card Application flow (debug mode is fine) and enter a new record. Choose the 5k credit limit and any card type.
  2. A case should be created to approve the Opportunity.
  3. Open the case, click the link to the opportunity and change the stage to Closed/Lost.
  4. Close the case.
  5. An email (Rejection) should be received at the email address you specified.

Test 3 – Automatic Approval

  1. Run the Credit Card Application flow (debug mode is fine) and enter a new record. Choose the 2k credit limit and the Astro card type.
  2. An email (Approval) should be received at the email address you specified.


Note: If emails are not received, check you have email deliverability enabled:

————————– end —————————