Maximo

Maximo

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

 View Only
Expand all | Collapse all

How to reference an image (company logo) in SRMOBILE and start hierarchy from second level in Application Framework?

  • 1.  How to reference an image (company logo) in SRMOBILE and start hierarchy from second level in Application Framework?

    Posted 13 hours ago

    Hi everyone,

    I'm currently working on customizing the SRMOBILE application in Maximo and have a couple of questions regarding configuration through the Application Framework - specifically app.xml and appCustomization.js.

    1. Image referencing:

      • How can I reference an image (like the company logo) that's hosted online within the SRMOBILE app?

    2. Hierarchy starting point:

      • Is there a way to start the location hierarchy from the second level instead of the first (for example, skipping the root and showing only sub-locations)?

      • Can this be achieved through the framework configurations, or does it require deeper customization in the application code?

    Additionally, I'm implementing several UI adjustments such as:

    • Save my GPS in the service address is not working.

    • make attachments required before submitting requests.

    Any insights or best practices on handling these through the framework would be greatly appreciated 

    Thanks in advance!



    ------------------------------
    Mostafa Mosaad
    Software Engineer
    Megasoft
    Cairo
    01117275779
    ------------------------------


  • 2.  RE: How to reference an image (company logo) in SRMOBILE and start hierarchy from second level in Application Framework?

    Posted 5 hours ago

    Hi Mostafa - great questions. You can do most of this via the Application Framework (app.xml + appCustomization.js), and only drop to "deeper" customization if you hit limits.

    1) Referencing an online image (e.g., company logo)

    Best practice: bundle the image with the app; it works offline and avoids CORS.

    • Put your file at: apps/SRMOBILE/common/images/logo.png

    • In app.xml (or a custom CSS), reference it:

    <image id="companyLogo" src="images/logo.png" />

    or in CSS:

    .company-logo { background-image: url("images/logo.png"); }

    If you must load from a URL:

    • Add the host to the Cordova/Worklight whitelist (config.xml / application-descriptor.xml):

    <access origin="https://assets.yourdomain.com" subdomains="true" />
    • Ensure the server sends proper CORS headers and uses HTTPS.

    • Remember: this won't show when the device is offline. For guaranteed display, consider a Base64 data URI:

    <image id="companyLogo" src="data:image/png;base64,...." />

    2) Start the location hierarchy from "second level"

    You have two clean options without code changes to core files:

    A. Saved Query approach (recommended):

    1. In Maximo (LOCATIONS), create a public saved query that excludes the root, e.g.
      parent is not null (or parent='YOURROOT' to show only children of a specific root).

    2. Expose it over OSLC and set your lookup/list in app.xml to use that queryBase:

    <lookup id="locationLookup" resource="LOCATION" queryBase="CHILD_ONLY" <!-- your saved query name --> ... />

    B. Additional WHERE in the control:
    If you're already using a queryBase, add a filter:

    <lookup id="locationLookup" resource="LOCATION" queryBase="ACTIVE" additionalWhere="parent is not null" />

    (Use whichever attribute your Anywhere version supports: additionalWhere, defaultFilter, or a filter binding.)


    3) "Save my GPS in the Service Address" not working

    Common causes & fixes:

    • Permissions: ensure the mobile OS has Location permissions enabled for the app.

    • Security: the user's security group needs create/update on SERVICEADDRESS (and related SR → Service Address relationship).

    • App config: confirm service address features are enabled in app.xml and that the SR app is set to persist the address.

    • Attribute mapping: Service Address typically has LATITUDE / LONGITUDE. Make sure your handler sets those on the related Service Address record, not just on SR.

    Example hook in appCustomization.js:

    define(["dojo/_base/lang", "platform/translation/MessageService", "platform/comm/_ConnectivityChecker", "platform/geolocation/GeoLocationHelper"], function(lang, MessageService, _ConnectivityChecker, GeoLocationHelper) { return { setGPSOnServiceAddress: function(eventContext) { var sr = eventContext.application.getResource("sr").getCurrentRecord(); return GeoLocationHelper.getCurrentLocation().then(function(loc){ // Create or get related Service Address var sa = sr.get("serviceaddress") || sr.createNewRelationshipRecord("serviceaddress"); sa.set("latitude", loc.coords.latitude); sa.set("longitude", loc.coords.longitude); // set other SA fields as needed, e.g. addressline1 from reverse geocode if you have it }).otherwise(function(err){ eventContext.application.showMessage(MessageService.createStaticMessage("Could not get GPS").getMessage()); }); } }; });

    Then wire setGPSOnServiceAddress to your "Save my GPS" UI action.


    4) Make attachments required before submitting the SR

    Add a lightweight validation hook in appCustomization.js:

    define(["dojo/_base/declare", "application/business/SR"], function(declare, SR){ var orig = SR.prototype.validateBeforeSave; SR.prototype.validateBeforeSave = function(eventContext){ var ok = true; if (orig) ok = orig.apply(this, arguments); if (!ok) return false; var srSet = eventContext.application.getResource("sr"); var sr = srSet && srSet.getCurrentRecord(); var atts = sr && sr.getPendingOrOriginalValue && sr.get("attachments"); var count = (atts && atts.count) ? atts.count() : 0; if (count === 0){ eventContext.application.showMessage("Please attach at least one file before submitting."); return false; } return true; }; });

    When you'd need deeper customization

    • If your hierarchy needs dynamic "second level" logic per site/org (not just parent is not null), inject the parent programmatically from user/site context in appCustomization.js and set a runtime filter on the lookup.

    • If the logo must be pulled from a tenant-specific URL at runtime, add a small handler that selects the src based on org/site and caches it locally.

    If you share your Anywhere/Mobile version (e.g., 7.6.4.x vs MAS Maximo Mobile) and whether SRMOBILE is the classic Anywhere SR app or the MAS Mobile SR, I can tune the exact control attributes and handler names for your build.

    - Manu Nagayach
    IBM-Certified Maximo Architect | EAM Strategist



    ------------------------------
    Manu Nagayach
    ------------------------------