Closed kvecc closed 2 months ago
@kvecc Check you payload to make sure that you have collection_status
and collection_interval
. If they are undefined or equal to 0, because of the if statement, they may not be a part of the payload.
console.error(payload);
I believe the error means that one of those variables was not replaced correctly from the payload.
@mikhail-vl my collection_status variable returns a 1 or 0, does this mean it will not register the variable if it is supposed to be returning a 0? Also, I have my two elements tied to values from my initial query, if I do not change one of the elements, will it still return the default value populated by my initial query?
@kvecc Remove the if
statement from the payload to set values in any case.
Yes, payload will have values for all the elements based on the code.
@mikhail-vl I tried removing the if statement, but I'm still getting the same error
@kvecc please replace single quotes to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
from
rawSql: '${payload.collection_status}'
to
rawSql: `${payload.collection_status}`
Please let us know if there is anything else or if it doesn't work for you
@asimonok I tried the following two pieces of code and got the corresponding errors
1)
2)
@kvecc the first option is valid. You should wrap string values into single quotes VALUES (${payload.collection_status}, '${payload.collection_interval}')
@asimonok when I try to format my code like that, it gives me formatting errors
@kvecc the closing bracket }
for first parameter is missing.
correct version
`INSERT INTO data_collection_status (collection_status, data_interval) VALUES (${payload.collection_status}, '${payload.collection_interval}')`
@asimonok thank you for pointing that out, didn't realize I had deleted that closing bracket, that correction has fixed my issue and I was able to successfully insert data back into my MSSQL database, thanks again for your help!
@kvecc Thank you for confirming. We updated blog posts accordingly.
I am using Azure Managed Grafana, and it is connected to my MSSQL database. I am able to query it to populate elements on my form, but I haven't been able to send data back to it using the Datasource option for the Update Request. It is a very simple form only sending two pieces of information, so I was hoping I could avoid having to create an API for my database.
My Update code is shown below:
This is the error message I get when trying to submit my form data: