Maximo

 View Only
  • 1.  Maximo Mobile set datasource fields via customization

    Posted 28 days ago

    Hi there.

    in my TECHMOBILE app I've "extended" the MXAPIWODETAIL in order to include a custom table.
    Now I'm trying to create a slide in the app mobile to create a new record in that table. 
    The issue here is that I want to set an attribute of the datasource that is shown in the custom Drawer equal to the wonum of the woactivity.

    This is the code that is evoked pressing the "open drawer" button:

      async showcustomMbo(evt) { 
        let dscustMbo = evt.page.getDatasource['cMboDs'];
        let wo = evt.page.datasources['woPlanTaskDetailds'];
        dscustMbo.item['record'] = '';
        dscustMbo.item['wonum']=wo.item.wonum
        this.page.showDialog('customDrawer');
      }
    I want the attribute "record" to be set to null as well when opening the dialog. But what I wrote seems not to be working.
    Thank you for you help.


    ------------------------------
    Alessandro Di Maggio
    ------------------------------


  • 2.  RE: Maximo Mobile set datasource fields via customization

    Posted 27 days ago

    You mention that this is a custom table but it's not clear to me if this is a 1:1 to WO/task (like service address) or 1:many (like actual materials) where you may need a new record to be added. If you are creating a new record in your child object, make sure you have ANYWHEREREFID on the object and on the datasource. This helps ensure that we can map the record created on the device with a response from the server. And then you would call .addNew() on the datasource like:

    let item=await dscustMbo.addNew();
    item.record="";

    In addition, the woPlanTaskDetailds is going to have an array of tasks but you'll be grabbing a random one when you go back to the datasource. You'll need to pass in the specific task to the showcustomMbo event. I assume this is an on-click so you'd need to have something like:

    on-click-arg="{{'item': woPlanTaskDetailds.item}}"

    You should also never access datasources using the page. You should always access it from the app like:

    laborDs=this.app.findDatasource("woLaborDetailds");

    Whether the datasource is page or app scoped, this works. Being consistent alone is a good reason to use this approach. JavaScript makes it impossible to prevent customers from using unsupported APIs which is why you can do it but the page.datasources approach is not an intended API for customers to use. This is something we may break at any point in the future. 


    ------------------------------
    Steven Shull
    ------------------------------