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
------------------------------
Original Message:
Sent: Fri August 04, 2023 04:43 AM
From: Vincent Wanders
Subject: MAF Mobile - Simple javacustomizations.js examples for customization
I am looking for a simple "Hello world" sample to set the Description of the workorder to "Hello World" through the button and with the use of a AppCustomizations.js

What I am looking for is the equivalent of mbo.setValue("DESCRIPTION","Hello World")
I managed to create an alert("Hello world").
async helloWorld(event){
alert("Hello " + event.item);
}
For me this is the next step. Altering a textfield by using Javascript (i tried already a lot by using the Maximo Mobile source files).
Just a simple example will do.
Thnx!
------------------------------
Vincent Wanders
------------------------------