Showing posts with label ODATA. Show all posts
Showing posts with label ODATA. Show all posts

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!!

Thursday, January 16, 2025

How to get total record count and Top 10 records from D365 Odata GET URL.

How to get total record count, Top 10 records from D365 Odata URL.

Get Total Record count by Odata URL.

1. To retrieve the total record count, we need to use the $count=true keyword in the URL.
{{resource}}/data/VendorGroups?Cross-company=true&$count=true


Get Top 3 records by Odata URL.

1. To retrieve the top 3 records, We need to use $top=3 keyword in the URL.
{{resource}}/data/VendorGroups?Cross-company=true&$top=3

Keep Daxing!!

Wednesday, January 8, 2025

How to Fetch Header and Line Information in a Single D365 OData GET URL

How to Fetch 2 entities Information in a Single D365 OData GET URL


1. When using the GET operation, it retrieves all information from the specified entity by default.

2. In some cases, we need information from two related tables, such as header and line data. For this we need to trigger D365 twice with different URL.

3. To achieve this, a relationship must exist between these two entities.

4. In the example below, I fetched data from PurchaseOrderHeadersV2 and PurchaseOrderLinesV2.
   
    The below purchase order has 2 lines:


5. I used the
$expand keyword to include data from the related table and $select to specify the fields to retrieve.

{{resource}}/data/PurchaseOrderHeadersV2?$filter=dataAreaId eq 'USMF' and PurchaseOrderNumber eq 'PO-000218'
  &Cross-company=true&$select=dataAreaId,PurchaseOrderNumber,OrderVendorAccountNumber,PurchaseOrderName,PurchaseOrderStatus
  &$expand=PurchaseOrderLinesV2 ($select=dataAreaId,PurchaseOrderNumber,LineNumber,OrderedPurchaseQuantity,ItemNumber,PurchasePrice)

6. Below is an example URL without using the $select keyword:

{{resource}}/data/PurchaseOrderHeadersV2?$filter=dataAreaId eq 'USMF' and PurchaseOrderNumber eq 'PO-000218'
  &Cross-company=true&$select=dataAreaId,PurchaseOrderNumber,OrderVendorAccountNumber,PurchaseOrderName,PurchaseOrderStatus
  &$expand=PurchaseOrderLinesV2



Without Purchase order filter.

{{resource}}/data/PurchaseOrderHeadersV2?$filter=dataAreaId eq 'USMF' &Cross-company=true
&$select=dataAreaId,PurchaseOrderNumber,OrderVendorAccountNumber,PurchaseOrderName,PurchaseOrderStatus
&$expand=PurchaseOrderLinesV2 ($select=dataAreaId,PurchaseOrderNumber,LineNumber,OrderedPurchaseQuantity,ItemNumber,PurchasePrice)


MS ODATA URL


Keep daxing!!


Monday, January 6, 2025

How to Select Required Fields in D365 OData URL

How to Select Required Columns in a D365 OData URL.



1. When using the GET operation, the system retrieves all the fields available in the data entity by default.

2. In real-time scenarios, we need only specific fields for our process. To achieve this, we can use the $select keyword in the GET URL.

3. Using $select, you can specify the fields that you want to retrieve.
?$select=FieldNames

4. Below is an example URL I used for testing:
{{resource}}/data/VendorGroups?Cross-company=true
    &$select=VendorGroupId,DefaultPaymentTermName,Description


5. Below is the output:





In the above URL, no filter was applied. If you want to retrieve a specific record, you can apply a filter by adding the $filter keyword to the URL.


I applied a filter using the dataAreaId and vendGroupId fields.
{{resource}}/data/VendorGroups?Cross-company=true&$filter=dataAreaId eq 'USMF' 
and VendorGroupId eq '10'
&$select=dataAreaId,VendorGroupId,DefaultPaymentTermName,Description


Keep Daxing!!

Thursday, March 9, 2023

ODATA Filters


ODATA Filters.


GET :

URL/data/CustomersV3?$filter=CustAccount eq '56'&dataAreaId eq 'DAT'&cross-company=true
URL/data/CustomersV3?cross-company=true


Patch or PUT:

URL/data/CustomersV3(dataAreaId='DAT',CustomerAccount='77')?Cross-company=true



Using Enums:

Microsoft.Dynamics.DataEntities.Gender'Male'

Microsoft.Dynamics.DataEntities.NoYes'Yes'

            Using in filter: 

        1. URL/CustomersV3?\$filter=PersonGender eq Microsoft.Dynamics.DataEntities.Gender'Male'
       2. URL/CustomersV3?$filter=PersonGender eq Microsoft.Dynamics.DataEntities.Gender'Male'
        URL/data/Currencies?\$filter=ReferenceCurrencyForTriangulation eq Microsoft.Dynamics.DataEntities.NoYes'No'

            Using to update:

        URL/data/CustomersV3(dataAreaId='usmf',CustomerAccount='1001', 
                                PersonGender= Microsoft.Dynamics.DataEntities.Gender'Male')?Cross-company=true


Keep Daxing!! 

No resources were found when selecting for update. In ODATA

 While updating the customer I am getting the below error :

"No resources were found when selecting for update"

So I have made the changes URL.

URL/data/CustomersV3(dataAreaId='DAT',CustomerAccount='77')?Cross-company=true

"More than one resource was found when selecting for update" for this also we can use the above URL.


Keep Daxing!!