Thursday, January 23, 2025

How to apply like operator, order by in D365 Odata URL.

  How to apply like operator, orderby in D365 Odata URL.

like operator in D365 Odata URL.


1. While fetching data from D365, we can apply filters.

2. In some cases, we may need to use a "like" operator.

3. To achieve this, we need to include a * in the text.

{{resource}}/data/VendorGroups?Cross-company=true&$filter=Description eq '*Test*'

4. I have tested this with three scenarios, as listed below:

  •     '*     ' -->   Prefix 
  •     '     *' -->   Suffix
  •     '*   *' --> Prefix and Suffix


With Select:

{{resource}}/data/VendorGroups?Cross-company=true&$select=VendorGroupId,DefaultPaymentTermName,Description
        &$filter=Description eq '*Test*'

Order by operator in D365 Odata URL.

1. We can apply order by for more than one field.
{{resource}}/data/VendorGroups?Cross-company=true&$orderby=dataAreaId,VendorGroupId


With Select:
{{resource}}/data/VendorGroups?Cross-company=true&$select=dataAreaId,VendorGroupId,DefaultPaymentTermName,Description
    &$orderby=dataAreaId,VendorGroupId

2. Applied order by for VendGroupId field.




MS ODATA URL

    Keep daxing!!

Monday, January 20, 2025

How to Generate a D365 Token in Logic App

There are two ways to trigger D365:

Way 1. Generate the Token 

    In this method, you generate the D365 token first and then use it to trigger D365.

    Steps to Generate the Token:

        1. Use the following URL:

        https://login.microsoftonline.com/@{parameters('Tenant Id')}/oauth2/v2.0/token

        2. Add the required Headers as below:

    {
          "Content-Type": "application/x-www-form-urlencoded"
    }

        3. Use the following format in the body:

        client_id=@{parameters('Client id')}
        &scope=@{parameters('D365URL')}%2F.default
        &client_secret=@{parameters('Client secret')}
        &grant_type=client_credentials

        Once the token is generated, you can use it to trigger D365.

        Expression:

     {
         "Authorization" : "Bearer @{body('Generate_D365_Token')?['access_token']}"
     }

            The token remains valid for up to 1 hour, allowing you to reuse it for multiple triggers during this time.

        Output:


Way2. Pass the Values Directly

        In this method, you do not need to generate a token separately. Instead, you pass the Client ID, Client Secret, and Tenant ID directly in the same step.


If you are triggering D365 multiple times within a Logic App, you must pass these values for each step.



Keep Daxing!!