client side scripting help

75 views
Skip to first unread message

Syed Qadeer

unread,
Mar 6, 2013, 1:45:44 AM3/6/13
to erpnext-dev...@googlegroups.com
hello,

i am writing the custom client side scripting , earlier i thought that i could use the jquery.

but this isnt the case.

i am trying to add a field called "HOME NUMBER".... field name : "home_number"

the user must enter the home number , if he selects the another field which is checkbox called , "i have a home number". field_name : "select_home"

cur_frm.cscript.select_home = function(doc, cdt, cdn) {

if(doc.select_home == 1)
   {

 

      doc.home_number.style.display = "block";
 

}
else
{
   doc.home_number.style.display = "none";
}
    refresh_field('home_number');
}

cur_frm.cscript.select_home; // i just tried to run this trigger but i dont know how to run this trigger from here....

i tried something like this as well

$('input[name="home_number"]').val(); // this returns me undefined , whereas if i go and execute this on console i get the value for this same command.




any help with this guys.

Rushabh Mehta

unread,
Mar 6, 2013, 1:47:53 AM3/6/13
to erpnext-dev...@googlegroups.com
Please use gist or pastebin to share code snippets. Its not readable otherwise.



--
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 post to this group, send email to erpnext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/Zf80HxSK3dkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta

Syed Qadeer

unread,
Mar 6, 2013, 1:58:47 AM3/6/13
to erpnext-dev...@googlegroups.com
hi rusabh,

please find the below link

https://gist.github.com/anonymous/5097290



On Wednesday, 6 March 2013 09:47:53 UTC+3, rushabh wrote:
Please use gist or pastebin to share code snippets. Its not readable otherwise.
On Wed, Mar 6, 2013 at 12:15 PM, Syed Qadeer <sdqad...@gmail.com> wrote:
hello,

i am writing the custom client side scripting , earlier i thought that i could use the jquery.

but this isnt the case.

i am trying to add a field called "HOME NUMBER".... field name : "home_number"

the user must enter the home number , if he selects the another field which is checkbox called , "i have a home number". field_name : "select_home"

cur_frm.cscript.select_home = function(doc, cdt, cdn) {

if(doc.select_home == 1)
   {

 

      doc.home_number.style.display = "block";
 

}
else
{
   doc.home_number.style.display = "none";
}
    refresh_field('home_number');
}

cur_frm.cscript.select_home; // i just tried to run this trigger but i dont know how to run this trigger from here....

i tried something like this as well

$('input[name="home_number"]').val(); // this returns me undefined , whereas if i go and execute this on console i get the value for this same command.




any help with this guys.

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

To post to this group, send email to erpnext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/Zf80HxSK3dkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Rushabh Mehta

unread,
Mar 6, 2013, 2:04:58 AM3/6/13
to erpnext-dev...@googlegroups.com
Hi,

This script is executed before the form is loaded so you have to write all functions in a trigger.

Please see examples here for how to achieve this:


(for a sample see "Make Attachments Mandatory") -- you can use a similar function to make selective mandatory.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

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

To post to this group, send email to erpnext-dev...@googlegroups.com.

Syed Qadeer

unread,
Mar 6, 2013, 2:37:00 AM3/6/13
to erpnext-dev...@googlegroups.com
let me put it this way ... if i want to hide an element during the page/form load based upon the value in the textbox??

how can i do that ??

Rushabh Mehta

unread,
Mar 6, 2013, 3:09:31 AM3/6/13
to erpnext-dev...@googlegroups.com
Declare a function in cur_frm.cscript.custom_refresh and add you code there.


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

To post to this group, send email to erpnext-dev...@googlegroups.com.

Syed Qadeer

unread,
Mar 6, 2013, 6:19:31 AM3/6/13
to erpnext-dev...@googlegroups.com
just need 1 more help over here ...

i am trying to run a condition during the save for the Employee.

https://gist.github.com/anonymous/5098651

and i am calling the "cur_frm.cscript.on_submit = function(doc)"

but this is not getting executed....

Nabin Hait

unread,
Mar 6, 2013, 6:21:34 AM3/6/13
to erpnext-dev...@googlegroups.com
Use "custom_on_submit" instead of "on_submit"

Regards,
Nabin Hait

--
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 post to this group, send email to erpnext-dev...@googlegroups.com.

Syed Qadeer

unread,
Mar 6, 2013, 6:51:15 AM3/6/13
to erpnext-dev...@googlegroups.com
this is still not working ... i am not getting the alertbox...


On Wednesday, 6 March 2013 14:21:34 UTC+3, Nabin Hait wrote:
Use "custom_on_submit" instead of "on_submit"

Regards,
Nabin Hait

On 06-Mar-2013, at 4:49 PM, Syed Qadeer wrote:

just need 1 more help over here ...

i am trying to run a condition during the save for the Employee.

https://gist.github.com/anonymous/5098651

and i am calling the "cur_frm.cscript.on_submit = function(doc)"

but this is not getting executed....

--
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,
Mar 6, 2013, 6:53:18 AM3/6/13
to erpnext-dev...@googlegroups.com
There could be a syntax Error.

Also on_submit is not called while saving, you have to use custom_validate function to write your event.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

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

To post to this group, send email to erpnext-dev...@googlegroups.com.

Syed Qadeer

unread,
Mar 6, 2013, 7:02:18 AM3/6/13
to erpnext-dev...@googlegroups.com
hey rusabh, thanks for that .. it is working however, if you see the above code .. i am returning false if the condition fails, but even though i am returning false.. the data is getting saved in the database. it is not coming out of that ??

Syed Qadeer

unread,
Mar 6, 2013, 7:07:32 AM3/6/13
to erpnext-dev...@googlegroups.com
got it working,.. thanks..

and rusabh i now understand what you meant by "Make attachments mandatory:"
Reply all
Reply to author
Forward
0 new messages