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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

Regarding image upload in class (D365FO)

(0) ShareShare
ReportReport
Posted on by 351

Hi,

I want to upload image.

Form name : HcmpersonImage.

As I mentioned above form there is worker against upload image the same things i want to do in class.

Could you please give me the example.

Thanks

I have the same question (0)
  • waytod365 Profile Picture
    351 on at
    RE: Regarding image upload in class (D365FO)

    The topic is service operation and i don't want browser stream class. i want to pick directly upload image in x++.

    Note : The service using mobile guy, there is don't open browser that is why i asked directly pick, please give me the example.

  • Suggested answer
    Martin Dráb Profile Picture
    236,503 Most Valuable Professional on at
    RE: Regarding image upload in class (D365FO)

    If your goal is to connect through X++ to users' local machines and read files from their disks, then this isn't possible. You'll need to through your business requirement once more and design a different technical solution.

    Note that I don't understand many of your statements (e.g. what if "mobile guy" or what you mean by "there is don't open browser"). You may want to explain your situation once again and with more details.

  • ergun sahin Profile Picture
    8,824 Moderator on at
    RE: Regarding image upload in class (D365FO)

    The HcmpersonImage form you mentioned above also uses FileUploadTemporaryStorageResult. What exactly is your demand?

  • waytod365 Profile Picture
    351 on at
    RE: Regarding image upload in class (D365FO)

    Thanks for your replay sir,

    We have an one ISV module and that same module process used in an one App.

    Third party Mobile app guy.

    Form : HcmPersonImage things i want to do in class.

    As i mentioned above form there is two process.

    So i wrote a two operation for that.

    1.Show image operation below my code its okay for me.

    public PersonPhotoData getPersonPhoto(HcmWorkerRecId _workerRecid, DataAreaId _dataAreaid)
        {
    
            PersonPhotoData             photoData; // Contract class our own
            HcmWorker                   hcmWorker = HcmWorker::find(_workerRecid);
            HcmPersonImage              hcmPersonImage;
            BinData                     imageData;
        
            photoData = new PersonPhotoData();
            changecompany(_dataAreaid)
            {
                select firstOnly Image from hcmPersonImage
                where hcmPersonImage.Person == hcmWorker.Person;
        
                if (hcmPersonImage.Image)
                {
                    imageData = new BinData();
                    imageData.setData(hcmPersonImage.Image);
        
                    photoData.parmPersonPhoto(imageData.base64Encode());
                }
            }
        
            return photoData;
        }

    2 . things upload image

    Here is It should be file as stream then upload it and i Don't wanna use file upload controller.

    Because the upload thing [He will use mobile third party guy.

    How to do Please give me example Martin sir.

    Thanks 

    Thanks for your replay Ergun Shain sir,

    As i mentioned same thing i want to do in class.

  • Martin Dráb Profile Picture
    236,503 Most Valuable Professional on at
    RE: Regarding image upload in class (D365FO)

    The key question is: where do you want to read the files from?

    The upload control allows users to upload files from their local machines. As I said, while users can use files from their machines, web servers  (such as the one hosting your F&O environment) can't just connect to users' machines and manipulate their files. It seems to me that indeed want to do that, but because it's not possible, I said you'd need to think it through again.

    You should forget implementation details for a moment, because the whole idea can't be implemented. You need to ask yourself again what business problem you're trying to solve and then think about a technical solution which can address it.

    For example, maybe users could upload files to a location where the files will be readable from X++ (e.g. Azure file storage) and you'll use PowerAutomate or batch in F&O to handle these files. Or maybe you'll realize that the whole idea was based on wrong assumptions and you'll abandon it.

  • waytod365 Profile Picture
    351 on at
    RE: Regarding image upload in class (D365FO)

    Thanks for your replay sir,

    I agreed on your point sir, Could you please give me the example in your hand and upload image process, i will rethink the scenario form my side. i don't know there is convert stream.

    Note : just give me upload process.

  • Martin Dráb Profile Picture
    236,503 Most Valuable Professional on at
    RE: Regarding image upload in class (D365FO)

    I thought you said you already have the code in front of you, in HcmPersonImage form. Isn't it the case?

    Or do you mean that you want an example of something else?

    If you don't know yet what you want to implement (because you will think it through in future), what point does it make to talk about code examples? You need to have some idea about what you want to do before you can write code to actually do it.

    What do you mean by "i don't know there is convert stream"?

    And what do you mean by "give me upload process"? Please spend a bit more time with formulating your requirements and putting them into sentences. We can't help you if you don't explain properly what you actually need.

  • waytod365 Profile Picture
    351 on at
    RE: Regarding image upload in class (D365FO)

    Sir i don't wanna confuse you as i mentioned above forget.

    Let me come to point quick.

    The thing is i want to upload image in service operation.

    Below code,

    FileUploadTemporaryStorageResult fileUploadResult = FileUpload.getFileUploadResult();
    if(fileUploadResult != null && fileUploadResult.getUploadStatus())
    {
        HcmPersonImage.Image = ImageReference::GetPackedBinaryData(fileUploadResult.getDownloadUrl());
    }
    else
    {
        warning("@SYS89176");
    }

    As I mentioned above the code it will show dialog to upload image  ? if so, instead of dialog upload there is any convert in x .

    I'm 100% sure I bet you have an opinion on this :)

  • Martin Dráb Profile Picture
    236,503 Most Valuable Professional on at
    RE: Regarding image upload in class (D365FO)

    The upload control allows users to pick a file from a local disk and upload it to F&O. You CAN'T do the same thing from X++. You don't have access to the local machine from X++. The idea of somehow replacing the upload dialog with X++ code and grabbing files from users' machines is wrong - such a thing can't be done.

    You also mentioned a service operation. Does it mean that you want to implement a custom service that will accept the file and you'll have local application (not written in X++, because F&O is a web application) that will call the web service and push a local file to there? Please answer at least this question, if you don't want to answer my previous ones.

    By the way, are you aware of data entities and Recurring Integrations Scheduled?

  • waytod365 Profile Picture
    351 on at
    RE: Regarding image upload in class (D365FO)

    Yes sir, there is allow in local machine that will call the web service and push a local file to here.

    It should be file as stream then upload directly in x++?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,882

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 794 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 525 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans