Execute Actions in ODATA Entities & CALLING IN MICROSOFT Flow/Power Automate/Logic Apps

Requirement –

  1. Developing & adding actions on OData entities of Microsoft Dynamics 365 finance and operations
  2. Consuming and calling Data entity action in Microsoft Flow or Logic Apps Or Microsoft Power Automate


  • Create or develop a custom data entity. Read More:
  • Add a new method in your custom data entity by using Attribute -SysODataActionAttribute & SysODataCollectionAttribute
[SysODataActionAttribute("demoExecuteActionListParm", true),
        SysODataCollectionAttribute("InventSiteIdList", Types::String),
     SysODataCollectionAttribute("return", Types::String)]
    public str demoExecuteActionListParm(List InventSiteIdList)
				str	siteCommaSeperated;
				List list = new List(Types::String);
				ListEnumerator  ListEnumerator;
				ListEnumerator = InventSiteIdList.getEnumerator();
				while (ListEnumerator.moveNext())
          siteCommaSeperated += strFmt('%1, ', ListEnumerator.current()) ;

				return '200 OK:Testing Of Odata Entity ExecuteAction has been completed!! Values = ' + siteCommaSeperated;
  • Build and synchronize your project
  • Test your flow and get response successfully.

Entity store In Azure Data Lake – D365 FINANCE & OPERATIONS

What is Entity Store ?

In Microsoft Dynamics 365 finance and operations, Entity store is database (AxDW) which you can use in D365 FO POWER BI dashboards for realtime analytical reporting . Click here to read more about entity store.

What is Azure Data Lake ?

Microsoft Azure Data Lake is cloud based storage and analytics service . Azure Data lake allows data scientist and data engineer to store any kind of large data and performing analytics, machine learning & AI operations on it. Click here to read more about entity store.

Quick Steps Exporting Entity Store in Azure Data Lake

  • Deploy a new storage account in azure portal. Don,t forget to mention Account kind as  StorageV2. Most important, in Advance TAB Enable the Hierarchical namespaces feature else you will not be able to consume Azure Data Lake data in Power BI.
  • When the deployment is completed, go to your recently deployed storage account and navigate to Settings –> Access Keys . Note down the connection string value, it will be used in coming steps
  • Deploy a KEY VAULT resource in portal.azure.com as per your comfort.
  • After deployment of key vault , go to your Azure KEY VAULT resource and navigate to Settings — > Secrets.
  • Click on button + GENERATE/IMPORT & create a SECRET. Fill a name for the secret and not it somewhere as NAME will be used in next steps. In the VALUE Field please Enter the connection string i (connection string you obtained from previous steps inside STORAGE ACCOUNTS)
  • Secret KEY is created
  • Go to Azure portal, select Azure Active Directory, and then select App registrations. You need to register an App
  • After registering you APP, navigate to –>API permission and Configured permissions as mentioned below.
  • In your registered APP, navigate to –> Certificates & secrets. Generate a new client secret and copy it immediately somewhere.
  • Now go back to your KEY VAULT Resource and click on access polices.
  • In the Select principal field, select the name of the application that you previously registered.In the Key permissions field, select Get and List permissions.In the Secret permissions field, select Get and List permissions.
Get and List permissions
  • Now open your D365 finance and operations environment and go the SYSTEM PARAMETERS . Fill the below details
  • Application ID: Enter the application ID of the Azure AD application that you registered earlier.
  • Application Secret: Enter the application key (secret) for the Azure AD application.
  • DNS name: Enter the DNS name of Key Vault.
  • Secret name: Enter the name of the secret that you added to Key Vault together with connection string information.
  • Validate and Test AZURE KEY VAULT as well as AZURE DATA STORAGE
  • Refresh Entity Store
  • Now your entity store is available in Azure Data Lake.

References : entity-store-data-lake

Date functions snippet in D365 Finance & Operations & Microsoft Dynamics AX

  • Get maximum date : TransDate maximumDate = dateMax();
  • Get minimum date: TransDate minimumDate= datenull();
  • Get Current or today’s Date: TransDate todayDate = today();
  • Convert string to date:  TransDate transdate = str2Date(’26-06-2020′, 123);(day = 1, month = 2, year = 3)
  • Convert date to string: str dateStr = date2Str(today(), 123, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4, 0);
  • Convert String to datetime: utcdatetime dateTime = str2Datetime(‘26.06.2020 11:00:00 pm’, 123);
  • Get current system date time : utcdatetime currentDateTime = DateTimeUtil::getSystemDateTime();
  • Get current system date : Transdate currentDate = DateTimeUtil::getSystemDate();
  • getCompanyTimeZone = DateTimeUtil::getCompanyTimeZone();
  • getUserPreferredTimeZone = DateTimeUtil::getUserPreferredTimeZone();
  • getClientMachineTimeZone = DateTimeUtil::getClientMachineTimeZone();// get clie
  • getOriginatingTimeZone = DateTimeUtil::getOriginatingTimeZone(transDateTime); // get originating time zone
  • dateTime = DateTimeUtil::minvalue(); // get minimum value of date time
  • dateTime = DateTimeUtil::maxvalue(); // get maximum value of date time

‘RunAs’ function & method in Dynamics 365 Finance & Operations


There are some scenarios in Microsoft Dynamics 365 finance and operations where we need to run X++ program or code or business operation on the behalf of different userId other than current userId.

In my case, my X++ program of D365 finance and operations should always run under the userId- ADMIN . I can use ‘RunAs’ function & method in Dynamics 365 Finance & Operations.

Sample Code:

class AcxSharepointIntegeration
    public static container download(container _parms)
        RunAsPermission perm;
        perm = new RunAsPermission("Admin");
        Container returncontainer = runAs("Admin", classnum(AcxSharepointIntegeration), "get", _parms);
        return returncontainer;

    public static container get(container _parms)
        container con;
        // Your business Logic
        return   con; 

class AcxSharepointIntegeration
public static container download(container _parms)
RunAsPermission perm;
perm = new RunAsPermission(“Admin”);
Container returncontainer = runAs(“Admin”, classnum(AcxSharepointIntegeration), “get”, _parms);
return returncontainer;

public static container get(container _parms)
container con;
// Your business Logic
return con;

D365 FO/AX7: Sharepoint File Upload using X++

Requirement :

Uploading a file in Sharepoint online using X++ and inside from Microsoft Dynamics 365 finance and operations.


The current user id of Microsoft Dynamics 365 Finance and operations should have proper rights and privileged in Sharepoint Online.

Sample Code:

In this scenario i am creating a text file in Microsoft Dynamics 365 finance and operations and then uploading its memory Stream in Sharepoint online using X++ . You can modify the X++ code in D365 finance and operations as per your need.

class RunnableClassRun
/// /// Runs the class with the specified arguments. ///
/// The specified arguments.
public static void main(Args _args)
System.UriBuilder builder = new System.UriBuilder(“https://XXXXXX.sharepoint.com”);
str extId = xUserInfo::getExternalId();
Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider provider;
Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation documentLocation = new Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation();
provider = new Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider(“XXXXXX.sharepoint.com”, “sites/dummy”, “Shared%20Documents/MyFolder”, extId);
System.Byte[] reportBytes = new System.Byte[0]();
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
reportBytes = enc.GetBytes(“YOUR STRING/TEXT”);
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(reportBytes);
//memoryStream = comma.getStream();
documentLocation = provider.SaveFile(newGuid(), ‘TextFile.txt’, System.Web.MimeMapping::GetMimeMapping(‘TextFile.txt’), memoryStream);