Ask Search:
Jim StricklandJim Strickland 

Can I use Visual Flow to make a Create Record button that copies field info from one object to another?

I have two custom objects, ARC-Contracts and Job Invoices. I have Job Invoices showing up as a related list in the ARC-Contracts detail record layout. I would like to create a button that creates a new Job Invoice record that copies the Contract Title, Contract Number, and Account from the ARC-Contracts record detail. It will also fill the Job field with Contracts - AR and generate a random invoice number. The problem is I don't have anyone currently in my org who can write visualforce or Java Script. Is it possible to do this with Visual Flow? I know it contains a Record Create Element. I just don't know how to add a field and tell it to copy the contents from an identical field in ARC-Contracts. Is this possible?
Best Answer chosen by Jim Strickland
Scott JohnsonScott Johnson
Here is a bit more detail.  Hope this helps!

1 - Create a variable called varARCContactID - make sure it is Input/Output
2 - Fast lookup on ARC-Contacts.  Lookup the record where ID = varARCContactID.  Name it varARCContacts
At the bottom - add each field you need to capture.  Title, number, account, etc...
3 - do a record create.
For each field in Job Invoices - click the drop down, and select Sobject Variable >> varARCContacts >> field you want to copy
4 - Cretae a confirmation screen.  Add some text  - something like "Your Invoice has been created"
Fourth - create a button that launches your flow.  Something like this
/flow/ARCContactFlow?varARCContactID={!ARC_Contact.Id} (this tells the flow the ID of the record in ARC-Contact

All Answers

Scott JohnsonScott Johnson
Definitely.  Do a Fast lookup on ARC-contacts, and then a record create to create the job invoices record.  

For each field in Job Invoices, select the varaible from the field in ARC-Contracts
Scott JohnsonScott Johnson
Here is a bit more detail.  Hope this helps!

1 - Create a variable called varARCContactID - make sure it is Input/Output
2 - Fast lookup on ARC-Contacts.  Lookup the record where ID = varARCContactID.  Name it varARCContacts
At the bottom - add each field you need to capture.  Title, number, account, etc...
3 - do a record create.
For each field in Job Invoices - click the drop down, and select Sobject Variable >> varARCContacts >> field you want to copy
4 - Cretae a confirmation screen.  Add some text  - something like "Your Invoice has been created"
Fourth - create a button that launches your flow.  Something like this
/flow/ARCContactFlow?varARCContactID={!ARC_Contact.Id} (this tells the flow the ID of the record in ARC-Contact
This was selected as the best answer
Jim StricklandJim Strickland
Thank you very much. I will try this first thing tomorrow, and let you know how it works.
Jim StricklandJim Strickland
When creating the Fast Lookup, I am asked to provide more information than what you are recommending. See below.
Fast Lookup Window

Where I was getting confused is unde Variable. It was asking me to create a new sObject variable. I did that, with the source being ARC_Contract__c. Is that correct?
Scott JohnsonScott Johnson
Yes.  Looks perfect.  Takes a while to get the hang of flow, but once you get past the lerning curve, it opens up a ton of possibilities
Jim StricklandJim Strickland
I feel like I am almost there. I do get an error that prevents the record from being created. Due to the way we use the same Job Invoices object to create invoice records for both Jobs and Contracts (two different custom objects in our org), I have to assign a job to every new record. For contracts, these always fall under the same job called Contracts - AR. How do I get the flow to find that job and put it in the new invoice record. Below is the error I get.

Flow Details
Flow Name: Create_New_Invoice
Type: Flow
Version: 1
Status: Inactive

Flow Interview Details
Interview Label: Create New Invoice 11/22/2017 9:28 AM
Current User: Jim Strickland (00580000002iAXJ)
Start time: 11/22/2017 9:28 AM
Duration: 0 seconds

How the Interview Started
Jim Strickland (00580000002iAXJ) started the flow interview.
Some of this flow's variables were set when the interview started.
varARCContractID = a0iC000000BXFpJ

FAST LOOKUP: varARCContractsLookup
Find all ARC_Contract__c records where:
Id Equals {!varARCContractID} (a0iC000000BXFpJ)
Assign those records to {!varARCContracts1}.
Save these field values in the variable: Name, Account_Name__c, Title__c, Opportunity_Type__c
Result
Successfully found records.

RECORD CREATE: newContractInvoice
Create one Job_Invoice__c record where:
Account__c = {!varARCContracts1.Account_Name__c} (0018000000b67FrAAI)
Contract_Title__c = {!varARCContracts1.Title__c} (Tbaytel CellMaps Renewal 2014)
Contract__c = {!varARCContracts1.Name} (C-0000003403)
Job__c = Contracts - AR
Result
Failed to create record.

Error Occurred: This error occurred when the flow tried to create records: MALFORMED_ID: Job: id value of incorrect type: Contracts - AR.
Scott JohnsonScott Johnson
You are close.  The issue is this:
Job__c = Contracts - AR

It looks like you are trying to populate "Contracts - AR" into the Job__c field.
Is that a text field?
Jim StricklandJim Strickland
I actually figured it out on my own. I did another fast lookup on Jobs_c for a record with the record ID matching that of the Contracts - AR job. Might have been overkill. I imaging I could have just hardcoded that record id in the Create Record flow element. Either way, it worked. Now I just have to do some cleanup on the closeout screen, and I am good.
Jim StricklandJim Strickland
I hope you are not finding me too bothersome. I actually have the flow working. I have a couple more elements to add, and am hoping you can provide guidance. Your help has been spot on.

1. Job Invoices has an Invoice Amount field and a Scheduled Invoice Date field. I would like to give the user the opportunity to fill these fields out manually during the flow process.

2. Since this button will be used from a related list inside of the ARC-Contract detail, is it possible to tell the flow to take the user back to the contract detail page when the flow is complete?
Scott JohnsonScott Johnson
Happy to help!

1. Add a screen.  Add input fields for the amount and date (you can also add display text to provide instruction).  In your record create - use the screen inout fields to populate the 2 fields in the Invoice

2. One of the most annoying things about flow is the inability to navigate to a record at the end.  There is a way to do it by embedding a flow in a VF page, but, that takes a bit more doing.  I often just add a screen at the end with text.  You can add hyperlinks.  Something like "Your invoice has been created" and add 2 hyperlinks:
Go to new invoice
Return to Contract

To add a hyperlink, you need to change to rich text, and there is a spot for hyperlink
User-added image
 
Jim StricklandJim Strickland
Thank you so much. I just implemented these last two things and they work perfectly. James Strickland Director | Systems & Physical Plant [cid:image001.png@01D363A8.AD6661E0] Mosaik Solutions T +1 (901) 377-8585 ext 5000 • F +1 (901) 377-8189 6423 Shelby View Drive, Suite 101 • Memphis TN 38134 Jim.Strickland@Mosaik.com | Mosaik.com | Facebook | Twitter | LinkedIn
Jim StricklandJim Strickland
Almost had it. The URL worked once. Then it reverted to sending the user to the home tab.
Scott JohnsonScott Johnson
Nice!   URL in the flow screen a a bit tricky.  It doesn't seem to always save
Here is an example of one I used.  Just use the relative URL, not the full path
/{!varQuoteID}

In your flow, you define a variable for the newly created record ID.  Just replace varQuoteID with your variable for the new record
Jim StricklandJim Strickland
Got it! I have tested with multiple records, and it works. It takes me to the contract detail in a new tab, but it works.