Maximo

 View Only
  • 1.  Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Wed December 06, 2023 07:55 AM
    Hello ,
    I am trying to develop a new page with in the Technician app, which displays the child Work of main work order(workorderdetails Page > child work page same as follow-up work page).In this new page I am using a data list to render all the child work.
    I've provided a chevron on the data-list ,when clicked user should navigate to a page which displays tasks of that particular child work .
    Here I have reference of woactivity (relationship Array) from Child Work Main page but I am not able to find a way to cast the same to a Datsource and pass to the new tasks page .
     
    Initially the thought was to navigate to the OOTB taskspage but I am not able to override the global woplantaskdetailds with the tasks from
    Child work.woactivity. OOTB woplantaskdetailds datasource is containing only the Workorderdetails(Main workorder) Tasks.
     
    Any suggestions here on the approach would be really helpful .
     
    Below is the reference of custom Datasources developed for the child work page:
     
    <maximo-datasource  id="workorderChildrenDS"  object-structure="mxapiwodetail"  item-url="{page.params.itemhref}">
    <schema id="xgddxc">
              <attribute id="y8wwqc" name="wonum" unique-id="true"/>
              <attribute id="p8y5pc" name="description"/>
              <attribute id="bj_dzc" name="workorderid"/>
              <attribute id="dd4d3c" name="siteid"/>
              <attribute id="ra7nwc" name="orgid"/>
            </schema>
    <maximo-datasource   id="showchildrenwo" id-attribute="workorderid" object-name="workorder" relationship="showchildren.mxapiwodetail" selection-mode="none">
    <schema id="nqagk1">
    <attribute id="chpba3qch1" name="workorderid" unique-id="true"/>
    <attribute id="chak5egch1" name="wonum"/>
    <attribute id="chekwkqch1" name="title"/>
    <attribute id="chrb8jach1" name="description"/>
    <attribute id="chwapd_xhch1" name="status"/>
    <attribute id="chg2ym6ch1" name="statusdate"/>
    <attribute id="chxbxwjxh1" name="siteid"/>
    <attribute id="chj9knnch1" name="worktype"/>
    <attribute id="chj9knnch1w" name="rel.woactivity{*}"/><!-- this is an array of tasks which should act as a datasource for another page-->
    <attribute id="chlead" name="lead"/>
    <attribute id="chasnum" name="assetnum" />
    <attribute id="chasset" name="asset">
    <attribute id="chasdes" name="description--assetdescription" />
    </attribute>
    </schema>
    </maximo-datasource>
    </maximo-datasource> 
    Thanks in Advance


    ------------------------------
    Meghana Siriveli
    ------------------------------


  • 2.  RE: Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Thu December 07, 2023 08:39 AM

    I'm not entirely sure how you're displaying the data but if you are trying to display all child WOs and all tasks of the WO on the same page, you would likely have a data-list of showchildrenwo and an additional data-list for the tasks. If that's the case, you can set the datasource to something like this:

    datasource="{showchildrenwo.getChildDatasource('woactivity', item)}"

    That should at least work for display purposes. I have not tried to use it for update purposes but I think that should work as well. 


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



  • 3.  RE: Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Thu December 07, 2023 09:34 AM

    Hello Steven,

    Thanks for the Response.

    I am trying to display all the child work orders in one page(similar to Schedule Page) and their respective tasks in a different page.

    I have found a different way to load the woactivity array into a datasource of tasks page using js code but I gave a try of getChildDatasource method also but somehow getting error as getChildDatasource is not a function of showchildrenwo datasource.

    Also I have observed that I am not able to access all the attributes of woactivity like description_longdescription  even though woactivity is defined to fetch all the attributes as name="rel.woactivity{*}" .

    Could you please help here.

    Thanks again !



    ------------------------------
    Meghana Siriveli
    ------------------------------



  • 4.  RE: Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Thu December 07, 2023 10:06 AM

    You never want to retrieve all attributes but certainly not on an object like WOACTIVITY where there are going to be literally hundreds of attributes. There's overhead in building that data (all the attribute initialize events will fire), downloading that data (a much larger dataset than the application needs), and memory utilization on the device to load that data into a datasource. 

    The REST API using the asterisks on a relationship does not seem it will retrieve non-persistent attributes on a persistent object. You have to define the specific attributes you want. Most non-persistent attributes on a persistent object are used for specific operations (such as supporting asset move/modify) so it would make sense to not fetch them. If you specifically call out description_longdescription, it will return in the select (provided that it is not null since we drop nulls by default to reduce the size of the payload). 



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



  • 5.  RE: Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Thu December 07, 2023 10:29 AM

    Yes, it worked if I specifically call out only required fields. Thanks Again!

    Could you please clarify one more doubt here.

    With respect to my child datasource of showchildrenwo , I had to define relationship as "showchildren.mxapiwodetail"  instead of "showchildren".

    With the latter approach, rel.woactivity on showchildrenwo was undefined ,but the other 1:1 relationships were working fine.

    Is it for Multi line relationships like woactivity , are we supposed to use <relationshioname.Objectstructurename>  or is there any other criteria?

    Thanks



    ------------------------------
    Meghana Siriveli
    ------------------------------



  • 6.  RE: Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Thu December 07, 2023 12:29 PM

    Without testing it I can't explain why but defining an object structure in the relationship shouldn't be required in this case. The use case of returning data using a specific object structure is to handle processing rules that may be set on the object structure.

    For clarity though, it is possible woactivity is null on either approach because we drop nulls in the REST API and it is not a requirement that a task has to exist on a WO. The getChildDatasource works whether it exists in the data or not. 



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



  • 7.  RE: Maximo Mobile: How to convert/cast an Array into a datasource so that it can be used as of main ds for a different page.

    Posted Fri December 08, 2023 06:25 AM

    Hello Steven,

    woactivity was not null but I was able to access it only if object structure was defined in the relationship.

    May I know if there is a way to reload the OOTB woPlanTaskDetailds with the woactivity from the showchildren records?

    I have tried using ds.load() method as below:

    let woDetailDS = this.app.findDatasource('woDetailds');
    await woDetailDS.load({ noCache: true,itemUrl: workorder.href,wonum :workorder.wonum});
    let woTasks=this.app.findDatasource('woPlanTaskDetailds');
    await woTasks.load({ noCache: true,itemUrl: workorder.href,parent :workorder.wonum});
    but the load is working perfectly fine in the preview mode and on RBA but not on the Device.
    I have to navigate the user to the tasks page for each child item in the datalist  and I want to make use of existing tasks page and the datasources so that there won't be any redudant code .
    Any pointers would be really helpful.
    Thanks


    ------------------------------
    Meghana Siriveli
    ------------------------------