Maximo

Maximo

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

 View Only
  • 1.  Maximo Anywhere formatting validation

    Posted Tue August 25, 2020 09:19 AM
    Hi, Has anyone added some field formatting validation to a Maximo Anywhere field.

    We need to add a formatting check to an asset attribute field contains a valid IP Address.

    We have added a new assetattribute datatype of IPADDR which is a synonym of ALN for us to use to identify when to check the formatting but cannot see where to add the js code to perform the validation.

    We want to implement this on the AssetDataManager application as a starting point.

    Any help will be appreciated

    regards
    Steve

    ------------------------------
    Steve Lee
    Maximo Technical Sales Specialist
    IBM
    Leeds
    ------------------------------



    #Maximo
    #MaximoAnywhere
    #AssetandFacilitiesManagement


  • 2.  RE: Maximo Anywhere formatting validation

    Posted Wed August 26, 2020 07:57 AM
    I think based on your question it's more how to invoke your logic on an asset spec being set rather than how to validate that it is an IP address. If you can do it on the Maximo side (with an inbound object structure processing automation script) it would be easier to maintain but you wouldn't have offline support and the user gets stuck typically undoing changes which isn't great. 

    I haven't tried to do this personally, but taking a quick glance I don't see why this wouldn't work. If you modify the text item with the id id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_uivalue", you can expand it to provide an event handler to call your custom logic. For example:

    <text editable="true" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_uivalue" label="Value" layoutInsertAt="val2" resourceAttribute="uivalue">
    <eventHandlers id="EMXAssetDataManager.SpecificationsView_listItemTemplate_groupitem_uivalue_eventHandlers">
    <eventHandler class="custom.handlers.EMXDataManagerHandler" event="validate" id="EMXAssetDataManager.SpecificationsView_listItemTemplate_groupitem_uivalue_eventHandlers_validate" method="validateSpec"/>
    </eventHandlers>
    </text>

    Then if in the custom/handlers folder you created a custom handler (if you copy above it would be EMXDataManagerHandler) with a validateSpec function, your logic would fire as users change it. You would have to analyze the spec to ensure it's one that you should be handling, and make sure to reference the uivalue attribute (not alnvalue) when doing your validation.

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



  • 3.  RE: Maximo Anywhere formatting validation

    Posted Wed August 26, 2020 08:17 AM
    Thanks Steven,

    We had done this on the server side using an automation script as you suggested already but like you say this can become difficult for the users to correct errors that are returned.

    In your example it seems that the AssetDataManager.SpecificationsView_listItemTemplate_groupitem_uivalue is no longer used in Anywhere 7.6.4 as this line is commented out and replaced with the following section:

    <list attribute="assetSpec" displayPageSize="25" id="AssetDataManager.SpecificationsView_asset_groupitem_assetSpec_list" label="Specifications" resource="asset" mixinclass="SpecificationStoreList"> <!-- <listItemTemplate id="AssetDataManager.SpecificationsView_listItemTemplate" layout="ViewSpecs"> <text editable="false" cssClass="editableLabel" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_assetattrid" layoutInsertAt="item1" resourceAttribute="assetattrid"/> <text editable="false" cssClass="editableLabel" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_description" layoutInsertAt="desc1" resourceAttribute="description"/> <text editable="true" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_uivalue" layoutInsertAt="val2" label="Value" resourceAttribute="uivalue"/> <text editable="true" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_measureunitid" layoutInsertAt="uom2" resourceAttribute="measureunitid" label="Unit of Measure" lookup="AssetDataManager.MeasureUnitAttributeLookup" lookupAttribute="measureunitid"/> </listItemTemplate> --> <listItemTemplate id="AssetDataManager.SpecificationsView_listItemTemplate"> <listtext cssClass="specLayoutLeft editableLabel" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_assetattrid" resourceAttribute="assetattrid" showreqattribute="mandatory"/> <listtext cssClass="specLayoutRight editableLabel" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_description" resourceAttribute="description"/> <listtext cssClass="specLayoutLeftReset editableLabel" hideEmpty="true" id="AssetDataManager.SpecificationsView_listItemTemplate_groupitem_measureunitid" resourceAttribute="measureunitid" /> </listItemTemplate>

    So it appears that it is now handles in the platform.ui.widget.SpecificationMixin.js script.
    We already had to change this as well as there was a problem if you had synonym values for the DATATYPE domain like we have to prepare to handle this. So we added a DATATYPE of IPADDR as a synonym of ALN.

    So we had to change the following section as it was not handling the synonym correctly and resolved it to a numeric:

    _buildTextBoxControl: function(parentControl, woSpec, parentId) { var deferred = new Deferred(); var assetAttrTypes = parentControl.application.getResource("assetattrtypes"); //Commented out the line below and added replacement as it was not resolving a synonym to the correct internal value //var resAttrName = (woSpec['datatype'] == SynonymDomain.resolveToDefaultExternal(assetAttrTypes, 'ALN')) ? 'alnvalue' : 'numvalue'; var resAttrName = ('ALN' == SynonymDomain.resolveToInternal(assetAttrTypes,woSpec['datatype'])) ? 'alnvalue' : 'numvalue';

    This is a core code issue so need to make sure our product developers know about this.

    I have a call later this afternoon with one of our developers so will hopefully have an answer which I will then post here as a solution

    Thanks for your response
    Steve



    ------------------------------
    Steve Lee
    Maximo Technical Sales Specialist
    IBM
    Leeds
    ------------------------------



  • 4.  RE: Maximo Anywhere formatting validation

    Posted Wed August 26, 2020 08:34 AM
    Ah, yeah I see what you're seeing. I was using my local environment I had for a customer which was 7.6.3, didn't think about it being significantly changed in newer versions. This makes it significantly more difficult since they're dynamically building the inputs in that javascript file. At that point, what I would do (and hopefully they tell you the same) is I would add a class to the "assetSpecResource" resource. Thankfully you don't need to extend it as there isn't one currently referenced. And you should be able to use a beforeSave event to perform some validation and throw an exception. But definitely let me know what you hear back.

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