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

Dialog for Excel upload in Batch Job (SysOperation Framework)

(0) ShareShare
ReportReport
Posted on by 644

Hi,

I'm working for import Excel file in Batch Processing. So requirement is to create a dialog for excel upload in SysOperation framework batch job.

So for this I have to create UI builder. Please anyone can help me to create dialog for excel upload.

Regards,

D365FO_Avatar

I have the same question (0)
  • Blue Wang Profile Picture
    on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Hi Sir,

    Have you tried to use Data Management Framework?

    No code required.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Hi D365FO Avatar,

    I also suggest to use Data management if you want to import Excel in batch.

  • D365FO Avatar Profile Picture
    644 on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Yes, I can use Data Management but user wants to have a separate form for it. He don't want to use DMF.

    Although, we'll insert the data in a table and process it in a batch job as it'll be mass upload.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    The upload itself can't happen in batch if the file is coming from the user's computer. Only the processing can happen as batch.

    So perhaps it's easiest to separate the two.

    1) Upload Excel and save the data to a table (not in batch)

    2) Process the table data in batch (using SysOperation)

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Hi D365FO_Avatar,

    What works out of the box is the following:

    * Create an embedded PowerApp "UI" that allows users selecting the files to be uploaded

    * The files selected are temporarily stored in an upload folder on SharePoint

    * A periodic (electronic reporting) batch grabs the new files and uploads them to D365FO

    * Once the upload is completed the original files are automatically moved to an archive folder.

    The configuration of this can be made in the standard application without coding.

    Best regards,

    Ludwig

  • Blue Wang Profile Picture
    on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Hi Sir,

    Please go through this thread:

    community.dynamics.com/.../import-csv-in-d365-through-sysoperationframework

  • D365FO Avatar Profile Picture
    644 on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Hi Nikolaos Mäenpää,

    The user will upload mass data and for this case they want to upload the data in batch.

    I have created a Controller class , service class, contract class and UI Builder class for this process.

    but facing issue as I'll share the code.

    For Controller class

    class MassProductUploadController extends SysOperationServiceController
    {
      
       protected void new()
        {
            super();
            this.parmClassName(classStr(MassProductUploadService));
            this.parmMethodName(methodStr(MassProductUploadService, processOperation));
        }
    
        /// 
        /// Assign the caption on batch processing
        /// 
        ///  A string that is shown on Batch description 
        public ClassDescription defaultCaption()
        {
            return "@MassProductUpload";
        }
    
        /// 
        /// Initialize the class MassProductUploadController
        /// 
        ///  Return the object of the class 
        public static MassProductUploadController construct()
        {
            return new MassProductUploadController();
       }
    
        /// 
        /// Runs the class with the specified arguments.
        /// 
        /// The specified arguments.
        public static void main(Args _args)
        {
            MassProductUploadController  controller  =   MassProductUploadController::construct();
            controller.startOperation();
        }
    

    For service  class.

    class MassProductUploadService extends SysOperationServiceBase
    {   
        DMFDefinitionGroup               definitionGroup;
        DMFDefinitionGroupEntity         dmfDefinitionGroupEntity;
        DMFExecutionId                   executionId;
        str                              fileId;
        protected    str                 fullFileName;
        protected    System.IO.Stream    fileStream;
        FileUpload                       fileUpload;
        str                              filePath;
        FileUploadTemporaryStorageResult fileUploadResult
    
     
     public void processOperation(MassProductUploadContract  _massProductUploadContract)
        {
            DictDataEntity                  entity = new DictDataEntity(tableNum(StgMassProductUploadEntity));
            InventTable                     inventTable;
            int                             i;
            MCSMassProductUpload            mcsMassProductUpload;
    
      
            fileUpload =  _massProductUploadContract.parmFileUpload();
    
    }
    
    }

    For contract class

    [DataContractAttribute, SysOperationContractProcessingAttribute(classStr(MassProductUploadUIBuilder))]
    public class MassProductUploadContract
    {    
        FileUpload                        fileUpload;
        FilePath                          filePath;
    
        [DataMemberAttribute('FileUpload'), SysOperationLabelAttribute('File Upload')]
        public FileUpload parmFileUpload(FileUpload _fileUpload = fileUpload)
        {
            fileUpload = _fileUpload;
    
            return fileUpload;
        }
    
        [DataMemberAttribute('FilePath'), SysOperationLabelAttribute('Upload excel file')
            , SysOperationDisplayOrderAttribute('1'), SysOperationHelpTextAttribute(literalstr('Assign file path'))]
        public filepath parmFilePath(FilePath _filePath = filePath)
        {
            filePath = _filePath;
    
            return filePath;
        }
    
    }

    For UI Builder class

    class MassProductUploadUIBuilder extends SysOperationAutomaticUIBuilder
    {
        MassProductUploadContract  contract;
        Dialog           dlg;
        DialogField     dialogApprover;
        DialogField     dialogSiteId;
        DialogField     dialogInventLocationId;
        DialogField     dialogFilePath;
        str             FileUploadName = 'FileUpload';
        private const str OkButtonName = 'Upload';
        str             fileUrl;
        FileUploadBuild dialogFileUpload;
    
        
        /// 
        /// Build method
        /// 
        public void build()
        {
            DialogGroup dlgGrp;
            contract  = this.dataContractObject();
            dlg = this.dialog();
    
            //make required modifications to the dialog
            dlgGrp = dlg.addGroup('File Upload');
            dlgGrp.columns(1);
    
            FormBuildControl formBuildControl = dlg.formBuildDesign().control(dlgGrp.name());
            dialogFileUpload = formBuildControl.addControlEx(classstr(FileUpload), FileUploadName);
            dialogFileUpload.baseFileUploadStrategyClassName(classstr(FileUploadTemporaryStorageStrategy));
            dialogFileUpload.fileNameLabel("@SYS308842");
            dialogFileUpload.resetUserSetting();
            dialogFileUpload.style(FileUploadStyle::MinimalWithFilename);
            dialogFileUpload.fileTypesAccepted('.xlsx');
            this.controller().batchInfo().parmBatchExecute(NoYes::Yes);
        }
    
        protected FormControl getFormControl(DialogRunbase _dialog, str _controlName)
        {
            return _dialog.formRun().control(_dialog.formRun().controlId( _controlName));
        }
    
        private void setDialogOkButtonEnabled(DialogRunbase _dialog, boolean _isEnabled)
        {
            FormControl okButtonControl = this.getFormControl(_dialog, OkButtonName);
            if (okButtonControl)
            {
                okButtonControl.enabled(_isEnabled);
            }
        }
    
        protected void uploadCompleted()
        {
            FileUpload fileUpload = this.getFormControl(dialog, FileUploadName);
            fileUpload.notifyUploadCompleted -= eventhandler(this.UploadCompleted);
            fileUrl = fileUpload.fileName();
            this.setDialogOkButtonEnabled(dialog, true);
        }
    
        /// Disables the dialog Ok button until the file upload is complete.
        public void dialogPostRun(DialogRunbase _dialog)
        {
            FileUpload fileUpload = this.getFormControl(_dialog, FileUploadName);
            fileUpload.notifyUploadCompleted  = eventhandler(this.uploadCompleted);
            this.setDialogOkButtonEnabled(_dialog, false);
        }
    
        public void getFromDialog()
        {
            FileUpload                       fileUploadControl = dlg.formRun().control(dlg.formRun().controlId(FileUploadName));
            FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult() as FileUploadTemporaryStorageResult;
    
            if (fileUploadResult != null && fileUploadResult.getUploadStatus())
            {
                fileUrl = fileUploadResult.getDownloadUrl();
            }
            contract.parmFilePath(fileUrl);
            super();
                  
        }
    
        public void run()
        {
            try
            {
                ttsbegin;
                FileUpload fileUploadControl = this.getFormControl(dlg, FileUploadName);
                FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult() as FileUploadTemporaryStorageResult;
                info(strfmt("-%1",fileUploadResult));
                if (fileUploadResult != null && fileUploadResult.getUploadStatus())
                {
                    fileUrl = fileUploadResult.getDownloadUrl();
                    info(strfmt("%1", fileUrl));
                }
                ttscommit;
            }
            catch (Exception::Deadlock)
            {
                retry;
            }
        }
    
    }

    I m facing issue in the code. when I m running it it causing error as invalid.

    and also I found that controller class is not executing Service class.

    Where I'm wrong??

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    Hi D365FO Avatar,

    the first step is to find out where the error comes from, and try to get the actual error message.

  • D365FO Avatar Profile Picture
    644 on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    This error is coming on opening the form.

    pastedimage1607418192298v1.png

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Dialog for Excel upload in Batch Job (SysOperation Framework)

    You need to debug it.

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 2,188

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 593 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans