Get rid of the id =
part of the query - it should be formatted with just commas like the rest.
1 Like
Well, when it's created it duplicates another ID. So I was trying to make it where it adds a new ID.
Unfortunately, the SQL syntax does not support it that way.
If id is an autoincrement, you do not need to include id
in the field list at all. Remove from both sides and you are good. Retool will return the id
of the added record in the query's data
field.
If not an autoincrement. do you have control of the backend? If so, make it an autoincrement field.
Otherwise, you will need to figure out what the next id
value would be, add 1 and send that as the id
like so:
// leadCount_query
Select max(id) as maxID from myTable
// insertLeadQuery
leadCount_query.trigger({
onSuccess:function(data) {
leadInsert.trigger({
additionalScope: {
newID: data.maxID + 1
}
})
}
// newLead
INSERT INTO
cc_leads (
...
) VALUES (
...
{{new_contact_form.data.newLEadLead_Status}},
{{newID}}
)