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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to upload image for released product.

(0) ShareShare
ReportReport
Posted on by 2,382

Hi,

I have more than 2000 released items. I want to upload images for those released items.

Image name is same as Released item ID with .jpeg extension.

Can anyone give me Job code for that.

Note: All images in directory (C:\AX\Images\) and directory is shared for everyone.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Please refer following link and you change it to suit your purpose.

    (How to Insert Image in Ax table Using X++ in Ax 2012)

    aspcodder.blogspot.com/.../how-to-insert-image-in-ax-table-using-x.html

  • faiz7049 Profile Picture
    2,382 on at

    Thanks Augustine and Golla,

    If do you have JOB code to meet my requirement.

    Please share

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Please check this links and it has x++ code(class) for product image upload:

    (X++ code for Product image upload in AX)

    community.dynamics.com/.../x-code-for-product-image-upload-in-ax

    (Item Image upload through X++ code )

    www.theaxapta.com/.../item-image-upload-through-x-code.html

  • Brandon Wiese Profile Picture
    17,788 on at

    The first thing to understand is that there are two ways to attach an image to a Released product.  The most basic is to attach the image using Document handling via DocuRef and DocuValue records.  The more comprehensive is to attach the image using Product image via EcoResProductImage records, which also use DocuRef and DocuValue records.  The advantage of Product image is that two additional thumbnails of the original image are stored on the EcoResProductImage record.  This provides the image preview found on the fact pane of the Released products list page, as well as on the detail form.

    The following code was quickly hacked together from several pieces of working code, but was not tested as provided below.  You will have to provide your own record loop and methods for providing the ItemId, Filename, and Text description.  It is provided for educational purposes only.  Use at your own risk.

        ItemId                              itemId;
        Filename                            filename;
        str                                 text;
        str                                 path = @'\\SERVER\Path\';
        InventTable                         inventTable;
        DocuRef                             docuRef;
        EcoResProductImage                  ecoResProductImage;
        EcoResProductImageManagement        ecoResProductImageManagement;
        DocuValue                           docuValue;
        DocuType                            docuType;
        boolean                             fileLocked;
        #File
        ;
    
        while (your.loop.here)
        {
            itemId = your.value.here;
            filename = your.value.here;
            text = your.value.here;
    
            if (itemId && filename)
            {
                inventTable = InventTable::find(itemId);
    
                if (!inventTable.RecId)
                {
                    // warning(strFmt("Item number %1 does not exist", itemId));
                    continue;
                }
    
                if (!WinAPI::fileExists(path + filename))
                {
                    warning(strFmt("File %1 for item %2 does not exist", filename, itemId));
                    continue;
                }
    
                docuRef.clear();
                docuRef.initValue();
                docuRef.TypeId = 'Image';  // default type
                docuRef.RefCompanyId        = curext();
                docuRef.RefTableId          = inventTable.TableId;
                docuRef.RefRecId            = inventTable.RecId;
                docuRef.Restriction         = DocuRestriction::External;
                docuRef.Name                = text;
                docuRef.insert();
    
                docuType = docuRef.docuType();
                if (docuType.FilePlace == DocuFilePlace::Database)
                {
                    if (WinAPI::fileLocked(path + filename))
                    {
                        info("@SYS72783", '', SysInfoAction_Formrun::newFormnameControlnameDesc(formstr(DocuOpenFile), identifierstr(Grid), "@SYS4167"));
                        // Clear out the file name can't be associated to the reference
                        docuRef.Name = "";
                        docuRef.doUpdate();
                        continue;
                    }
                }
    
                ttsbegin;
    
                docuValue.clear();
                docuValue.initFromDocuRef(docuRef);
                docuValue.insert();
     
                docuRef.ValueRecId = docuValue.RecId;
                docuRef.update();
    
                DocuValue::writeDocuValue(docuRef, path + filename);  // assumes associated DocuValue record already exists
    
                ttscommit;
    
                ecoResProductImageManagement = EcoResProductImageManagement::construct();
                ecoResProductImageManagement.setEcoResImageValues(docuRef, EcoResProductImageUsage::External, true);
            }
        }
    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans