Re: Getting all documents of a certain Doctype

John,

Welcome to the forum!

I just checked and get in client.py is only designed to get one record.

The new API in version 4 will fix all your issues: /api/resource/Item?fields=*

will return all items & it will work with filters too... /api/resource/Item?filter={"is_stock_item":"Yes"}&fields=*

in version 3, use

cmd=webnotes.widgets.reportview.get

https://github.com/webnotes/wnframework/blob/develop/webnotes/widgets/reportview.py#L11

(all whitelisted methods can be directly called via cmd)

parameters here:

https://github.com/webnotes/wnframework/blob/develop/webnotes/widgets/reportview.py#L28





On Wednesday, April 2, 2014 4:22:43 PM UTC+5:30, John Green wrote:
Hello community,

I am new here and have since recently integrated the wn-client API into my own custom application to get, insert and update documents from my ERPNext system.
Inserting and updating docs work just fine. Getting a document from a certain doctype by name also works.
The problem is that I am unable to get all the documents of a certain doctype, I keep getting the first item.
I have tried getting documents by filters in the hope that the result would be a list of all matching docs that match the filter, like so:

https://[my_erp].erpnext.com/server.py?cmd=webnotes.client.get&doctype=Item&filters={"is_stock_item" : "Yes"}

The return value of this is the first document that matches the filter instead of all the documents that match the filter. Are filters supposed to return just one item?
I also tried the following statement:

https://[my_erp].erpnext.com/server.py?cmd=webnotes.client.get&doctype=Item

I believed that this would return all the documents of the doctype Item, but i get the error message: Item Item does not exist
Could you please explain to me how I am supposed to get all the documents of a certain Doctype.

Yours sincerely,
John Green



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/05210ef3-24f0-483a-bca4-2e3df2036617%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Thank you for your help rushabh, that is just what I needed.

In case anyone has the same problem, here is the commando i used to get all of items.

https://[my_erp].erpnext.com/server.py?cmd=webnotes.widgets.reportview.get&doctype=Item&fields={* : *}



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cc8238e8-898e-48b7-99b2-567b9a4e2b52%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
The commando I posted above returns all of the fields of the doctype Item, that is not always necessary.
To be more specific about which fields you want to return add them within the JSON object like so:

https://[my_erp].erpnext.com/server.py?cmd=webnotes.widgets.reportview.get&doctype=Item&fields={"barcode" : "*", "name" : "*"}



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/34f41321-cc80-45d2-9b0d-fa701a3f995a%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.