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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Save Image in Table

(0) ShareShare
ReportReport
Posted on by 810
static void ImageField(Args _args)
{
BinData binData = new BinData();
A_ImageTable table;
container imageContainer;
str imageFilePathName;
imageFilePathName="C:\\Users\\Public\\Desktop\\diwali.jpg";
if ( WinAPI::fileExists(imageFilePathName))
{
binData.loadFile(imageFilePathName);
imageContainer = binData.getData();
//table.Image = _Party.RecId;
table.Image = imageContainer;
table.insert();
}
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    UmesH@ Profile Picture
    810 on at
    RE: Save Image in Table

    Create Container in A_ImageTable and Use Code to Save Image in Table.

  • Community Member Profile Picture
    on at
    RE: Save Image in Table

    I created an field with container, so I need to write this code in job right??

    Does this code will make me to insert the image in the table..

  • Suggested answer
    Rohin Profile Picture
    4,624 on at
    RE: Save Image in Table

    Well, you can take help from CompanyImage Form

  • Community Member Profile Picture
    on at
    RE: Save Image in Table

    yes, i tried but i don't know how to insert image in table level itself..

  • Rohin Profile Picture
    4,624 on at
    RE: Save Image in Table

    Do you have form for inserting the Image or you want to insert directly to table ?

    If you want to insert directly to table , you can use above job.

  • Community Member Profile Picture
    on at
    RE: Save Image in Table

    Ya i tried to use tat job..

    But wat  i need is i like to display the image in table level..

    I just tried by adding a field File path and overrided active method in form datasource and used the coding as:

    public int active()

    {

       int ret;

       Image logoImage;

       AX_BookMaster ax_bookmasterLocal;

       container imageContainer;

       BinData binData = new BinData();

       ;

       ret = super();

       select ax_bookmasterLocal where ax_bookmasterLocal.Book_Id == AX_TransactionLine.Book_Id;

       if(ax_bookmasterLocal.FilePath)

       {

       binData.loadFile(ax_bookmasterLocal.FilePath);

       imageContainer = binData.getData();

       logoImage = new Image();

       logoImage.setData(imageContainer);

       bookimage.image(logoImage);

       bookimage.widthValue(logoImage.width());

       bookimage.heightValue(logoImage.height());

       }

       return ret;

    }

    But i like to insert the image in table level, so tat wen the record is inserted in form so that the image will display automatically..

    Is there any way to do like tat?

  • Rohin Profile Picture
    4,624 on at
    RE: Save Image in Table

    I don't understand your business requirement, sorry. can you please elaborate it? Record are inserted through form level and if image is inserted through form level linked to specific record , so it will inserted into table itself and display to form as well. AX does this for company Image, for instance. what is the problem with company Image? please provide more details?

  • Lhamo Dolma Profile Picture
    292 on at
    RE: Save Image in Table

    what if you want the image to show up on the report? this report gets data from the table? How do you then insert the image into the table? I've a field that is of type container with extended data type of bitmap. How do I insert an image into a table?

    Thanks in advance for the help!

  • Community Member Profile Picture
    on at
  • Community Member Profile Picture
    on at
    RE: Save Image in Table

    I've done in form to show images for active records.

    In table I added a string field and named as Filepath and stored the location of Images.

    In form active method:

    public int active()

    {

       int ret;

       Image logoImage;

       AX_BookMaster ax_bookmasterLocal;

       container imageContainer;

       BinData binData = new BinData();

       ;

       ret = super();

       select ax_bookmasterLocal where ax_bookmasterLocal.Book_Id == AX_TransLine.Book_Id;

       if(ax_bookmasterLocal.FilePath)

       {

       binData.loadFile(ax_bookmasterLocal.FilePath);

       imageContainer = binData.getData();

       logoImage = new Image();

       logoImage.setData(imageContainer);

       BookImage.image(logoImage);

       BookImage.widthValue(logoImage.width());

       BookImage.heightValue(logoImage.height());

       }

       return ret;

    }

    It will show like this when we change the books in line, the image will change based on active record in line.

    815778.Capture.PNG

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans