My first custom script: concatenating two values

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?

Please apply and check it.

frm.doc.full_name_in_arabic = frm.doc.first_name_in_arabic + " " + frm.doc.last_name_in_arabic ;

Thanks.

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?

If not worked in refresh event then

refresh(frm) → before_save(frm)

when save click then automatically set full name

apply and chcek it.

Big thanks!
What are the possible “lifecycle hooks” in these custom scripts other than beefore save? and where can I find such info?

Controller Hooks:

https://frappeframework.com/docs/v13/user/en/basics/doctypes/controllers?revisions=true#controller-hooks

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