function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Glenn Nyhan 26Glenn Nyhan 26 

Creating Custom Fields in Flow and Adding a Button to Trigger Script

I am working with a nonprofit developing a script in their case management system using Flow. This has worked very well, and I have been able to build a script that meets the demands of the Program Manager who runs their volunteer hotline. I do have some questions though that I cannot seem to find the answers to online. I have predominantly used picklists and multi-select picklists to capture the various answers to questions the volunteer hotline reps will be asking tenants that call in with questions, and the picklists and multi-selects map fine to the Case Object, but where I am having difficulty is with this, when I add a screen where I want to use a text field, text box, currency or number field from the Add a Field tab I do not see those materializing in the Case object custom fields list This is my first time using Flow, and I cannot seem to find answers anywhere online. Are there extra steps involved in connecting mapping these to the Case Object?

My second question is in the creation of a button to fire the script when creating a new case. Ideally I would like the hotline rep to be able to push a Create New Case button and in doing so be taken to the script so they can launch into the scripted questions, and go through the script to completion and save the case. Does anyone have a solution for this, and if so can someone help me out with solving this issue. 
Best Answer chosen by Glenn Nyhan 26
DavidGantDavidGant
Glenn,

Regarding your first question - the custom field will need to be added to the Case object first and then you can map values to it from within a Flow. Adding the field to the Screen in the Flow just creates a way for the Flow to hold on to what the user enters. You can then reference that screen entry in a Record Create or Record Update step (or in an Assignment step if you want to add the field value to a variable).

To launch the Flow from a button, you will need to use a Visualforce Page and Custom Button (or override the standard "New" button on the Case object if you want ALL new Cases to go through the Flow). 

Here is a sample of the code for the VF Page (assuming the Flow is named "New_Case_Flow"):
<apex:page >
    <flow:interview name="New_Case_Flow"/>
</apex:page>
Here are the steps to setting up the button:
  1. Create your new Flow
  2. Create a VF Page that calls that Flow (see code above)
  3. Create Custom "Create New Case" Button or Edit the standard "New" button for the Case object so that it calls your VF Page instead of the standard page
  4. If using a Custom button, then add that button to the appropriate page layouts.
I will advocate overridng the standard button if all new cases need to go through the flow because that will allow the Flow to be called from the Case tab, the Quick Create, and pretty much any where else that the Standard button is used by default. 

Hope this helps.

David

 

All Answers

DavidGantDavidGant
Glenn,

Regarding your first question - the custom field will need to be added to the Case object first and then you can map values to it from within a Flow. Adding the field to the Screen in the Flow just creates a way for the Flow to hold on to what the user enters. You can then reference that screen entry in a Record Create or Record Update step (or in an Assignment step if you want to add the field value to a variable).

To launch the Flow from a button, you will need to use a Visualforce Page and Custom Button (or override the standard "New" button on the Case object if you want ALL new Cases to go through the Flow). 

Here is a sample of the code for the VF Page (assuming the Flow is named "New_Case_Flow"):
<apex:page >
    <flow:interview name="New_Case_Flow"/>
</apex:page>
Here are the steps to setting up the button:
  1. Create your new Flow
  2. Create a VF Page that calls that Flow (see code above)
  3. Create Custom "Create New Case" Button or Edit the standard "New" button for the Case object so that it calls your VF Page instead of the standard page
  4. If using a Custom button, then add that button to the appropriate page layouts.
I will advocate overridng the standard button if all new cases need to go through the flow because that will allow the Flow to be called from the Case tab, the Quick Create, and pretty much any where else that the Standard button is used by default. 

Hope this helps.

David

 
This was selected as the best answer
kryzkryz
Hi Glenn,

Whenever you create any field in your screen in your new FLOW, you cannot actually reference direclty the fields in the object you are trying to populate, in your case, the Case object. So let's say you have a screen that will contain an Email that will be populated by a user, you will need to drag a text field in your screen, give it a name and unique name and on your next element, let's say create or update element, you will need to map the values from your screen to the object itsefl. As per the values from the Case object, you can return existing picklist values from the object by using Dynamic Choices. 
Glenn Nyhan 26Glenn Nyhan 26
Hi David and Kryz,

Thanks so much for the guidance. Both have been very helpful. And thanks for supplying the formula for the Visualforce page David so I can create the button. Not have yet tackled gaining facility in Visualforce programming, which is the next stage I have to tackle  in my training, this was extremely valuable. The objective of this process I'm building is to have the volunteer hotline reps use the Console I set up, go to the Contacts on the menu check if a contact already exists, if it does and they have a new case, then scroll down to the Case related list item and click the button then create a new case and capture the data via the Flow script. If no contact already exists, then create new contact, scroll down and again click the new case button and proceed with the questions. All the custom fields have already been mapped to the Case object within the flow, so thats done. I also realized I need to create a New Record screen at the end of the Flow and then add the custom fields to that in order for the field data to write to the Case object Thanks again for your invaluable assistance. Most appreciated!

Have a great holiday season.

All the best,

Glenn