web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

DIXF- Import product images

(0) ShareShare
ReportReport
Posted on by

Hi

Does DIXF support the product images import ? Can you please help me if a custom entity is required then how to go with this for importing product images. ?

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 1 on at

    The architecture of  DMF is build to accept kind of file like text, excel CSV etc. it is not supposed to select physical files from your local drive and upload those Bitmaps images.

    So logically thinking there should be no entity to support this.

    yes people have done work to upload product images by x++ code and you can find examples on search engine. But not by DMF/DIXF.

  • Suggested answer
    Brian Kinser Profile Picture
    815 on at

    I created an x++ job to do this a while back.....here is what I did....all of the product images were named the same name as the product in my case so.....I put all the images into a folder, then looped through each file in the folder, stripped out the image name, and attached the image to the product......ping me if you want the code and I will forward it......mark this answer as correct if so...

  • Community Member Profile Picture
    on at

    Hi Brian Kinser ,

    Can you please provide me code for the same.

    Thanks

    Pallavi

  • Waqas Javed Profile Picture
    115 on at

    Hi Brain, 

    I am using the same approach suggested by you however unable to view the image on front end. Below is the code that i am using. docuref, docuval and ecoresproduct images are populating properly but image is not appearing on front end. Any suggestion please.

    public void uploadProductImages()
    {
    DocuRef docuRef;
    DocuValue docuValue;
    InventTable inventTable;
    EcoResProductImage ecoResProductImage;

    System.String[] fileNames;
    int fileCount, i;

    str fileName, trimmedFileName, fileNameWithExt;
    BinData binData;

    binData = new BinData();
    //fileNames = System.IO.Directory::GetFiles(strFmt(@"%1", StringFilePath.valueStr()));
    fileNames = System.IO.Directory::GetFiles(@"C:\DAXImages");


    fileCount = fileNames.get_Length();

    for (i=0; i<fileCount; i++)
    {
    fileName = fileNames.GetValue(i);


    trimmedFileName = substr(fileName, strscan(fileName, '\\', strlen(fileName), -strlen(fileName))+ 1, strlen(fileName));
    fileNameWithExt = trimmedFileName;
    if (trimmedFileName)
    {
    // Assuming file extension is always .jpg, removing it
    trimmedFileName = strreplace(trimmedFileName, ".jpg", "");
    }
    // assuming image name matches item name in AX
    inventTable = InventTable::find(trimmedFileName);

    if (inventTable)
    {
    binData.loadFile(fileName);

    //docuValue.FileName = trimmedFileName;
    docuValue.Name = trimmedFileName;

    docuValue.FileType = "jpg";
    docuValue.OriginalFileName = fileNameWithExt;
    docuValue.File = binData.getData();
    docuValue.insert();

    docuRef.ValueRecId = docuValue.RecId;
    docuRef.RefTableId = tableNum(InventTable);
    docuRef.RefRecId = inventTable.RecId;
    //docuRef.RefRecord = inventTable.RecId;
    docuRef.RefCompanyId = curext();
    docuRef.Name = trimmedFileName;
    docuRef.TypeId = "File";
    docuRef.insert();

    ecoResProductImage.clear();
    ecoResProductImage.DefaultImage = true;
    ecoResProductImage.FileName = fileNameWithExt;
    ecoResProductImage.ImageFormat = "jpg";
    ecoResProductImage.RefRecId = docuRef.RecId;
    ecoResProductImage.RefRecord = inventTable.RecId;
    ecoResProductImage.RefRecord = docuRef.RecId;
    ecoResProductImage.Usage = 0; // Base Enum: 0=External, 1=Internal
    ecoResProductImage.insert();

    }
    }
    }

  • Suggested answer
    Brian Kinser Profile Picture
    815 on at

    Can you debug and see which table is not getting populated correctly? is docuRef table getting new row? is ecoResProductImage table getting new row? Also I noticed you are setting the usage to EXTERNAL, that means that you can see the image in the product catalog...but do you have a image for the internal product view? also, also I see that you are trying to set the link between the 2 table fields twice...

     ecoResProductImage.RefRecord = inventTable.RecId;
    ecoResProductImage.RefRecord = docuRef.RecId;

    Hope that helps

    Brian Kinser

    info@briankinser.com

  • Waqas Javed Profile Picture
    115 on at

    Hi Brain, 

    thank you for your reply, missed out your message :) 

    Yes, all 3 tables are populating properly and i am able to view the image under Product Image now but still its not appearing on the main form. 

    It was by mistake that is replaced as below. 

    ecoResProductImage.RefRecId = docuRef.RecId;

    ecoResProductImage.RefRecord = docuRef.RefRecId;

    DB-Records.JPG

    DB-Records.JPG

  • Waqas Javed Profile Picture
    115 on at

    MediumSize and Thumbnailsize is appearing Null in ECORESPRODUCTIMAGE whereas when uploading from the front end there is a value in it. That might be the issue? May be image is there but due to size i can not view it.

  • Waqas Javed Profile Picture
    115 on at

    Appreciate if anyone can assist me to resolve this issue.

  • Suggested answer
    Brian Kinser Profile Picture
    815 on at

    When you upload using AX client it automatically creates / inserts the file into the medium size and thumbnail images.......x++  code does not do this, you must add that to the x++ if you want to also insert the file into the other 2 locations.....currently my code only inserts it as a product image...not a thumbnail or meduim but you can add that in X++....also you can increase the size of the thumbnail using murrays way....you need to generate the thumbnail / mediumsize images this way....

    ecoResProductImageThumbnail         = new EcoResProductImageThumbnail(false);

                ecoResProductImage.MediumSize       = ecoResProductImageThumbnail.generateThumbnail(204,204,docuRef);
                ecoResProductImage.ThumbnailSize    = ecoResProductImageThumbnail.generateThumbnail(48,48,docuRef);
                if (ecoResProductImage.MediumSize == connull())
                {
                    info("@SYS301935");
                }
                if (ecoResProductImage.ThumbnailSize == connull())
                {
                    info("@SYS301936");
                }
                ecoResProductImage.insert();
  • Douglas Noel Profile Picture
    3,907 on at

    One stupid question:

     

    Is your used DocuType set to store in database? Maybe it's only a problem for displaying, if viewer tries to read the attached file somewhere from url or path instead from the blob?

     

    regards

     

    Douglas

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 10

#2
Harisgillani Profile Picture

Harisgillani 4

#2
dserp Profile Picture

dserp 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans