Maximo Open Forum

 View Only
  • 1.  Debugging MAF variables

    Posted 13 days ago

    Hello everyone! 

    I am very new to graphite / carbon and it's configuration, so I apologize for any wrong terminology I use.

    I've been trying to tinker with the Self Serve application by adding custom made surveys to each ticket. After a lot of trial and errors, I figured out how to create datasources through object structures as well as getting related objects through inline multi-record relationships (which I am 80% sure could be done in a better way once I understand datasources better).

    What I am finding difficult is navigating through (what I presume is) the runtime objects (app, page, datasources, their child objects, etc...). I know how to debut the UI elements through my browser's inspect, but I can not tackle debugging these objects. I am guessing these are not sent to the client and remain server sided? I've skimmed through the documentation and the architecture and I am guessing these can be somehow accessed in the container MAF is running on. Has anyone figured out how to reach these runtime objects?


    #MaximoApplicationSuite

    ------------------------------
    Khalid Tarek
    MegaSoft
    ------------------------------


  • 2.  RE: Debugging MAF variables

    Posted 12 days ago

    These are all client-side objects built in React. If you install the React Developer Tools extension in your browser you'll be able to inspect these better when you're in the MAF configuration. I will caution you, however, that JavaScript is not like Java and there is no way for IBM to declare public/private methods. This means you can access & utilize anything, but the IBM team only intends you to utilize certain APIs. 

    For example, you'll see code out of the box like:

    let locationWorkOrderList = this.page.datasources['locationWorkOrderList'];

    But if you read the developer documentation (wiki embedded in the Configuration utility available in the help menu), it's made clear that you should always use 
    this.app.findDatasource('completedCloseDS') instead. Accessing the datasources the other way is not the supported way and could be broken in a future patch.


    I recommend sticking to what you see in the developer documentation and in the component documentation. Most use cases are similar in concept, and you'll be able to find examples that help show you what you need to do. If you don't see it in the documentation and see it in the react dev tools, you can technically use it, just be aware that it might not be supported and breaking changes could be introduced at any time. Or it might not behave as you expect in certain situations. 


    ------------------------------
    Steven Shull
    Naviam
    ------------------------------



  • 3.  RE: Debugging MAF variables

    Posted 12 days ago

    Nice post, Steven.

    Hopefully in the next patch the hard coded limited upload of an entire cloned archive (.zip) is removed. In the current 9.1.5 it is only allowed to upload a .zip file smaller than 500kb. We have tweaked the entire Health (RELENGINEER) app for a Belgium customer, but we can't upload it in the migrated V9.1.5 version because of this hard coded limitation.




    ------------------------------
    Jan-Willem Steur
    Naviam
    ------------------------------



  • 4.  RE: Debugging MAF variables

    Posted 11 days ago

    Thanks a ton for your insight, Mr. Steven.

    I did jump to the React Developer Tools extension as a first resort, but for some reason, it wasn't detecting that the MAF preview was using React. I will try my luck again with it. That being said, I did find another (and perhaps convoluted) way to debug through the following document shard on techXchange:
    https://community.ibm.com/community/user/viewdocument/amug-event-maximo-application-fram?CommunityKey=af2335d3-5043-4063-8509-018adc3ba1d9&tab=librarydocuments

    On page 32, you can see how they use breakpoints in AppCustomization.js to view the current state of variables. This, albeit a bit too complicated and not user-friendly, was quite insightful. That being said, what I was looking for didn't seem to be there (I was looking to see what the {item} object contained), but I can see this being a very useful tool, especially with debugging datasources and making sure I am retrieving the right data and the right structure for it.

    I was under the impression that I could find the "item" variable used in components like <data-list><repeat>, or such, but it seems to be something akin to the binding values used in Maximo, like:&DATETIME& or :&PERSONID&. There are published exhaustive guides for Maximo, but I haven't found any for MAF yet, other than the occasional small list of app, eventManager, page. I did somehow find that I can use the binding value {index}, which can be used in <data-list><repeat>, or similar components.

    Either way, thanks again for your reply, and I am definitely not planning on diverting from the best practices, only gaining better understanding of how graphite works.



    ------------------------------
    Khalid Tarek
    MegaSoft
    ------------------------------



  • 5.  RE: Debugging MAF variables

    Posted 11 days ago

    It's not clear from your message if you're running 9.1 (where the MAF configuration is embedded in the application) or 9.0 or earlier (where you run the MAF configuration on your local desktop). I'm assuming you're running 9.0 or earlier and if so, there are different command line arguments you provide to the container. One of the parameters that was recommended at one point was to indicate whether it was a production build which helped reduce the zip size when it was built and uploaded to the server. This stopped being necessary, but you might still have the argument indicating it and it might break the ability to debug if you have it since it changes how the app is built. Otherwise, it should work in the preview in the MAF configuration (not in the web version of Maximo since that is a production react build). I've used the React Developer Tools extension across many releases (except 9.1 due to other problems)

    There are pieces of an item record that are consistent for the framework (like item.href) but it's mainly to represent a single record in the datasource so most of what you interact with will be specific to the datasource that you're interacting with. You'll access the attributes you've defined in the schema like item.wonum or item.description. Attributes that exist in Maximo but are not part of the schema would not be accessible. For example, if you didn't declare description_longdescription in the schema, you would not be able to access it as item.description_longdescription. There are a few special values like status_description or status_maxvalue (attributes that are tied to a domain have some special logic the REST API populates) but it's otherwise really the schema as you've declared. If you alias an attribute (IE asset.description--assetdesc) then you would access it as the alias (IE item.assetdesc). If you have a one to many dataset inside the schema, you can get a child datasource of that programmatically or you can declare the maximo-datasource inside your maximo-datasource to have the framework do it for you.

    I have never found a reason to use repeat, but you will use data-list extensively. 



    ------------------------------
    Steven Shull
    Naviam
    ------------------------------



  • 6.  RE: Debugging MAF variables

    Posted 11 days ago

    I am currently running 9.0.0. I have tried using 9.1.0, just for the sake of knowing how to set it up in a MAS workspace, but I have noticed that it had a lot of issues, including but not limited to the preview feature as well as the hierarchy/properties on the left. For now, I prefer 9.0.0 for its stability. I am not sure about the build command. I will look into it and check whether it is a production build, and hence, it disables react debugging. This helps a lot, Thank you!

    Thank you for the tips regarding the alias. I understand the part about the schema, though I am curious about these things that are consistent for the framework. I am finding it difficult to find documentation for that. Additionally, I did see the ability to embed a maximo-datasource inside another maximo-datasource using a relationship defined in the object structure, though I failed to be able to access it elsewhere. I noticed from network requests that they do appear in the response, but I was not able to find a way to access them. I vaguely remember seeing something mentioning a function like datasource.getChildDataSource() and setting it up in AppCustomization.js, but I was curious if I could retrieve that datasource directly in the UI without JS customization logic.



    ------------------------------
    Khalid Tarek
    MegaSoft
    ------------------------------



  • 7.  RE: Debugging MAF variables

    Posted 10 days ago

    In TECHMOBILE (which is the most complex app so it has the best examples), you can see the datasource woPlanTaskDetailds. This is defined as a child datasource inside of the woDetailds datasource. That then gets accessed and displayed directly in a data-list without needing to populate it using javascript.

    Though as you mentioned, JavaScript is possible. You'll see when we display attachments for the task they programmatically create a child datasource using syntax like:

    datasource="{woPlanTaskDetailds.getChildDatasource('doclinks', item, {query: {attachment: true}})}"

    That says for the current item, get the doclinks array inside the item and create it as a unique child datasource. The query attachment true stuff is a special flag because the datasource is intended to be used for attachments. Without that, if you use a custom relationship for DOCLINKS (IE instead of DOCLINKS you use MOBILEDOCLINKS), then it would break. 


    Regarding the child datasource not being accessible, datasources can be page or app scoped. Most datasources in the out of the box applications are page scoped which means they can only be accessed inside that specific page. Work Order details launches into several distinct pages (tasks, report actuals, etc.) and you'll see that they define the maximo-datasource for the work order fields and all the child datasources needed for the page on each page. 

    You also can't load a child datasource prior to the parent datasource loading. There were a lot of things that have changed over time and I can't remember the final state of things before I left. But there were flags on the maximo-datasource like notify-when-parent-loads="true" which would trigger the child datasource to load when the parent loads. There is can-load which allows you to prevent the datasource from loading too early by checking some condition prior to loading. And there is a depends-on attribute but I believe this is fully redundant now and isn't needed on child datasources to indicate that it's dependent on the parent datasource. 


    ------------------------------
    Steven Shull
    Naviam
    ------------------------------