Maximo

Maximo-ICON.png

Maximo

Learn how to increase the operational efficiency of the assets you manage, and improve overall equipment effectiveness by using IoT data and AI.

Maximo-ICON.png

TRIRIGA

Reduce the operational costs of the facilities you manage, and create more engaging occupant experiences through the application of IoT data and AI.

Maximo-ICON.png

Engineering

Learn how IoT data and AI are being applied to transform the end-to-end engineering lifecycle.

Expand all | Collapse all

Create a LastSuccessfulSyncDate field in a cron task?

  • 1.  Create a LastSuccessfulSyncDate field in a cron task?

    Posted Sun August 23, 2020 12:45 AM
    Edited by User1971 Tue September 01, 2020 06:35 PM

    Question:

    Is there a way to populate a LastSuccessfulSyncDate field in cron tasks?



    Details:

    I have a Maximo cron task that syncs records from an external system's web service to the ASSET table in Maximo.

    In order for the cron task to determine which records need syncing, IBM has suggested that we do the following in the HTTP request URL: 

     - Add a parameter that uses the LastRunTime field in the cron task and compare it to the last_edited_date field in the records in the external system.
     - The parameter in the URL would be: where = last_edited_date >: lastruntime



    To be honest, the idea of basing the sync logic on the LastRunTime field in the cron task seems dangerous to me.
    We determined in a related post that there are several scenarios where a cron task can run, but not actually sync properly. So if the cron task runs, but doesn't actually sync anything, then the records from the external system would fail to sync—and not be caught in subsequent syncs—which would be a big problem.


    I think I would rather base the sync logic on something more robust.
     - For example, if there was a LastSuccessfulSyncDate field in the cron task, then I'd use that field in the sync logic: where = last_edited_date >: LastSuccessfulSyncDate

    Is there a way to populate a LastSuccessfulSyncDate field in cron tasks?

    Or does anyone have any better ideas for the sync logic/WHERE clause?


  • 2.  RE: Create a LastSuccessfulSyncDate field in a cron task?

    Posted Mon August 24, 2020 08:25 AM
    You could probably backend SQL a new cron task parameter without issue to store the value (or put it somewhere else if desired). The challenge for me is how you plan to record a successful execution. I don't know a lot about the ArcGIS cron task, but thinking about others (like reorder/PM WOGEN), there could be errors in the process without the cron task failing. I'm not sure how even if you extend their java class to know that some error wasn't suppressed that you need to know about. I think this is something the Spatial team would have to implement, and makes sense to me for them to implement. Delta syncs are good for both sides of the integration.

    I also 100% agree with your assessment that last run time is not a reliable metric for something like this. If connectivity failed for example (bad username/password, site down, etc.), the cron task would still record that it ran.

    ------------------------------
    Steven Shull
    Director of Development
    Projetech Inc
    Cincinnati OH
    ------------------------------



  • 3.  RE: Create a LastSuccessfulSyncDate field in a cron task?

    Posted Mon August 24, 2020 12:56 PM
    Edited by User1971 Tue September 01, 2020 06:42 PM

    Yes, I agree.

    Someone suggested that I store the dates in the asset records instead. "If you add new Assets, you want to know if the individual record has been updated or not. Have the synchronization update the current date into that field."

    I really like this idea, and I was actually doing this originally.


    In the Maximo ASSET table, I created a field called LastSyncDate, and populated it automatically (using the current date) via the JSON mapping, whenever the record got synced. https://stackoverflow.com/a/58122864/10936066

    In the external system, I used a dblink (in the Maximo db) and joined from the external system's table -to- the Maximo ASSET table. So in the external system, I had access to the last_edited_date field -and- the Maximo LastSyncDate field.


    So in the external system, in the view/web service that I use to serve up records to the Maximo cron task, I was able to create a SYNC_NEEDED column:

    case
        
    when gis.last_edited_date > maximo_asset.lastsyncdate or maximo_asset.lastsyncdate is null  then 1
        else 0
    end as sync_needed


    That seemed to work quite well. I could determine what records needed to be synced just by comparing the dates in the records (between the two tables).

    However, my technical experts hoped there might be a way to do the syncs without the dblink.
     - There is a dblink for each of our environments (sandbox, dev, test, prod, etc.).
     - And there are several views on the Maximo side  —and—  several views on the external system side...for each of the tables that are synced (assets, locations, service addresses).

    So it was making things complicated from an administrative standpoint.

    But I think the safest way is just to compare the dates on a record-to-record basis (via the dblink). And not use a broad/risky approach like LastRunTime or LastSuccessfulSync.




  • 4.  RE: Create a LastSuccessfulSyncDate field in a cron task?

    Posted Mon August 24, 2020 05:32 PM
    Can you make your cron task use the max(Asset.LastSyncDate)?

    ------------------------------
    Blessings,
    Jason Uppenborn
    Sr. Technical Maximo Consultant
    Ontracks Consulting
    ------------------------------



  • 5.  RE: Create a LastSuccessfulSyncDate field in a cron task?

    Posted Tue September 01, 2020 06:50 PM

    Thanks, Jason.

    Regarding your message:

    "You haven't stated whether your cron task is some OOTB one or a script one. I have assumed a script one. In which case you can just query for the asset with the greatest LastSyncDate and get its sync date and use that to query your ArcGIS REST API. Otherwise, you could save it in a MaxVar or in Cron Task Properties. I feel like you have tons of options if the cron task is your own code."


    I'm actually not using a script-based cron task. I'm using the OOB Spatial ArcGISDataSync cron task:
    https://www.ibm.com/support/knowledgecenter/SSG2D3_7.6.1/com.ibm.spl.doc/configure/t_configure_cron_synch.html

    So, I guess that limits my options.

    Thanks again for your input.




  • 6.  RE: Create a LastSuccessfulSyncDate field in a cron task?

    Posted Tue August 25, 2020 10:49 AM
    Can you send lastsyncdate back to the feature record in GIS using the Response JSON mapping and use that in your Cron Task URL for the query on feature services? In the most recent release of Maximo Spatial, IBM discontinued support of DB Links.

    ------------------------------
    Lacey Radabaugh
    Client Technical Professional
    IBM
    ------------------------------



  • 7.  RE: Create a LastSuccessfulSyncDate field in a cron task?

    Posted Wed September 02, 2020 05:15 PM
    Edited by User1971 Wed September 16, 2020 02:56 PM