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 :
Supply chain | Supply Chain Management, Commerce
Answered

Could not resolve X++ type class 'CLRObject' to a managed type in SYSOperation framework

(0) ShareShare
ReportReport
Posted on by 290

I want to create a menu for import some data from an excel. I know that we have data management feature and we can use this functionality however due to some reasons we need to add a menu in a form for importing the data.

For this aim I am using Sysoperation framework and I created all the related classes. There is a problem in having a paramMethod for stream object. As you know I have to get a fileStream from UIBuilder class and then pass it to contract class to have this value in service class. If I add [DataMemberAttribute, SysOperationControlVisibilityAttribute(false)] above of parmStream method then when I open my menu I will get an error which says : "Could not resolve X++ type class 'CLRObject'". If I don't add this attribute for this method in service class the stream value is null. I guess that the problem is directly related to serialization of this type of object. 

The examples of using fileupload in UIbuilder and passing the value to dataContract class are very limited. There is a class TaxSetupLookupConditionImportContract which is the most similar class to my aim but I doubt it really works because first I wrote my contract class  without adding dataMemeberAttribute and consequently the parameter values were empty in service class.  unfortunately I can't test this tax import class since GTE is not active in my machine. 

Is possible to pass Stream object through contract class?

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    It could at least theoretically work if you could serialize a stream. But it's not really possible. You can either store (and serialize) a reference to the resource (such as to a file), or download the data from the stream and store the content itself (e.g. as a container with binary data).

    If you want to use the former approach, how you can do it depends on where the data comes from. If you let a user upload a file, you'll get an upload result object and you can use methods like getDownloadUrl() to store the reference. For example, look into BankStatementImportBatch.getFromDialog().

  • Nastaran Profile Picture
    290 on at

    Thank you Martin, you saved my day, I was disappointed that I had to move my code in a runBaseBatch class.

    So this is the final code. At first I got null URL because I hadn't removed the line which getUploadedFile as once the file stored in fileStream the file is deleted from temporary stoage.

            var formRun             = this.dialog().dialogForm().formRun();
    
            FileUpload fileUpload   = formRun.control(formRun.controlId(FileUploadName));
    
            // var fileStream       = fileUpload.getUploadedFile(true);
    
            FileUploadTemporaryStorageResult fileUploadResult = fileUpload.getFileUploadResult();
    
            if(fileUploadResult != null && fileUploadResult.getUploadStatus())
    
            {
    
                contract.parmUploadURL(fileUploadResult.getDownloadUrl());
    
                contract.parmFilename(fileUpload.fileName());
    
                this.setDialogOkButtonEnabled(formRun, true);
    
            }

     As Martin said we can't pass Stream object to service class so we have to pass the URL and then get the file there using this code:

    File::UseFileFromURL(_contract.parmUploadURL())

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 > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 298 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 179 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans