How to export / import a picture or image from a table field by X++ code in Microsoft Dynamics AX 2012.
Applied on: Dynamics AX 2012 R3 CU9.
Prerequisite: Basic Dynamics AX 2012 programming knowledge.
Target audience: AX programmers.Assumption: You are familiar with Dynamics AX 2012.
Below X++ job will explain you how to export an image or picture from Dynamics AX 2012 table. It's a simple piece of code but sometimes we spent hours to get the code how to export picture or image. I have posted here just to make it handy.
}
In addition I am share the code how to import or insert a picture or image in Dynamics AX 2012 using X++ code.
Here is the job:
}
Hope this was useful. You may leave your comment below.
Applied on: Dynamics AX 2012 R3 CU9.
Prerequisite: Basic Dynamics AX 2012 programming knowledge.
Target audience: AX programmers.Assumption: You are familiar with Dynamics AX 2012.
Below X++ job will explain you how to export an image or picture from Dynamics AX 2012 table. It's a simple piece of code but sometimes we spent hours to get the code how to export picture or image. I have posted here just to make it handy.
static void
exportImageFromTable(Args _args)
{
bindata bin = new
bindata();
str content;
container image;
RetailImages retailImages;
FilePath filepath;
select
retailImages where
retailImages.PictureId == 8045;
filepath = strFmt('C:\\Users\\Administrator\\AppData\\Local\\Temp\\images\\PictureID_%1.jpg',
retailImages.PictureId);
image = retailImages.picture;
bin.setData(image);
// Create the
base64 encoded string
// content =
bin.base64Encode();
//
info(content);
// Save it to
the file system as a jpg, png or tif format
AifUtil::saveBase64ToFile(@filepath,
content);
In addition I am share the code how to import or insert a picture or image in Dynamics AX 2012 using X++ code.
Here is the job:
static void
InsertImageToTableField(Args _args)
{
Bindata binData = new
BinData();
FilePath path;
RetailImages retailImages;
str imageID;
path = "C:\\Users\\Administrator\\AppData\\Local\\Temp\\Images\\PictureID_8046.jpg";
// file location
binData.loadFile(path);
select
retailImages where
retailImages.PictureId == 1111;
if
(!retailImages)
{
retailImages.picture = binData.getData();
retailImages.PictureId = 1111;
retailImages.doInsert();
}
Hope this was useful. You may leave your comment below.
This comment has been removed by the author.
ReplyDeleteInformative blog.
ReplyDeleteMS Dynamics Online Training
I got what i am seraching from last few days in your Blog. I hope you will share more info about it. Please keep sharing.
ReplyDeleteLaptop Service center in Ameerpet
Dell Service center in Ameerpet
HP Service center in Ameerpet
Lenovo Service center in Ameerpet
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis is good information and really helpful for the people who need information about thiswonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
ReplyDeleteoracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
hadoop training in chennai
hadoop training in bangalore
Svu University B.Com 2nd,4th,6th Sem Result 2020
ReplyDeleteHnbgu University B.Com 2nd,4th,6th Sem Result 2020
Jadavpur University B.Com 2nd,4th,6th Sem Result 2020
You’d outstanding guidelines there. I did a search about the field and identified that very likely the majority will agree with your web page.
Good work and you are putting the effort is very great. This post is having clear content about this topic and I hope more valuable post from your innovative blog. Keep it up...
ReplyDeleteSalesforce Training in Chennai
Salesforce Online Training in Chennai
Salesforce Training in Bangalore
Salesforce Training in Hyderabad
Salesforce training in ameerpet
Salesforce Training in Pune
Salesforce Online Training
Salesforce Training
Greate article. Keep posting such kind of info on your blog. result of BA Final Year
ReplyDeleteI think Bcom 3rd Year Time Table you did an awesome job explaining Amu ba 3rd Year time table it. Sure beats having to research it on my own. Thanks
ReplyDeleteBollywood News in Hindi - Check out the latest Bollywood news, new Hindi movie reviews, box office collection updates and latest Hindi movie videos. Download free HD wallpapers of Bollywood celebrities and recent movies and much more on Bollywood Hungama.
ReplyDeleteThe Tomorrow War Full Movie
Gangubai Kathiawadi Full Movie
I wish to say that this 3rd year exam date post is amazing.
ReplyDelete