Output documents and update Opportunity from the List View in Salesforce Flow (for OFC Ver.2) - Office File Creator Advanced -

This article will show you how to output documents and update Opportunity from the List View in Salesforce Flow. Office File Creator can be integrated into the Screen Flow.

*This procedure is for Office File Creator Ver.2. If you are using Ver.1, please refer to Output documents and update Opportunity from the List View in Salesforce Flow (for OFC Ver.1) - Office File Creator Advanced -.

 

Completed Flow

After selecting records from the list view, click the "Mass Output Invoice" button to display the flow execution screen, execute the flow to output files, and update Opportunity.

 

Demo

 

 

Key Points for Flow Creation

  • The parameter that receives the record Id selected from the list view in the flow is "ids". Create a text type variable "ids" and a collection variable in the flow with a check on. Other variable names cannot receive the record Id from the list view.
  • To output a file in Office File Creator, place the ofcForFlowScreen component in the screen flow. After the ofcFowFlowScreen component finishes processing, it returns the results, including the success Id list, the error Id list, and error messages.
  • For details on the parameters and return values of the ofcForFlowScreen component, refer to the Instruction manual.

 

 

Flow Process Overview

This is the overall picture of the flow.

1. Record selection judgment

Judge whether or not a record is selected from the list view. If one or more records are selected, go to process 2. If there are no records, go to process 1e.

1e. End Screen (No Record)

Display an exit screen with a message that no record is selected and end the flow.

2. Set Total Ids Count

Sets the total number of records selected from the list view to a variable.

3. Top Screen

Display the confirmation message. Clicking the "Next" button, output the file from the "ofcForFlowScreen" component.

4. Update Bill Output Date

For records with a successful OFC result, update the Bill Output Date with today's date.

5. Completion Screen

Display the completion message. If there are errors in output files, error messages are also displayed.

 

 

Create the Flow

Now let's create the flow. Open Flows from Setup and click the "New Flow" button.

 

Select "Screen Flow" and click the "Create" button.

 

 

Create variables

First, the variables to be used in the flow are created first. Here is a list of variables.

API Name Description
ids Selected record Id list in list view.
varTotalIdsCount Total record count

 

Click the "Toggle Toolbox" button in the upper left corner of the screen, then click the "New Resource" button.

 

Create ids variable.

Resource Type: Variable

API Name: ids

Description: Selected record Id list in the list view.

Data Type: Text

Allow multiple values (collection): check on

Available for input: check on

Note: The ids is a variable that receives the record Id from the list view. Be sure to use "ids" (All lowercase). Other variable names cannot receive the record Id from the list view.

 

Create varTotalIdsCount variable.

Resource Type: Variable

API Name: varTotalIdsCount

Description: Total record count

Data Type: Number

Decimal Places: 0

 

First, save the flow. Click the "Save" button.

 

Save the Flow under any name. Here it is saved as follows.

Flow Label: Mass Output Invoice Screen Flow

Flow API Name: MassOutputInvoiceScreenFlow

Description: Output invoices from the list view of Opportunity.

 

If a warning message appears, close it with an "X".

 

 

1. Record selection judgment

Click the "+" mark under "Screen Flow".

*Place the cursor over the "" mark and the "+" mark (add element) will appear.

 

Select "Decision".

 

Set the properties.

Label: Records selected or not?

API Name: DecSelectedRecordExists

[OUTCOME DETAILS] section

Label: No

Outcome API Name: decSelectedRecordExists_No

Condition Requirements to Execute Outcome: All Conditions Are Met (AND)

Recourse: {!ids}

Operator: Is Null

Value: {!$GlobalConstant.True}

Note: Select the variable {!ids} from the candidate resources. In the same manner thereafter, settings of the form {!xxx} will be selected from the resources.

 

Click "Default Outcome" in the left sidebar.

 

Set the properties.

[OUTCOME DETAILS] section

Label: Yes

 

 

1e. Error screen (no record selected)

Click the "+" mark under "No" and select "Screen".

 

Set the properties.

Label: Error Screen (No Record)

API Name: Error_Screen_No_Record

Set the properties.

 

Click "Display Text" in the left component and set the properties.

API Name: dispNoRecordMsg

Text:

No records have been selected.

Please select at least one record and then execute.

 

Click the "+" mark under "Error screen (No Record)" and select "End".

 

It is branched into two.

 

 

2. Set Total ids Count

Click the "+" mark under "Yes" and select "Assignment".

 

Set the properties.

Label: Set Total Ids Count

API Name: Set_Total_Ids_Count

Variable: {!varTotalIdsCount}

Operator: Equals Count

Value: {!ids}

 

 

3. Top Screen

Click the "+" mark under "Set Total Ids Count" and select "Screen".

 

Set the properties.

Label: Top Screen

API Name: Top_Screen

Show Footer: check off

 

Click "Display Text" in the left component and set the properties.

API Name: dispConfirmMsg

Text:

Output {!varTotalIdsCount} files.

Are you sure?

 

Click "ofcForFlowScreen" in the left component and set the properties. After setting, click the "Done" button.

