Output files and update Opportunity records in Salesforce Flow (for OFC Ver.1) - Office File Creator Advanced -

This article will show you how to output files using Office File Creator and update Opportunity records in Salesforce Flow. Office File Creator can be integrated into the Screen Flow.

*This procedure is for Office File Creator Ver. 1.xx. If you are using Ver. 2.xx, please refer to Output files and update Opportunity records in Salesforce Flow (for OFC Ver.2) – Office File Creator Advanced –.

 

Completed Flow

By clicking on the "Output Invoice" button, a pop-up window will appear, and when the flow is executed, output files and update the field "Bill Output Date".

 

Demo

 

 

Key Points for Flow Creation

  • The parameter that receives the record Id from the records screen in the flow is "recordId". Create a text type variable "recordId" in the flow. No other variable name can receive the record Id.
  • To output a file in Office File Creator, place the officeFileCreatorForFlow component in the screen flow. It returns the result of creating the files (success or failure) and returns an error message in case of failure.
  • For details on the parameters and return values of the officeFileCreatorForFlow component, refer to the Instruction manual.

 

 

Flow Process Overview

This is the overall picture of the flow.

1. Top Screen

Display the confirmation message.

2. Output File

Place officeFileCreatorForFlow component in the screen flow and output the file.

3. OFC error judgment

Judge the success or error of the output result. In case of success, go to process 4. In case of error, go to process 3e.

3e. Error Screen

Displays an error message and end the flow

4. Update Invoice Output Date

Update the Invoice Output Date of the Opportunity.

5. Completion Screen

Display the completion message.

 

 

Create the Flow

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

 

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

 

 

Create recordId Variable

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

 

Create the Record Id variable. After setting, click the "Done" button.

Resource Type: Variable

API Name: recordId

Data Type: Text

Available for input: check on

Note: recordId is a variable that receives the record Id from the record screen. Be sure to use "recordId" (only "I" is capitalized). Other variable names cannot receive the record Id.

 

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

 

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

Flow Label: Output Invoice Screen Flow

Flow API Name: OutputInvoiceScreenFlow

 

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

 

1. Top Screen

Click the "+" mark under Screen Flow.

 

Select "Screen".

 

Set Screen properties.

Label: Top Screen

API Name: TopScreen

 

Drag and drop "Display text" from the left component and set the properties. After setting, click the "Done" button.

API Name: dispConfirmMsg

Text: Are you sure you want to output the invoice?

 

 

2. Output File

Click the "+" mark under Top Screen.

 

Select "Screen".

 

Set Screen properties.

Label: Output File

API Name: OutputFile

Show Footer: check off

Note: The footer is hidden so that users do not click the "Next" or "Previous" button while officeFileCreatorForFlow is running. officeFileCreatorForFlow is placed on the screen, but its role is the same as an action, and only processing is performed. Upon transitioning to the OFC screen, the process starts immediately, and upon completion, the flow automatically transitions to the next flow screen and process.

 

Drag and drop "officeFileCreatorForFlow" from the component and set its properties. After setting, click the "Done" button.

API Name: OFCCmp

recordId: {!recordId}

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

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

 

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

 

 

3. OFC error judgment

Click the "+" mark under Output File.

 

Select "Decision".

 

Sets the properties of the Decision.

Label: OFC has errors?

API Name: DecOFCError

[OUTCOME DETAILS] section

Label: Error

Outcome API Name: decOFCError_Yes

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

Recourse: {!OFCCmp.isSuccess}

Operator: Equals

Value: {!$GlobalConstant.False}

 

Click "Default Outcome" in the left sidebar.

 

Set the properties of OUTCOME DETAILS, and Click the "Done" button.

[OUTCOME DETAILS] section

Label: Success

 

3e. Error Screen

Click the "+" mark under Error.

 

Select "Screen".

 

Set Screen properties.

Label: Error Screen

API Name: ErrorScreen

 

Click "Configure Footer" and check "Hide Previous" in the "Previous button".

 

Drag and drop "Display text" from the left component and set the properties. After setting, click the "Done" button.

API Name: dispErrorMsg

Text: {!OFCCmp.errorMessage} *The text is set to red from the color palette.

 

Click the "+" mark under Error.

 

4. Update Invoice Output Date

Click the "+" mark under Success.

 

Select "Update Records".

 

Set the properties.

Label: Update Invoice Output Date

API Name: UpdateInvoiceOutputDate

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

 

Set the properties. After setting, click the "Done" button.

[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: Equals

Value: {!recordId}

[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.

 

 

5. Completion Screen

Click the "+" mark under Update Invoice Output Date.

 

Select "Screen".

 

Set Screen properties.

Label: Completion Screen

API Name: CompletionScreen

 

Click "Configure Footer" and check "Hide Previous" in the "Previous button".

 

Drag and drop "Display text" from the left component and set the properties. After setting, click the "Done" button.

API Name: dispCompleteMsg

Text: Completed.

 

Flow creation is now complete. Click the "Save" button.

 

 

Debug the Flow

Click the "Debug" button.

 

Enter the record Id and click the "Run" button. Enter the Opportunity record Id here.

 

The debug screen will appear. Click the "Next" button.

 

Confirm that the file is output. Confirm the date is set to the Bill Output Date in the Opportunity record screen.

 

Click the "Activate" button on the flow. Close the Flow screen.

 

 

Create Custom Button

Create a custom button for outputting files to be placed on the record screen.

 

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

 

Set the Action Information. After setting, click the "Save" button.

Action Type: Flow

Flow: Output Invoice Screen Flow

Label: Output Invoice

Name: OutputInvoice

 

Click "Page Layout" on the left sidebar, place the Output Invoice button, and click the "Save" button.

 

 

Run Flow

Click the "Output Invoice" button on the record page.

 

A pop-up screen will appear. Click the "Next" button.

 

The Running screen will appear. Outputting the file and updating Bill Output Date.

 

The completion screen will appear. Click the "Done" button to close the flow screen.

 

The invoice file is output and today's date is set as the Bill Output Date.

 

Copied title and URL