6.2.8 How to Call Billing Run on Pre-Invoice Object using Flows and Custom Buttons

Flow Builder is a declarative interface which is used to create individual Flows. It can be used to build code-like logic to automate complex business processes without programming.

How to Use Billing Run Initiator with a Custom Invoice URL Button:

You will see how to trigger invoice generation for a Pre-Invoice record using a button.

Learn how you can generate an Invoice for a Pre-Invoice Record with a Custom URL Button: You will see how to create a button that triggers the generation of an invoice for a pre-invoice record.

Creating the Screen Flow

  1. To get started, enter "Flows" into the Quick Search Bar and select it from the Process Automation section.

  2. Create a new flow and choose the screen flow type.

  3. The flow will consist of a text variable and three screen elements: a Welcome Screen, a Billing Run Screen (where the Billing Run Initiator Component will be activated), and the Final Screen.

Flow Variable

To begin create a new text variable. Follow these steps:

  1. Under Toolbox, select Manager and click on New Resource.

  2. Input the following details:

    • Resource Type - Variable

    • API Name - recordId

    • Data Type - Text

    • Allow multiple values (collection) - Uncheck

    • Available for Input - Check

  3. Click Done.

Creating the Welcome Screen

To set up the Welcome Screen with a link, follow these steps:

  1. Add a new screen element to the flow.

  2. Configure this screen element to contain a Display Text.

  1. Within the Display Text, create a link that will open the Pre-Invoice related to this flow by utilizing the recordId variable created in the previous step.

    • Link URL:

      https://yourDomain.lightning.force.com/{!recordId}

This will allow users to access the Pre-Invoice associated with this flow by clicking on the link provided in the Welcome Screen.

Setting Up the Billing Run Screen

To create the Billing Run Screen with the Billing Run Initiator Component, follow these steps:

  1. Add a new screen component to the flow.

  2. Make sure to unselect the "Show Footer" option under the "Configure Footer" section.

  1. On the left side, locate the "Custom" section, and you'll find the "Billing Run Initiator" component. Add this component to the screen.

  1. It's crucial to use the recordId variable as an input for the component. To do this, enter

    {!recordId}

    in the preInvoiceId field of the Billing Run Initiator component.

This configuration will ensure that the Billing Run Initiator works with the Pre-Invoice associated with the recordId variable.

Creating the Final Screen

To set up the Final Screen and provide a link to the invoiced Invoice, follow these steps:

  1. Add a new screen component to the flow.

  2. Ensure that you unselect the "Show Footer" option under the "Configure Footer" section.

  3. Add a Display Text component to this final screen.

  4. Similar to the Welcome Screen, you can add a URL link that will open the Invoice that has been invoiced. Use the following URL format:

    • Link URL:

      https://yourDomain.lightning.force.com/{!recordId}

Now that you've completed the flow setup, save it. Next, let's create a custom button on the ADvendio Invoice object and add it to the Invoice page layout. The flow used in this tutorial is named "Billing Run Test Flow" with the API Name

Creating a Custom Button for ADvendio Invoice Object

Here are the steps to create a custom button for the ADvendio Invoice object:

Step 1:

  1. Go to Setup > Object Manager.

  2. Select the ADvendio Invoice Object.

Step 2:

  1. In the Object Manager for ADvendio Invoice, navigate to "Buttons, Links and Actions."

  2. Click on "New Button or Link."

Step 3:

  1. Fill in the following details for the custom button:

    • Label - Billing Run Test

    • Name - Billing_Run_Test

    • Display Type - Detail Page Button

    • Behaviour - Display in new window

    • Content Source - URL

  2. In the text area below, enter the following URL:

    /flow/ADvendio/Billing_Run_Test_Flow?recordId={!ADvendio__Invoice__c.Id}

    • /flow/ADvendio/Billing_Run_Test_Flow is the URL of the flow, which can be found in the flow details. To find these details, go to the list of flows, open the action menu of the flow, and select "View Details and Versions."

    • ?recordId={!ADvendio__Invoice__c.Id} is the ID of the pre-invoice that will be invoiced and used as a parameter of the flow.

This custom button will trigger the Billing Run Test Flow when clicked on an ADvendio Invoice record.

 

Here's how the custom button should look:

Adding the Custom Button to the Page Layout

To include the custom button on the ADvendio Invoice object's page layout, follow these steps:

  1. Go to the Page Layout of the ADvendio Invoice object.

  2. Select the "Edit" option for the page layout.

  3. In the panel, choose "Mobile and Lightning Experience Actions."

  4. Drag and drop the "Billing Run Test" custom button into the "Mobile and Lightning Experience Actions" section.

  5. After adding the button, click "Save" to save your changes.

Now, the "Billing Run Test" custom button will be available and accessible on the ADvendio Invoice record's page layout, allowing users to trigger the specified flow.

Run Invoice Generation from an ADvendio Invoice record

Here are step-by-step instructions for using the Billing Run Initiator via a Custom Invoice URL Button:

  1. Navigate to the Pre-Invoice record in your system's menu.

  2. On the Pre-Invoice record, you should see the invoice status listed as "Created."

  3. At the top right corner of the Pre-Invoice record, click the "Billing Run Test" custom button that you added earlier.

  4. After clicking the button, wait for an option that says "Return to the Pre-Invoice" and click on it.

  5. The system will ask you whether you want to start the Billing Run. Press "Yes" to confirm.

  6. Wait for the process to complete. You should see a message indicating that it's Done.

  7. Now, press the option Return to the Pre-Invoice record, you should see that the invoice status has changed to "Invoiced."

How to Execute a Flow Using a Button

Buttons, links, and actions are standard features available in all Orgs and can be easily customized by an administrator without the need for any coding. Custom buttons and links can be used to direct a user to a URL or to trigger OnClickJavaScript or Visualforce actions.

To activate a flow, you can use a custom URL button in an object and fill the button's text field with the URL of the flow.