Maximo

Maximo

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

 View Only
Expand all | Collapse all

Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

  • 1.  Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Mon July 07, 2025 02:07 PM
    Hello All,
     
    Has anyone successfully created a BIRT report that displays images from work order attachments in MAS  where the doclinks are stored in Cloud Object Storage (COS)?
     
    We are working within an IBM SaaS environment, and the doclinks are stored in AWS COS.
    We've developed a report that works correctly when the doclinks are stored in local storage, but the same approach doesn't work when attempting to access images stored in COS.
     
    Here is the snippet of code we're using:
     
    var docUrl = "https://mxhost/maximo/oslc/cosdoclink/i1.png";
    row["imgdata"] = Base64.getEncoder().encodeToString(XMLUtils.readXMLFileToBytes(docUrl));
     
    Has anyone run into this issue or found a workaround for retrieving and displaying images from COS in a BIRT report?
     
    Any help or guidance would be appreciated!
     
    Thanks in advance.


    ------------------------------
    Ratheesh Pullaikodi
    ------------------------------


  • 2.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Tue July 08, 2025 09:01 AM

    hello Ratheesh

    IBM seems to release a note today on this known limitation and suggested work around using API to convert into public URL without any authentication.

    Hope this helps to your problem.

    BIRT Reports Fails to Render S3-Based Image Attachments in IBM Maximo Application Sute 9

    Regards



    ------------------------------
    Saikat
    ------------------------------



  • 3.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Wed July 09, 2025 03:21 AM

    Hello Saikat

    IBM replied with same as a response to a PMR raised.

    This is resolved by Creating an API from enterprise service to return the DOCUMENTDATA in Base64 encode text.  Invoke the same API from birt.

    For some reason, DOCUMENTDATA returns null if I invoke Object structure rest APIs.

    Thanks



    ------------------------------
    Ratheesh Pullaikodi
    ------------------------------



  • 4.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Mon October 06, 2025 07:20 AM

    Hi Ratheesh Pullaikodi,
    We are currently using MAS 9 and have configured AWS S3 for attachment storage. However, an existing 7613 report that is supposed to display attached images of a worker is not functioning as expected in MAS.
    Glad to hear you have a solution for this problem. Would you be okay to share the details of your solution with us?
    Thanks,
    Raju



    ------------------------------
    Raju Bharla
    ------------------------------



  • 5.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Mon October 06, 2025 08:33 AM

    Hi Ratheesh Pullaikodi,


    We are currently using MAS 9 and have configured AWS S3 for attachment storage. However, an existing 7613 report that is supposed to display attached images of a worker is not functioning as expected in MAS.
    Glad to hear you have a solution for this problem. Would you be okay to share the details of your solution with us?


    Thanks,
    Raju



    ------------------------------
    Raju Bharla
    ------------------------------



  • 6.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Mon October 06, 2025 03:12 PM

    Hi Raju Bharla

    I followed below steps

    Add an Object structure on object DOCLINKS, make sure non persistent field DOCUMENTDATA is included.

    Add a Query enterprise service with above OS and add this to an external system.

    In Web Service Library application, Create a webservice from above Enterprise service.

    Call this service from Birt report (I have used HttpURLConnection class) ,in request payload by passing the doclinks id <max:WHERE>doclinksid=" + doclinksid + "</max:WHERE>

    the DOCUMENTDATA column returned will have the encoded attachment.

    Thanks

    Ratheesh



    ------------------------------
    Ratheesh Pullaikodi
    ------------------------------



  • 7.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Wed October 15, 2025 03:08 AM
      |   view attached

    Hi Ratheesh Pullaikodi, 
    Our team is working on integrating image attachments into a BIRT report for Maximo using your suggested approach. The report runs in Eclipse but shows "The resource of this report item is not reachable." Since the enterprise service web service isn't working for us, we've used an object structure–based web service instead.
    With this setup, we're encountering an SSL exception in Eclipse, and in Maximo, the report hangs indefinitely. We've attached our code-could you please review it and share:
    - The full dataset script (open, fetch, close) for attachment metadata
    - The complete onCreate method for the Dynamic Image element
    - Any tips or logging suggestions to help troubleshoot
    Thanks again for your support!



    ------------------------------
    Raju Bharla
    ------------------------------

    Attachment(s)



  • 8.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Thu October 16, 2025 03:39 AM

    Hi Raju,

    I can see 2 issues with this approach which you'll need to address somehow.

    First one is the fact you're trying to reach HTTPS resource from the BIRT report code. The code executes on the server side and therefore server-side trust store is being used while establishing connection to your endpoint. You're pointing back to your Manage/Maximo which even though is available over HTTPS using given TLS-certificate then it doesn't mean it trusts it on its own. Having said the first thing to do is to import in MAS Core your Manage TLS-certificate or (preferably) the Root CA certificate (Administration > Workspace > Manage > Update configuration > Imported certificates).

    Second thing is actual authentication which is required in order to get access to the HTTP endpoint. In fact we're back to square one - regardless which Manage endpoint (serving REST/WebService or secure attachments) you're trying to reach you still need to authenticate yourself first. I'm more than certain, looking at the attached code, that you'll not be able to get the proper document content using raw URL connection without passing additional authentication details. You can do that by sending APIKEY in the header, but this means you would need to get it first (which is doable; hardcoding it would be a very bad practice) or somehow extract the authentication data from the current request context and pass it on.

    I would recommend you however alternative technique which is based on a Bonus: Using (Jython) Library Scripts in BIRT Reports section of my LinkedIn article Jython Library Scripts in MAS Manage/Maximo. Since you can invoke any Maximo/Manage automation script (JavaScript and/or Jython) directly from the BIRT report then you can read the content of the attachment without making a "loopback" HTTP request. Example automation script may look somewhat like this:

    function getAttachment(doclinksId) {
        // Get your DOCLINKS Mbo as any other Mbo in the library automation script
        // based on DOCLINKS.DOCLINKSID, passed as an argument.
        var doclinkMbo = [...] 
        var AttachmentStorage = Java.type(com.ibm.tivoli.maximo.oslc.provider.AttachmentStorage);
        return AttachmentStorage.getInstance().getAttachment(doclinkMbo);
    }

    This way you'll get byte[] which you can further use inf your report logic.

    Good luck!



    ------------------------------
    If this post helps, please consider accepting it as a solution to help other members find it more quickly.

    Andrzej Więcław
    Maximo Technical SME
    ZNAPZ B.V.
    Wrocław, Poland
    ------------------------------



  • 9.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Thu October 16, 2025 06:06 AM

    Thanks Andrzej Więcław, for responding, we are getting below error while running report to call automation script from fetch method. Please suggest.

    org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "if (!WoImage1.fetch()) return false;
     
    row["urlname"] = WoImage1.getString("urlname");
    row["description"] = WoImage1.getString("description");
    row["doclinksid"] = WoImage1.getString("doclinksid");
     
    // Call Maximo automation script to get   attachment
    var ScriptService = Packages.com.ibm.tivoli.maximo.script.ScriptService;
    var Arrays = Packages.java.util.Arrays;
    var docId = row["doclinksid"]; // Use the value you just extracted
     
    var service = new ScriptService("getAttachment", null, null);
    var result = service.invokeScript(
    "getAttachment", // Script name
    "getAttachment", // Function name inside the script
    Arrays.asList(docId) // Pass doclinksId as argument
    );
     
    row["imageBytes"] = result; // Store the byte[] for use in image rendering
     
    return true;":
    Fail to execute script in function __bm_FETCH(). Source:
    ------
    " + if (!WoImage1.fetch()) return false;
     
    row["urlname"] = WoImage1.getString("urlname");
    row["description"] = WoImage1.getString("description");
    row["doclinksid"] = WoImage1.getString("doclinksid");
     
    // Call Maximo automation script to get   attachment
    var ScriptService = Packages.com.ibm.tivoli.maximo.script.ScriptService;
    var Arrays = Packages.java.util.Arrays;
    var docId = row["doclinksid"]; // Use the value you just extracted
     
    var service = new ScriptService("getAttachment", null, null);
    var result = service.invokeScript(
    "getAttachment", // Script name
    "getAttachment", // Function name inside the script
    Arrays.asList(docId) // Pass doclinksId as argument
    );
     
    row["imageBytes"] = result; // Store the byte[] for use in image rendering
     
    return true; + "
    -----
    A BIRT exception occurred. See next exception for more information.
    TypeError: [JavaPackage com.ibm.tivoli.maximo.script.ScriptService] is not a function, it is object. (/report/data-sets/script-data-set[@id="2721"]/method[@name="fetch"]#12).
       at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:99)
       at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:256)
       at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:143)


    ------------------------------
    Raju Bharla
    ------------------------------



  • 10.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Thu October 16, 2025 06:46 AM
    Edited by Andrzej Więcław Thu October 16, 2025 06:49 AM

    Hi Raju,

    are you trying to execute this report in the Birt Designer or directly in Maximo?
    It could be that you need to add businessobjects.jar to your preview web server embedded into the Birt Designer. In Maximo it should work out of the box.

    Furthermore I can see that you're calling a script getAttachment which for sure doesn't exist as all scripts names are of type UPPER.
    Assuming that you defined your GETATTACHMENT script of script language JavaScript, with Allow Invoking Script Functions flag checked (just as described in the article linked earlier) and getAttachment function defined then the script invocation should look as follows:

    var ScriptService = Packages.com.ibm.tivoli.maximo.script.ScriptService;
    var params = [ row["doclinksid"] ]; // Use the value you just extracted
     
    var service = new ScriptService("GETATTACHMENT", null, null);
    var result = service.invokeScript(
        "GETATTACHMENT", // Script name
        "getAttachment", // Function name inside the script
        params // Pass doclinksId as argument
    );



    ------------------------------
    If this post helps, please consider accepting it as a solution to help other members find it more quickly.

    Andrzej Więcław
    Maximo Technical SME
    ZNAPZ B.V.
    Wrocław, Poland
    ------------------------------



  • 11.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted Fri October 17, 2025 06:45 AM

    Thanks Andrzej Więcław-your solution works perfectly in MAS Manage and is highly reusable for similar needs.



    ------------------------------
    Raju Bharla
    ------------------------------



  • 12.  RE: Display images from attachments in a BIRT report on MAS Saas manage where the doclinks are stored in COS

    Posted 16 days ago

    HI @Raju Bharla

    Would you able to share the automation library script and rpt design sample code so I can implement it? I have similar requirement to build



    ------------------------------
    Xpert Max
    ------------------------------