Refresh document on API

132 views
Skip to first unread message

Nguyen Do Le Bao

unread,
Aug 5, 2014, 3:01:37 AM8/5/14
to erpnext-dev...@googlegroups.com
Haha this may sound very ridiculous but will it possible to refresh document in API... 
This is because the API (AFAIK processed by worker) and the web front end (by web process) can open the same document. 

If this happens, on the Web, it's fairly simple to resolve -> just clear cache and reload. 
But on API, this can be troublesome :|. How do I avoid this, or resolve this for API so that at least it catch this error, refresh and try again ?

Thanks a lot!!!

Rushabh Mehta

unread,
Aug 5, 2014, 4:18:24 AM8/5/14
to erpnext-dev...@googlegroups.com
If you try to update a document that does not have the latest timestamp, it will give you an exception. You just need to catch it


Thanks a lot!!!

--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. 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.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. 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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/80688f95-47d4-4973-ab6a-d60ec97df967%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nguyen Do Le Bao

unread,
Aug 5, 2014, 4:37:45 AM8/5/14
to erpnext-dev...@googlegroups.com
Yeah, i caught the exception but how to refresh the document to access it ?
Any pointer to what server code can do that ?

On Tuesday, August 5, 2014 4:18:24 PM UTC+8, rushabh wrote:
On 05-Aug-2014, at 12:31 pm, Nguyen Do Le Bao <natha...@gmail.com> wrote:

Haha this may sound very ridiculous but will it possible to refresh document in API... 
This is because the API (AFAIK processed by worker) and the web front end (by web process) can open the same document. 

If this happens, on the Web, it's fairly simple to resolve -> just clear cache and reload. 
But on API, this can be troublesome :|. How do I avoid this, or resolve this for API so that at least it catch this error, refresh and try again ?

If you try to update a document that does not have the latest timestamp, it will give you an exception. You just need to catch it


Thanks a lot!!!

--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. 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.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. 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+unsub...@googlegroups.com.

Rushabh Mehta

unread,
Aug 5, 2014, 4:39:57 AM8/5/14
to erpnext-dev...@googlegroups.com
On 05-Aug-2014, at 2:07 pm, Nguyen Do Le Bao <natha...@gmail.com> wrote:

Yeah, i caught the exception but how to refresh the document to access it ?
Any pointer to what server code can do that ?

GET /api/resource/[DocType]/[Name]

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/0f01259d-865e-4544-a920-70d077a9fbf4%40googlegroups.com.

Anand Doshi

unread,
Aug 5, 2014, 4:40:08 AM8/5/14
to ERPNext Developer's Forum
Get the document again via API.

-Anand.


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/0f01259d-865e-4544-a920-70d077a9fbf4%40googlegroups.com.

Nguyen Do Le Bao

unread,
Aug 12, 2014, 2:54:40 AM8/12/14
to erpnext-dev...@googlegroups.com
Okay, 

Figured out what's wrong in the code. In server, gotta call frappe.get_doc(Doctype, DocName) to refresh it
Thank you!

On Tuesday, August 5, 2014 4:40:08 PM UTC+8, Anand Doshi wrote:
Get the document again via API.

-Anand.
On Tue, Aug 5, 2014 at 2:07 PM, Nguyen Do Le Bao <natha...@gmail.com> wrote:
Yeah, i caught the exception but how to refresh the document to access it ?
Any pointer to what server code can do that ?

On Tuesday, August 5, 2014 4:18:24 PM UTC+8, rushabh wrote:
On 05-Aug-2014, at 12:31 pm, Nguyen Do Le Bao <natha...@gmail.com> wrote:

Haha this may sound very ridiculous but will it possible to refresh document in API... 
This is because the API (AFAIK processed by worker) and the web front end (by web process) can open the same document. 

If this happens, on the Web, it's fairly simple to resolve -> just clear cache and reload. 
But on API, this can be troublesome :|. How do I avoid this, or resolve this for API so that at least it catch this error, refresh and try again ?

If you try to update a document that does not have the latest timestamp, it will give you an exception. You just need to catch it


Thanks a lot!!!

--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. 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.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. 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+unsubscr...@googlegroups.com.

--
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. 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.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. 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+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages