Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  MAF Mobile - Simple javacustomizations.js examples for customization

    Posted Fri August 04, 2023 04:43 AM
    Edited by Vincent Wanders Fri August 04, 2023 04:47 AM

    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
    ------------------------------



  • 2.  RE: MAF Mobile - Simple javacustomizations.js examples for customization

    Posted Fri August 04, 2023 08:21 AM

    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
    ------------------------------



  • 3.  RE: MAF Mobile - Simple javacustomizations.js examples for customization

    Posted Fri August 04, 2023 01:35 PM

    Thanks! This is what I was looking for. 
    Both examples work like a charm.

    I will also look into the document (after my holidays). 
    Again, many thanks!

    Have a nice weekend.



    ------------------------------
    Vincent Wanders
    ------------------------------