Hi there,
I wonder if I can add some text to chat field by using some script?
Thanks.
Hi there,
I wonder if I can add some text to chat field by using some script?
Thanks.
Hello, Thomas,
yes, you can use console.log to write out the object and then you can write JS according to it.
Have a nice day.
With kind regards,
Soňa
Thank you. Well I am not sure how to proceed…
Hello Thomas,
if you press F12, you can see what you can use for JS. I also send you this JS:
const existingRecord = await doo.table.getRecord('table1', doo.model.id);
const fields = {
chatTest: {
"lastChange": new Date().toISOString().substring(0, 20),
"messages": []
}
};
if (existingRecord.data.fields.chatTest?.messages) {
fields.chatTest.messages = existingRecord.data.fields.chatTest.messages;
}
const message = {
"author": "emailname@gmail.com",
"authorName": "emailname@gmail.com",
"created": new Date().toISOString().substring(0, 20),
"text": "Text 1"
};
fields.chatTest.messages.push(message);
const x = await doo.table.updateFields('table1', doo.model.id, fields);
console.log('', x);
I hope that helped
With kind regards,
Soňa