Loading
 Experience Cloud – Feature Degradation on Lightning Web Runtime SitesRead More
The Trailblazer Community is now read-only Read More
Grantmaking
Call Candid Charity Check from a Flow

Call Candid Charity Check from a Flow

Build a screen flow that prompts a user for an Employer Identification Number (EIN), calls the Candid Charity Check API, and shows the result. This sample flow demonstrates how to pass an EIN to the API, handle both successful and error responses, and show tax status data to the user.

Required Editions

Available in: Lightning Experience
Available in: Nonprofit Cloud for Grantmaking and Public Sector Solutions. View edition availability.
User Permissions Needed
To create a flow: Grantmaking Manager permission set

Here’s what the completed flow looks like.

Completed screen flow that branches to a success or error screen based on the Charity Check Action result

Create a Screen Flow

  1. From Setup, in the Quick Find box, find and select Flows.
  2. Click New Flow.
  3. Click Screen Flow.
  4. Select Auto-Layout.

Create the EIN Screen Element

  1. Create the EIN resource.
    1. In the toolbox, click New Resource.
    2. Resource Type: Variable
    3. API Name: ein
    4. Data Type: Text
    5. Select Available for output.
    6. Click Done.
  2. After the start element, click Add To Flow, and then select Screen.
  3. Set these screen properties.
    1. Label: EIN Screen
    2. API Name: EIN_Screen
  4. From Components, drag a Text component to the canvas.
  5. Set these fields on the Text component.
    1. Label: EIN
    2. API Name: EIN_input
    3. Select Required.
    4. Default Value: {!ein}
    5. When to Display Component: Always
    6. Error Message: EIN must be in the following format: ##-#######.
      To enter the error message, expand Validate Input.
    7. Formula: Create a formula resource with the data type Boolean.
      For the formula, enter REGEX({!EIN_input}, "\d{2}-\d{7}").
    8. Revisited Screen Values: Use values from when the user last visited this screen
      To select the value, expand Advanced.
  6. Click Done.

Create the Assign EIN Element

  1. After the EIN Screen element, click Add To Flow, and then select Assignment.
  2. Set these fields.
    1. Label: Assign EIN
    2. API Name: Assign_EIN
    3. Variable: {!ein}
    4. Operator: Equals
    5. Value: {!EIN_input}

Create the Charity Check Action Element

  1. After the Assign EIN element, click Add To Flow, and then select Action.
  2. In the Search Actions box, search for and select Charitycheck V 1.
  3. Set these fields.
    1. Label: Charity Check Action
    2. API Name: Charity_Check_Action
    3. Ein: {!ein}

Create the Assign Response Code Element

  1. In the toolbox, click New Resource.
    1. Resource Type: Variable
    2. API Name: httpResponseCode
    3. Data Type: Number
    4. Decimal Places: 0
    5. Select Available for output.
    6. Click Done.
  2. After Charity Check Action, click Add To Flow, and then select Assignment.
  3. Set these fields.
    1. Label: Assign Response Code
    2. API Name: Assign_Response_Code
    3. Variable: {!httpResponseCode}
    4. Operator: Equals
    5. Value: {!Charity_Check_Action.responseCode}

Create the Is Charity Check Successful Decision Element

  1. After the Assign Response Code element, click Add To Flow, and then select Decision.
  2. Set these fields.
    1. Label: Is Charity Check Successful?
    2. API Name: Is_Charity_Check_Successful
  3. For the New Outcome, set these fields.
    1. Outcome Label: Yes
    2. Outcome API Name: Yes
    3. Condition Requirements: All Conditions Are Met (AND)
    4. Resource: {!Charity_Check_Action.responseCode}
    5. Operator: Equals
    6. Value: 200
  4. Click Default Outcome, and then enter No as the label.

Create the Assign Charity Check Data Element

  1. In the toolbox, click New Resource.
    1. Resource Type: Variable
    2. API Name: charityCheckData
    3. Data Type: Apex-Defined
    4. Apex Class: ExternalService__CandidCharityCheck_charitycheckx5fv1_OUT_200_data
    5. Select Available for output.
  2. After Yes in the decision path, click Add To Flow, and add an Assignment element.
  3. Set these fields.
    1. Label: Assign Charity Check Data
    2. API Name: Assign_Charity_Check_Data
    3. Variable: {!charityCheckData}
    4. Operator: Equals
    5. Value: {!Charity_Check_Action.200.data}

Create the Success Screen Element

  1. After the Assign Charity Check Data element, click Add To Flow, and then select Screen.
  2. Set these screen properties.
    1. Label: Success Screen
    2. API Name: Success_Screen
  3. From Components, drag a Display Text component to the canvas.
  4. For API Name, enter Success_Message, and then enter this text in the rich text editor.
    Successfully performed a Candid Charity Check
    EIN: {!ein}
    Organization Name: {!charityCheckData.organizationx5fname}
    State: {!charityCheckData.statex5fname}
    Tax-Exempt Status: {!charityCheckData.subsectionx5fdescription}
    Foundation Code: {!charityCheckData.foundationx5fcode}
    Note
    Note Change the text to meet your needs.
  5. Click Done.

Create the Assign Error Element

  1. In the toolbox, click New Resource.
    1. Resource Type: Variable
    2. API Name: error
    3. Data Type: Text
    4. Select Available for output.
  2. After No in the decision path, click Add To Flow, and then select Assignment.
  3. Set these fields.
    1. Label: Assign Error
    2. API Name: Assign_Error
    3. Variable: {!error}
    4. Operator: Equals
    5. Value: {!Charity_Check_Action.defaultExc}

Create the Error Screen Element

  1. After the Assign Error element, click Add To Flow, and then select Screen.
  2. Set these screen properties.
    1. Label: Error Screen
    2. API Name: Error_Screen
  3. From Components, drag a Display Text component to the canvas.
  4. For API Name, enter Error_Message, and then enter this text in the rich text editor.
    There was an error calling the Candid Charity Check for EIN {!ein}. {!error}
    Note
    Note Edit the text to meet your needs.
  5. Click Done.

Create the Fault Path

  1. On the Charity Check Action element, click the Actions menu, and then select Add Fault Path.
  2. After Fault, click Add To Flow, and then select Assignment.
  3. Set these fields.
    1. Label: Assign Exception
    2. API Name: Assign_Exception
    3. Variable: {!error}
    4. Operator: Equals
    5. Value: {!$Flow.FaultMessage}
  4. After the Assign Exception element, click Add To Flow, and then select Connect to element.
  5. Select the Error Screen element.
  6. Save and activate the flow.
 
Loading
Salesforce Help | Article