SamSam
June 14, 2022, 12:04pm
#1
Hi all,
I didn’t find much useful examples on:
https://docs.erpnext.com/docs/v12/user/manual/en/customize-erpnext/custom-scripts
So I am trying to figure out how to use custom scripts.
What I am attempting to do is simply: concatenating the value first_name_in_arabic with last_name_in_arabic
Is there any documentation that reveals all the possible methods I can use there?
NCP
June 14, 2022, 12:11pm
#2
Please apply and check it.
frm.doc.full_name_in_arabic = frm.doc.first_name_in_arabic + " " + frm.doc.last_name_in_arabic ;
Thanks.
SamSam
June 14, 2022, 12:15pm
#3
Ah yes, the missing " " wasn’t the issue.
My issue that it’s not doing anything in that target form when I filling first name in arabic and last name in arabic; it is not filling automatically the full_name_in_arabic field.
and no error is thrown, nothing. What am I missing?
NCP
June 14, 2022, 12:21pm
#4
If not worked in refresh event then
refresh(frm) → before_save(frm)
when save click then automatically set full name
apply and chcek it.
SamSam
June 14, 2022, 12:23pm
#5
Big thanks!
What are the possible “lifecycle hooks” in these custom scripts other than beefore save? and where can I find such info?
NCP
June 14, 2022, 12:24pm
#6
peterg
June 14, 2022, 1:34pm
#8
In addition to those server-side hooks, the client side hooks are here:
https://frappeframework.com/docs/v13/user/en/api/form#form-events
you can use validate() instead of refresh()
validate(frm){
let full_name_in_arabic = frm.doc.first_name_in_arabic + " " + frm.doc.last_name_in_arabic;
frm.set_value('full_name_in_arabic', full_name_in_arabic);
}
This will update value in full_name_in_arabic once the document is saved