Hi Vincent,
There can be few ways to do it. Because of that I suggest you to check MAF_Development_Information.docx chapters: State, Datasource Overview and also review code that was done by IBM (for example WorkOrderCreateController:createWorkorder()).
I think one of the way to solve your requirement can be like this:
app.xml
<button slot="buttons" label="Update Description" on-click="updateDesc" id="test"/>
AppCustomizations.js
async updateDesc() {
let dsCreateWo = this.app.findDatasource("dsCreateWo");
if(dsCreateWo) {
dsCreateWo.item["description"] = "Hello World";
}
}
Another solution is to use on-click-arg
app.xml
<button slot="buttons" label="Update Description" on-click="updateDesc" on-click-arg="{{'item':dsCreateWo.item,'datasource':dsCreateWo,'page':page,'app':app}}" id="test"/>
AppCustomizations.js
async updateDesc(evt) {
let workorder = evt.item;
if(workorder) {
workorder["description"] = "Hello World";
}
}
Good luck!
------------------------------
Bartosz Marchewka
------------------------------