hi,
i need help to get the name of column, which i am manipulating. is it possible to get it?
you can see related area in the pic.
i need that key, not value.
hi,
i need help to get the name of column, which i am manipulating. is it possible to get it?
you can see related area in the pic.
i need that key, not value.
Can you use the lodash keys method?
_.keys(changesetObject[1])
'{{table1.changesetArray[0].keys(changesetObject[1])}}'
that does not work.
i can get it but staticly like
'{{table1.selectedCell.columnId}}'
i am trying to catch the changes and push it into my audit table. like
INSERT INTO mr_audit_log_retool (entity_id, table_name, field_name, previous_value, new_value)
VALUES
('{{table1.changesetArray[0].buchungId}}', '{{mr_bookings.id}}', '{{table1.selectedCell.columnId}}'
, '{{table1.selectedCell.value}}', '{{table1.changesetObject[1].buchungEnde}}');
but there are some handicaps. that does not have a dynamic structure
That isn't how to use the lodash function though:
I think when you get the right column name out of the changesetArray with
_.keys(table1.changesetArray[0])
you'll get more traction with the SQL statement.
(eta: fixed the missing [0] in the changesetArray)
I also wanted to add an example of the loop you can use for the changesetArray:
This way you can make sure to grab all the changes from any column that require further processing
@pyrrho i meant, i need to loop sql query
for example i have table1, it has 3 columns. if user changes every cell under that columns, changesetObject can catch them, and if i loop that object for everychanges and integrate it with my sql query, then i can insert everychanges into my another table. i mean i want to run mysql query based on the size of changesetObject and for each loop i want to inject next value of changesetOject. here is MySqlQuery.
INSERT INTO mr_audit_log_retool (entity_id,
table_name,
field_name,
previous_value,
new_value,
retool_user)
VALUES
('{{table1.changesetArray[0].buchungId}}',
'{{mr_bookings.id}}',
'{{Object.keys(table1.changesetObject[1])[0]}}',
'{{MyJavaScriptQuery.data.find(
x=>x.buchungId === table1.changesetArray[0].buchungId)[Object.keys(table1.changesetObject[1])[0]]}}',
'{{table1.changesetObject[1].buchungEnde}}',
{{current_user.id}});
but MyJavaScriptQuery.data does not return anything.
and here is MyJavaScriptQuery
let obj= table1.changesetObject[1];
const orgs = await new Promise((resolve) => {
MySqlQuery.trigger({
additionalScope: {
field_name: Object.keys(table1.changesetObject[1])[0]
},
onSuccess: (data) => {
resolve(data);
},
});
});
return orgs;
but MyJavaScriptQuery.data does not return anything