In my previous post SFDC Flow: Add a Confirmation Screen, we learned how to add a confirmation screen in SFDC flow. After this, here we see how to add a custom button to launch the SFDC flow


Add a Custom Button


Now that we have a flow, let’s add a custom button so that users can launch the flow from the invoice detail page. The button will:

  • Launch the flow specified by the flow URL. You can find the flow URL on the flow detail page.
  • Pass the relevant invoice ID into a flow variable.
  • Set the flow finish behavior so that when the flow user clicks Finish, the browser returns the user to the relevant invoice detail page.

1. Create the custom button for the Line Item custom object.

a. From Setup, click Create > Objects > Line Item.

b. In the Buttons, Links, and Actions related list, click New Button or Link.

c. Define the custom button.

    Field -              Value

    Label -            Add Line Item and Update Stock Qty

                            The Name is automatically populated based on this entry.

    Display Type - List Button

    Behavior-        Display in existing window without sidebar or header

    Content Source- URL

    URL text box-

    /flow/Add_Line_Item_from_Invoice_and_Update_Stock_Quantity

    ?vInvoiceId={!Invoice__c.Id}&retURL=/{!Invoice__c.Id} 

d. Click Save.

e. Click OK.

 

2. Add the custom button to the Invoice page layout.

a. From Setup, click Create > Objects > Invoice.

b. In the Page Layouts related list, click Edit for the Invoice Layout.

c. Click  for the Line Items related list.

d. Expand the Buttons section.

e. Under Available Buttons, select Add Line Item and Update Stock Qty.

f. Click .

The button name now appears under Selected Buttons.

g. Click OK.


3. Verify that the button appears in the preview area for the Line Items related list.

4. Click Save.

 

Try Out the App


Now try out the revised app and see the flow in action.

1. To make sure you get real results when you try the app, configure an existing Merchandise record to have a known starting quantity.

a.       Click the Merchandise tab.

b.      Click Desktop.

c.       Click Edit.

d.      Set the Quantity to 1000.

e.      Click Save.

Now when we try out the flow, we can easily verify that the merchandise quantity is updated correctly.

2. Click the Invoices tab and either create a new invoice or edit an existing one.

3. Click the Add Line Item and Update Stock Qty custom button you just created.

4. To see results on the invoice detail page, enter the following values for the line item.

    Field                              Value

    Line Item Number       11

    Merchandise                Desktop

    Quantity Ordered        100

    Unit Price                  1000

5. Click Next and then Finish.

6. Verify that the line item correctly appears on the invoice detail page.

7. Click the Merchandise tab.

8. Click Desktop.

9. Verify that the Quantity changed from 1000 to 900

 

Congratulations! You’ve successfully updated your inventory. But what happens if an error occurs? The standard behavior is for the flow to email the organization administrator a generic message, but you can modify the flow to also immediately notify the user. This is covered in my next post.

 

**This document is referred from salesforce help tutorials

  Modified On Feb-22-2018 12:39:02 AM

Leave Comment