Category: Dynamics 365 F&O Codes

Displaying a Message Box with yes and no option

static void JobBoxDemo(Args _args){DialogButton diagBut;str strMessage = “The No button should have initial focus.”;str strTitle = “Title”;;diagBut = Box::yesNoCancel(strMessage,DialogButton::No, // Initial focus is on the No button.strTitle);if (diagBut == DialogButton::No){print “The No button was clicked.”;}else{print “The button that was clicked was: “, diagBut;}pause;}

Rename File X++

void MoveFilesFromFoldertoAnotherFolder(){FilenameOpen fileNameOpen;DialogField dialogFileName;Dialog dialog;FileName DestinationPath;FileIOPermission FileIOPerm;#File DestinationPath = @filePathText + countingId;WinAPI::createDirectoryPath(DestinationPath);// MoveFile – The Original File won’t be available once it’s moved into destination pathWinAPI::copyFile(@filePath + ‘\\’ + fileNameText + FileType, @DestinationPath + ‘\\’ + fileNameText + FileType);WinAPI::deleteFile(@filePath + ‘\\’ + fileNameText + FileType); /*FileIOPerm = new FileIOPermission(@filePath + ‘\\’ + fileNameText + FileType,’w’);…

Upload and read CSV files in Dynamics 365 for operations

To quickly reuse the code here it goes class RGReadSample{           ///    /// Runs the class with the specified arguments.    ///    /// The specified arguments.    public static void main(Args _args)    {               AsciiStreamIo                                   file;        Array                                           fileLines;        FileUploadTemporaryStorageResult                fileUpload;        fileUpload = File::GetFileFromUser() as FileUploadTemporaryStorageResult;        file = AsciiStreamIo::constructForRead(fileUpload.openResult());        if (file)        {            if (file.status())            {                throw error(“@SYS52680”);            }            file.inFieldDelimiter(‘,’);            file.inRecordDelimiter(‘\r\n’);        }       …

Job to get cust DimensionAttributeValueSetItem or sales order DimensionAttributeValueSetItem

static void Job3(Args _args){CustTable custTable ;DimensionAttributeValueSet DimensionAttributeValueSet;DimensionAttributeValueSetItem DimensionAttributeValueSetItem;DimensionAttributeValue DimensionAttributeValue;DimensionAttribute DimensionAttribute; while select * from custTablewhere custTable.AccountNum == “‪‪‪ELC-02310-00288” join RecId from DimensionAttributeValueSetwhere DimensionAttributeValueSet.RecId == custTable .DefaultDimensionjoin RecId, DisplayValue from DimensionAttributeValueSetItemwhere DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecIdjoin RecId from DimensionAttributeValuewhere DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValuejoin RecId, Name from DimensionAttributewhere DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute && DimensionAttribute.Name == “Sales_man”// &&DimensionAttribute.Name == “Location” {info(DimensionAttribute.Name+ “—-“+…

Extensions Event handlers

OnDeleted event – This is a post-event handler that triggers when a record is deleted in the table. You could use this, for example, to display an Infolog message after a record is deleted. [DataEventHandler(tableStr(CustTable), DataEventType::Deleted)]public static void CustTable_onDeleted(Common sender, DataEventArgs e){} OnInserting event – This is triggered when data is being inserted. For example, this could trigger when…