concatenating fields into a new field

frappe.ui.form.on('Sales Invoice', 'before_save', function(frm) {{


args: {


filters: {

name: frm.doc.shipping_address_name


fieldname:["address_line1", "address_line2", "city", "state"]


callback: function(r) {

// console.log(r.message.address_line2);

var a = r.message.address_line1 + ', ' + r.message.address_line2;

var b = + ', ' + r.message.state;



// set the returned value in the fields

cur_frm.set_value('address_1_and_2', a);

cur_frm.set_value('city_and_state', b);




Some important notes:

  • This was done // on saving / before_save, pull city and state values from address based on standard address shipping name and populate city_and_state field (both are custom fields)

  • console.log is (obviously) just for checking, but always good practice

  • r is a collection variable in JSON (?) format that needs to be parsed to its message and fields (which was also pulled during

  • frappe.client.get_value is for client side scripting, while frappe.db.get_value is for server side scripting