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
Hello, it works but if I want to use this code in open form as button, message is pushed but I cant save other changes I did in that form. It pops up message that form has been changed by another user. Any ideas?
Hi,
yes, this message is displayed because an email other than currentUser is inserted in the Chat field, so the form will evaluate that the form has been changed by another user. I would try using refresh page (F5). If the information reappears, we’ll discuss at the meet with my colleagues from development team how we can fix it, if at all.
Regards,
Filip