Refresh document on API

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



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+un…@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.

On 05-Aug-2014, at 12:31 pm, Nguyen Do Le Bao <na...@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+un…@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.



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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/21C1D038-CE92-4D99-8186-7A18E4917E6D%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
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 <na...@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+un…@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.



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+un…@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.

    For more options, visit https://groups.google.com/d/optout.
Get the document again via API.

-Anand.


On Tue, Aug 5, 2014 at 2:07 PM, Nguyen Do Le Bao <na...@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 <na…@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+un…@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.




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+un…@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.

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




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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CAAQzbF0WmfA2HH9H0vXzWjO1-qG6R_kp4HuL-w7scOk3Vzg6Ng%40mail.gmail.com.

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


On 05-Aug-2014, at 2:07 pm, Nguyen Do Le Bao <na...@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]

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 <na...@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+un…@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.




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+un…@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.

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



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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/21BAA68D-AC73-4957-99FF-63EF84B0F2B0%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
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 <na...@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 <na…@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.

    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.




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+un…@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.

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




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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cceac17e-7250-4430-a91b-94c03062233b%40googlegroups.com.

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