API Name: OFC

recordId List: {!ids}

save: Empty  *To save the file, enter "file" or "att".

template: OpportunityInvoice  *Enter the Template Api Name of the OFC_Template record.

 

 

4. Update Bill Output Date

Click the "+" mark under the "Top Screen" and select "Update Records".

 

Set the properties.

Label: Update Bill Output Date

API Name: Update_Bill_Output_Date

How to Find Records to Update and Set Their Values: check on "Specify conditions to identify records, and set fields individually"

[Update Records of This Object Type] section

Object: Opportunity

[Filter Opportunity Records] section

Condition Requirements to Update Records: All Conditions Are Met (AND)

Field: Id

Operator: In

Value: {!OFC.successIdList}

[Set Field Values for the Opportunity Records] section

Field: BillOutputDate__c

Value: {!$Flow.CurrentDate}

*A custom fields named Bill Output Date (API Name: BillOutputDate__c) is created in Opportunity.

 

After setting, close the properties screen by clicking the "X" button in the upper right corner of the screen.

 

Click the "Save" button as appropriate to save your edits.

 

 

5. Completion screen

Click the "+" mark under Update Invoice Output Date and Select "Screen".

 

Set Screen properties.

Label: Completion Screen

API Name: Completion_Screen

 

Click "Display Text" in the left component and set the properties. After setting, click the "Done" button.

API Name: dispCompleteMsg

Text:

Completed.

Total Count: {!OFC.totalCount}

Success Count: {!OFC.successCount}

Error Count: {!OFC.errorCount}

 

Click "Display Text" in the left component and set the properties.

API Name: dispErrorMsg

Text:

Error Occurred.

{!OFC.errorMessages}​

*Set text color to red from the color palette.

*Select "errorMessages", not "errorMessage".

 

Click "Set Component Visibility" and set the conditions.

When to Display Component: All Conditions Are Met (AND)

Resource: {!OFC.errorMessages}

Operator: Does Not Equal

Value: {!$GlobalConstant.EmptyString}

 

Flow creation is complete.

 

Click the "Save" button.

 

 

Debug the Flow

Click the "Debug" button.

 

The following is displayed and there is no record Id entry field when debugging. The test will only be conducted with no record selected. First, test that no records are selected. Click the "Run" button.

 

The error message "No record selected." is displayed.

 

Next, assign a debug record Id to the ids variable for debugging only. When debugging is complete, delete the assignment. Click the "+" mark under "Screen Flow" and select "Assignment".

*This assignment will be deleted after debugging is completed.

 

Set the properties.

Label: Set Ids For Debug

API Name: Set_Ids_For_Debug

Variable: {!ids}

Operator: Add

Value: *Set the Opportunity record Id for the test.

In the example, two test Opportunity record Id's are added.

 

Ensure that "Set Ids for Debug" is added under "Screen Flow".

Click the "Save" button and then the "Debug" button.

 

Click the "Run" button.

 

The debug screen will be displayed. Click the "Next" button.

 

Confirm that the files are output and the dates are set to the Bill Output Date in the Opportunity record screen.

 

Next, test the case with errors. Return to the flow edit screen, click "Assign Id Set for Debugging" and add non-existent record Id's.

Variable: {!ids}

Operator: Add

Value: *Set the record Id of the Opportunity Id that does not exist.

In the example, 3 error Opportunity record Id's are added.

 

Click the "Save" button and then the "Debug" button.

 

Click the "Run" button.

 

Click the "Next" button.

 

Three error messages are displayed.

 

After debugging is complete, click "Set Ids for Debug".

 

Click "Delete Element".

 

Confirm that it has been deleted.

 

Click the "Save" button and then the "Activate" button. Close the flow screen.

 

 

Create Custom Button

Create a custom button for outputting files on the List view.

Open the target object from the Object Manager in Setup. Click "Buttons, Links, and Actions" in the left sidebar, then click the "New Button or Link" button.

 

Set the properties.

Label: Mass Output Invoice

Name: MassOutputInvoiceFlow

Display Type: List Button

Display Checkboxes (for Multi-Record Selection): check on

Behavior: Display in existing window with sidebar

Content Source: URL

URL: /flow/Flow API Name?retURL=/Object Prefix?fcf=filterId

*"retURL" is the URL that transitions to the list view screen after the flow is completed.

*"Object Prefix" is the first three digits of the record Id of the target object.

*"filterId" is the Id after "filterName=" in the URL of the list view screen.

 

In the example, the following is set.

/flow/MassOutputInvoiceScreenFlow?retURL=/006?fcf=00B5g00000nK3tzEAC

 

Click "List View Button Layout" on the left sidebar, then click "" and then "Edit".

 

Select the created button and click "Add", then click the "Save" button.

 

 

Run the Flow

From the list view, select a record and click the "Mass Output Invoice" button.

 

Click the "Next" button.

 

Files are output sequentially.

 

Click the "Finish" button to move to the list view.

 

The Bill Output Date has been updated.

 

 

Reference

Use with Screen Flow

 

 

 

 

 

Copied title and URL