JS to populate SharePoint list "title" field with 2 other fields on save

I have 2 fields in my form that need to be concatenated to become the content of the 'Title' field in the SharePoint list on Save.

The desired outcome is that 'field_19' and 'field_3' are populated into the 'Title' field on save with a space character between the two fields.

Example:
field_19 = "Fred"
field_3 = "Jones"

Title = "Fred Jones"

I am a complete Newbie to JS so some example code would be a real help.

Dear @damianM,
Place it outside of the commented out part, and it should work:

fd.spBeforeSave(function(){
  fd.field('Title').value = fd.field('field_19 ').value + ' ' + fd.field('field_3 ').value;
});

hmm I got an error:
image
I noticed that you had an extra space at the end of the filed names - corrected the code and it works a treat - updated code:

fd.spBeforeSave(function(){
  fd.field('Title').value = fd.field('field_19').value + ' ' + fd.field('field_3').value;
});

Thank you

1 Like