web
You’re offline. This is a read only version of the page.
close
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,426

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.

I have the same question (0)
  • Verified answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    You can use LINQ query to fetch the line. Take a look at below article to see how it is used.

    stoneridgesoftware.com/.../

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    You can check the example here for filtering specific records.

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi all,

    I found this URL

    "axguru.com/.../"

    This pic is from URL how this is possible

    pastedimage1599670211839v1.png

    how can i achieve same thing

    But when i used same thing i am getting error.

    pastedimage1599670382729v2.png

    Please suggest me how can i use linq Query should i have to install any assembly for that?

    Regards,

    Have a nice day

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    I have referred to using System.Linq;

    Its working now.

    Let me test more and come back.

    Regards

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi AX 2012_r3,

    You need to import the namespace System.Linq at the beginning of the file.

    using System.Linq

    docs.microsoft.com/.../working-with-linq

  • AX 2012 r3 Profile Picture
    2,426 on at

    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.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    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.

  • Sukrut Parab Profile Picture
    71,710 Moderator on at

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

  • AX 2012 r3 Profile Picture
    2,426 on at

    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,710 Moderator on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans