Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to get specific record / Filter using Odata Endpoint

(0) ShareShare
ReportReport
Posted on by 2,422

Good morning,

i am trying to update Purchase order line from console application.

i found this piece of code for update

pastedimage1599666974356v1.png

this foreach loop will loop for all the records. 

In my case if i have 5000 Purchase orders it is going to check in foreach loop 4999 times.

So to avoid this i want to filter only that particular PO and that particular line record.

in my case i need to update specific line for Purchase order.

Suppose i want to update Purchase order line - Line number 2.

How can i filter records from context.PurchPurchaselineentity

Please show some light on this.

Regards,

Have a nice day.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: How to get specific record / Filter using Odata Endpoint

    I think you can use either one.

  • Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: How to get specific record / Filter using Odata Endpoint

    You can debug it  through console app as well.

  • AX 2012 r3 Profile Picture
    2,422 on at
    RE: How to get specific record / Filter using Odata Endpoint

    Hi Gunjan,

    How can we debug these kind of scenarios .

    Only through Runnable class or can we debug from console application as well by placing breakpoint in d365fo.

    What should i select in that process - iisexpress will not work?

    Please show some light on this.

    Regards,

    Have a nice day.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: How to get specific record / Filter using Odata Endpoint

    Hi,

    Your code looks correct. You may try updating some other fields as well to make sure the update is working fine.

  • AX 2012 r3 Profile Picture
    2,422 on at
    RE: How to get specific record / Filter using Odata Endpoint

    Hi Experts,

    Thanks for the help.

    I have closed this thread.

    Regards,

    Have a nice day.

  • Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: How to get specific record / Filter using Odata Endpoint

    As long as you are able to select correct lines , you should be good. We don't know your business scenario ,  the information which you shared is  you want to select and  update line which seems to be working  correct according to code you shared. If there is nothing left please close the thread.

  • AX 2012 r3 Profile Picture
    2,422 on at
    RE: How to get specific record / Filter using Odata Endpoint

    Hi all,

    Resolved with the above code.

    Please review it and let me know if that is correct or not

    pastedimage1599684749803v1.png

    Now Quantity got updated to 9.

    Please review the code and let me know is that clean code or should i change ?

    Please let me know experts.

    Regards,

    Have a nice day.

  • Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: How to get specific record / Filter using Odata Endpoint

    Please share your  code  where you are doing update. Also whats the actual validation  error ? can you share that ?

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: How to get specific record / Filter using Odata Endpoint

    Hi,

    This means that data validation is failing for the row. Can you debug the code and check where the validation is failing?

    Also, you can try updating record (with the same values) using the entity with a runnable class.

  • AX 2012 r3 Profile Picture
    2,422 on at
    RE: How to get specific record / Filter using Odata Endpoint

    Hi ,

    When i am updating  i am getting this error

    InnerException = "{\r\n  \"error\":{\r\n    \"code\":\"\",\"message\":\"An error has occurred.\",\"innererror\":{\r\n      \"message\":\"Write validation failed for table row of type 'SalesOrderLineV2Entity'. Infolog: .\",\"type\":\"Microsoft.Dynamics.Platform.Integration.S...

    can we debug this not sure what is happening i am trying to update only one field line description

    It is throwing this error

    Please show some light on this how can i skip this.

    Regards,

    Have a nice day.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,758 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans