Posts

X++ code Date time format in D365FO

         static str getDateTimeStamp()     {                   utcdatetime  systemDateTime   = DateTimeUtil::getSystemDateTime();           utcdatetime  utcDateTimeLocal =DateTimeUtil::newDateTime(                                                                                                     DateTimeUtil::date(systemDateTime),                                                          ...

Computed columns in Views D365FO x++

Here is the computed column example in view which return Yes/No based on if condition /// <summary> /// </summary> /// return Yes if External Customer has attachment else No /// </summary> public static server str computeFileAttached() { str customerRecID; str fileAttached; str result; SysDictTable dictDocuRef = new SysDictTable(tableNum(DocuRef)); customerRecID=SysComputedColumn::returnField(tableStr(TestExtCustomerView), identifierStr(TestExtCustomerTable), fieldStr(TestExtCustomerTable, RecId)); str s = strFmt('SELECT TOP 1 %1 FROM %2 WHERE %2.%3 = %4  AND %2.%5 = %6', dictDocuRef.fieldName(fieldNum(DocuRef, RefRecId), DbBackend::Sql), dictDocuRef.name(DbBackend::Sql), dictDocuRef.fieldName(fieldNum(DocuRef, RefRecId), DbBackend::Sql),customerRecID, dictDocuRef.fieldName(fieldNum(DocuRef,RefTableId),DbBackend::Sql),"9708"); result = strFmt('ISNULL((%1), \'\')', s); return SysComputedColumn::if( SysComputedColumn::returnLiteral(...

Shrink command for AxDB Sql log file to free space in development VM D365FO

Please execute below commands in SQL Server on AxDB. USE AxDB;   GO   ALTER DATABASE AxDB SET RECOVERY SIMPLE;   GO   DBCC SHRINKFILE (N'AxDBCopy1_Log', EMPTYFILE);   GO  

X++ code how to get inner exception or error in AX 2012 D365FO

try{ } catch(Exception::Error)         {             Microsoft.Dynamics.Ax.Xpp.ErrorException ex;             str errorMsg;             ex = new Microsoft.Dynamics.Ax.Xpp.ErrorException();             errorMsg = ex.Message;             throw error(strFmt("%1",errorMsg));         }

upload file to sharepoint in D365FO x++ code

Hello Guys, Here is the code snippet to upload file into sharepoint site using x++ code D365FO.      public void uploadFiletoSharepoint()     {      //upload to sharepoint site         str site = '/Sites/TestSharepointSite';         str folder = 'TestDocumentLibrary/TestFolder';         System.UriBuilder builder = new System.UriBuilder('Test.sharepoint.com');         str host = builder.Host;         str extId = xUserInfo::getCurrentUserExternalId();         str filename = 'Testdata.csv';         SharePointDocumentStorageProvider storageProvider =             new SharePointDocumentStorageProvider(host, site, folder, extId);         storageProvider.ProviderId = DocuStorageProviderType::SharePoint;            ...

x++ code to add hyperlink to a field in D365FO

Here is a way to provide hyperlink for field. 1.Create an Extension class to the form as below. [ExtensionOf(formStr(TestHistory))] public final class  TestHistoryForm_Extension { } 2.Copy onPostRun form eventhandler and write code as below.     [FormEventHandler(formStr(TestHistory), FormEventType::PostRun)]     public static void TestHistory_OnPostRun(xFormRun sender, FormEventArgs e)     {         FormStringControl   formCtrl = sender.design().controlName(formControlStr(TestHistory,TestHistory_Voucher));         formCtrl .registerOverrideMethod(methodStr(FormStringControl, jumpRef), methodStr(TestHistoryForm_Extension, JumpRefId), sender);     } 3.write definition for JumpRefId method public void jumpRefId(FormControl _formControl)     {         MenuFunction    menuFunction;       ...

How to add new Enum value through extension in D365FO

Here is the useful link. https://docs.microsoft.com/en-us/dynamics365/unified-operations/financials/accounts-receivable/location-relationship