Change in Client Custom Script handling

Hi everyone,

Many of you are now using Client Custom Scripts to make ERPNext work for your needs.

WNFramework fires standard cur_frm.cscript functions and cur_frm.cscript.custom_ functions in parallel. Hence, to use ajax requests, you would have to use setTimeout hacks.

We are going to change that from tomorrow. Once released, all cur_frm.cscript.custom_ functions will be called as callbacks to cur_frm.cscript standard functions. 
As for how it is handled, you can check the trigger function here:
https://github.com/webnotes/wnframework/blob/f6f54d7027e1394337b0e2b01a9bc9e08f213dd9/public/js/wn/form/script_manager.js#L8

Ideally, your existing custom scripts shouldn't be affected. If you have any queries or can think of any possible problems with this change, please reply to this thread. 

Thanks,
Anand Doshi.



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.

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

     

     
Hello, Anand!

In my view, you could take an initiative differentiated.

Already have some time I've been thinking about, links instead of custom code to be part of the native code, why not leave it out in another file, eg "my_doctype.custom.js"


That extends through the object ClientScriptApi cscript, with custom methods.

I say this not only because of JS code, but python code too.


It's funny, when I want to encode new functionalities in my fork, I can not keep the updates current, only when I finish, I apply the same and check what has changed, and I review my code.


If there is an API for customization, this would leave the thing and leaner, I say this because, I do not even need to keep a fork full ERPNext, and Wnframework, but only the files *. Custom. *

If you consider that a simple "my_doctype_custom from import *" in python code already solve most issues callback.

In the javascript this separation would also be advantageous.

Even before I had my codes as Custom Code (Client and Server)


But for reasons of performance, we are migrating everything to the server side, but in counterpart, created problems with Git merge.


See, we're working on 4 features simultaneously to meet Brazilian law, for us, it would be more practical to just keep our code, and leave it up to you to manage the core application, but due to the current model of Development also, we we must actively participate in the changes in the nucleus, even in our local repositories.

Recently I even proposed a hack with setTimeout, because there is a problem with get_query, and still keep this hack on my fork, why the code does not run in my application.

I'm sure two points:
My repository is as up to date as yours
I have no customization on "customer_address" which is where the error is caused.

So that's it, just let my humble comments on this issue.




2013/7/29 Anand Doshi <an...@iwebnotes.com>
Hi everyone,

Many of you are now using Client Custom Scripts to make ERPNext work for your needs.

WNFramework fires standard cur_frm.cscript functions and cur_frm.cscript.custom_ functions in parallel. Hence, to use ajax requests, you would have to use setTimeout hacks.

We are going to change that from tomorrow. Once released, all cur_frm.cscript.custom_ functions will be called as callbacks to cur_frm.cscript standard functions.
As for how it is handled, you can check the trigger function here:

Ideally, your existing custom scripts shouldn't be affected. If you have any queries or can think of any possible problems with this change, please reply to this thread.

Thanks,
Anand Doshi.



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.

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







--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
www.realizemodulados.com.br



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.

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

     

     

Hi Max,


Storing custom code in the database offers the same advantage as writing the custom code in the file. It doesn’t cause any conflicts. On your own server, you can even have server side custom script. Also, your scripts are included in the database backup so that the customization is not lost. 

But files option does seem to be a cleaner design, atleast from a developer’s perspective. Maybe we can have both options.
Can you raise this as an issue here: Pull requests · webnotes/wnframework · GitHub
Also, put a link to this thread in the description for reference.

This is a big change and we won’t be able to do it very soon. But an issue will help us keep track of it.

Thanks,
Anand.


On Monday, July 29, 2013 11:02:25 PM UTC+5:30, Maxwell wrote:
Hello, Anand!

In my view, you could take an initiative differentiated. 

Already have some time I’ve been thinking about, links instead of custom code to be part of the native code, why not leave it out in another file, eg “my_doctype.custom.js” 


That extends through the object ClientScriptApi cscript, with custom methods. 

I say this not only because of JS code, but python code too. 


It’s funny, when I want to encode new functionalities in my fork, I can not keep the updates current, only when I finish, I apply the same and check what has changed, and I review my code. 


If there is an API for customization, this would leave the thing and leaner, I say this because, I do not even need to keep a fork full ERPNext, and Wnframework, but only the files *. Custom. * 

If you consider that a simple "my_doctype_custom from import *" in python code already solve most issues callback. 

In the javascript this separation would also be advantageous. 

Even before I had my codes as Custom Code (Client and Server) 


But for reasons of performance, we are migrating everything to the server side, but in counterpart, created problems with Git merge. 


See, we're working on 4 features simultaneously to meet Brazilian law, for us, it would be more practical to just keep our code, and leave it up to you to manage the core application, but due to the current model of Development also, we we must actively participate in the changes in the nucleus, even in our local repositories. 

Recently I even proposed a hack with setTimeout, because there is a problem with get_query, and still keep this hack on my fork, why the code does not run in my application. 

I'm sure two points: 
My repository is as up to date as yours 
I have no customization on "customer_address" which is where the error is caused. 

So that’s it, just let my humble comments on this issue.




2013/7/29 Anand Doshi <an...@iwebnotes.com>
Hi everyone,

Many of you are now using Client Custom Scripts to make ERPNext work for your needs.

WNFramework fires standard cur_frm.cscript functions and cur_frm.cscript.custom_ functions in parallel. Hence, to use ajax requests, you would have to use setTimeout hacks.

We are going to change that from tomorrow. Once released, all cur_frm.cscript.custom_ functions will be called as callbacks to cur_frm.cscript standard functions. 
As for how it is handled, you can check the trigger function here:

Ideally, your existing custom scripts shouldn't be affected. If you have any queries or can think of any possible problems with this change, please reply to this thread. 

Thanks,
Anand Doshi.



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.

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

 

 




--


Maxwell Morais

(+55 11) 3931-1412 Ramal 31
 www.realizemodulados.com.br



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.

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