MxLoader

 View Only
  • 1.  Upload Image to IMGLIB for ITEM.

    Posted 05-09-2023 05:52
    Edited by Manuel Guyot 05-09-2023 06:02

    Hi,

    I am using MxLoader 8.2 with Maximo 7.6.1.2 and try to upload picture connected to ITEM. 
    This is my MxLoader:

    MXL_ITEMPIC ITEM AddChange itemnum="19351"        
    ITEMNUM ITEMSETID DESCRIPTION STATUS IMGLIB.IMAGE IMGLIB.IMAGENAME IMGLIB.MIMETYPE [RESULT]
    19351 ISSE VENTIL FESTO JH-5-1/2 ACTIVE FileEnc:/C:\Temp\Reservdelar\10165.jpg 10165.jpg image/jpeg OK


    I can see that the picture is uploaded to Maximo with the right information but the picture is "broken", I can't see it or open it.


    I have started the Debug mode in MxLoader and copied the information saved into IMGLIB/IMAGE, pasted it in a Base64 decoder and the picture is the same than the one I uploaded, so what did I do wrong?

    Anyone who succeed in uploading picture to ITEM with MxLoader?

    Thanks.



    ------------------------------
    Manuel Guyot
    Husqvarna AB
    ------------------------------



  • 2.  RE: Upload Image to IMGLIB for ITEM.

    Posted 06-29-2023 01:06
    After some test and research, I found what was missing.
    I had to create a script for integration connected to MXITEM like this:
    from org.apache.axiom.om.util import Base64
     
    def afterMboData(ctx): 
     if ctx.getMboName()=='IMGLIB': 
      ctx.getMbo().setValue("IMAGE",Base64.decode(ctx.getData().getCurrentData("IMAGE")))
    And had to add IMGLIB to object MXITEM.
     
    Then it was working without any problem.



    ------------------------------
    Manuel Guyot
    Husqvarna AB
    ------------------------------



  • 3.  RE: Upload Image to IMGLIB for ITEM.

    Posted 03-06-2024 00:22

    Hi, I tried this method and getting below error:

    Internal Server Error
    Error 500: BMXAA4211E - Database error number 2601 has occurred when operating on IMGLIB :  Unique Id=12,233. Report the error to the owner of the deployment.

    I created integration script for MXITEM with your code for inbound processing. In MXLOADER I've tried two different object structures, MXITEM adn MXLITEM (created new) but getting the same error. 

    I'd really appreciate if you can provide your insights.

    Cheers

    Hammad



    ------------------------------
    Hammad Najeeb Ghumman
    Keolis Downer
    ------------------------------



  • 4.  RE: Upload Image to IMGLIB for ITEM.

    Posted 06-19-2024 03:36

    Hi, for me it worked using MxLoader Sync Action .

    Regards, Janez



    ------------------------------
    Janez Naglic
    KOPA d.d.
    ------------------------------



  • 5.  RE: Upload Image to IMGLIB for ITEM.

    Posted yesterday

    Hi,

    With Maximo MAS, things changes and when you try to send a picture you get the message: "Upload of bynary files is not yet supported for REST APIs." (Message from MxLoader), for those who are creating own VBA scripts, this can be done by easy way:

    In my script I write in the IMGLIB.IMAGE column the referens to the file like:

    Picture:/D:\Temp\JPG\Image.jpg

    Then in my script I detect the "Picture:/" and then send the encryption like:

    PictureB64 = Chr(34) & "image" & Chr(34) & ": " & Chr(34) & EncodeFileToBase64(Right(value, Len(value) - 9)) & Chr(34)

    The Function is:

    Public Function EncodeFileToBase64(filePath As String) As String
        Dim fileStream As Object
        Dim xmlObj As Object
        Dim fileBytes() As Byte

        ' Read file as binary
        Set fileStream = CreateObject("ADODB.Stream")
        fileStream.Type = 1 ' Binary
        fileStream.Open
        fileStream.LoadFromFile filePath
        fileStream.Position = 0
        fileBytes = fileStream.Read
        fileStream.Close

        ' Convert to Base64
        Set xmlObj = CreateObject("MSXML2.DOMDocument").createElement("b64")
        xmlObj.DataType = "bin.base64"
        xmlObj.nodeTypedValue = fileBytes
        EncodeFileToBase64 = xmlObj.Text
    End Function

    I don't know if it can help someone but I put it here so that it can give some hints or help on the way, I got it working perfectly with my script.



    ------------------------------
    Manuel Guyot
    Husqvarna AB
    ------------------------------