Form Dropdown list with value different from name

Hello everyone,
I just want to know if it’s possible in a Form node to display a text into the dropdown list and a different value like an id in the value returned.
For example i have two arrays: one with the name of companies and the second one with their ids.

Tried this but not working:

I want the dropdown list displaying the name and returning to the form the id.

I can figure out how ti do that.
First form “ID Form1” is working but returning the company name, the second one don’t work.

Hope someone can help me.

I recommend that after data capture, where sensitive data is captured from predefined values ​​such as dropmenu, you create node code with the following logic:

// Input: { company: "Company A", ...other fields }
const input = $json;

const companyMap = {
"Company A": "12345",
"Company B": "67890",
"Company C": "99999"
};

// Map the name to the ID
const companyId = companyMap[input.company] || "unknown";

return [
{
json: {
...input,
companyId: companyId,
}
}
];

This is because n8n currently does not allow you to define an independent label/value pair directly in the Form node’s visual editor. What you define as an option is displayed and returned with that same text. Only a simple options field with a list of strings that act as both label and value is supported.

2 Likes

Thanks Erick for your help.
I’m not a developer, i was not aware that n8n form doesn’t handle separate label and value.
Maybe i can post a feature request for that !
With your mechanic i was able to handle my process.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.