[SalesForce] Flow not creating a new record

I'm relatively new to Salesforce development.

Right now, I'm making a voting app that contains two objects; a contestant object and a vote object. Each object has the following fields:

Contestant: Contestant Name – Text(80), Vote Count – Roll-Up Summary (COUNT Vote)

Vote: Contestant, – Master-Detail(Contestant), Vote Name – Text(80)

Both include a 'Created By' and 'Last Modified By' field as well. Here, when I create a vote (after creating contestants), the vote count for that contestant will increase by one successfully.

I've created 6 sample contestants, and I want the user to cast their votes through a survey flow. In this flow, the user is directed to a survey in which they are asked to put their name in as well as their vote, both in text boxes (in which they will type the EXACT NAME of the contestant; I have done this with radio options and this didn't work). Then a new vote record gets created in which the inputs the user puts in will be the values of the fields, as shown below:

enter image description here

The flow has three different segments; the first one which is a screen that asks for the user's name (VoterName), and the contestant they are voting for (Contestants), the record creation and a 'goodbye' screen.

However, when I try to run this flow, I keep getting this error by the time I fill in my information in the first two screens:

Error element Cast_Vote (FlowRecordCreate).
This error occurred when the flow tried to create records: MALFORMED_ID: Contestant: id value of incorrect type: Whatever the user fills out for the first screen. For details, see API Exceptions.

I'm thinking the reason for this is because Contestant__c is a master-detail data type, and it's already taking in a text type and there's a conflict there. Which is weird, because shouldn't it transfer over to the actual Contestant Object, and insert it as a name which is already a text type?

Best Answer

The master-detail field Contestant__c accepts an input type of ID. I think you are giving it an input of "Contestent 1" when it is looking for something more like "0030B0000280tRq".

To get the id you can do one of two things:

  1. Create a Lookup Record element. Have it lookup the contestant were the name equals the text they input. Then you can save the Contestant ID as a variable.
  2. If the records already exist, you might try using a radio choice with a dynamic choice for options. You can make the flow dynamically display the contestants based on whatever criteria you want (like an Active checkbox you control on the record). Then when they select someone you can save the Contestant ID.

If you want to link the contestant AND the voter, you can duplicate this as well.

Related Topic