Reversed Mapped Values for Insert into Database

Not sure the best way to go about this. I have a table of data from a postgres query, with one column i'm running a mapped value on, since i have employee IDs assigned to their name:

{{ item === 1 ? "Mikey" : item === 2 ? "Terry" : item === 3 ? "Gip"  :  "Nobody" }} 

When trying to run an insert query to another table, i get an error because employee_id is being entered as "Mikey" when it should just be 1.
(invalid input syntax for type integer: "Mikey")

request_id: {{ requestToCloseTable.selectedRow.request_id }},
employee_id: {{requestToCloseTable.selectedRow.assigned_to}}

So i guess i need to reverse the mapped value somehow, should i use a transformer or javascript query? Not really sure. I'll end up having about 10 employee IDs and Names and it's something I'd reuse quit a bit in my app.

How is the table constructed?
If employee name is in one column and employee ID is in another, what are you trying to accomplish? Can you post some screenshots?

This is the data coming into my table for the assigned_to column:

Then i have another query triggered on click to insert data to another table, while using selectedRow data from the requestToCloseTable:

Employee ID is the value i'm having trouble with, instead of it being the name, i need it to be the ID number when doing the insert query.

assigned_to is the employee ID? If so don't map it. Add a Custom column and set Mapped value of the custom column to

{{ === 1?'Mikey': === 2 ?'Terry' === 3?'Gip' === 4 ?'Ricky' === 5 ?'Carrie' === 6 ?'Jane' === 7 ?'Bill' === 8 ?'Justin' === 9 ?'Someone here' === 10 ?'Someone else':''}}

Assuming assigned_to is a number - if it isn't use single quotes around the id (replace id above with assigned_to

I added a custom column (col13) that uses the mapping you suggested, which works for what's displayed in the column.

I still have the issue in the insert query, where that custom column is still the value of the person's name, instead of the id number.

Sorry if i'm missing something.

{{requestToCloseTable.selectedRow.assigned_to}} Since assigned_to is the column with the ID

1 Like

Thank you for the full follow through on that, exactly what i needed!