Question

I am looking to create a Ui form section in my application that will Dynamically Add Remove UiApp Form Elements. I was trying to use the example from App Script Tutorials here

This example works great as far as performing the add remove elements, but when I use the submit button to capture the values, it submits as a JSON.stringify format. When I just want to capture the values only in a text or string format that will be added to a html email.

If there is way to convert JSON.stringify to text, string or get the values only in format, I will continue to use this example.

If not I was wonder if the following Javascript HTML code can be convert into GAS code and able to capture the values for each entry in a HTML email template to using in MailApp.

http://jsfiddle.net/g59K7/

Any suggestions, examples or adjustments to the codes would be greatly appreciated.

Thank you in advance

Was it helpful?

Solution

If you don't want the result to be in a JSON object, then you can adjust the _processSubmittedData(e) function. Right now he has it writing everything to an Object, which is fine. All you have to do is have a way to parse it:

  function _processSubmittedData(e){
  var result = {};
  result.groupName = e.parameter.groupName;
  var numMembers = parseInt(e.parameter.table_tag);
  result.members = []; 
  //Member info array
  for(var i=1; i<=numMembers; i++){
        var member = {};
        member.firstName = e.parameter['fName'+i];
        member.lastName = e.parameter['lName'+i];
        member.dateOfBirth = e.parameter['dob'+i];
        member.note = e.parameter['note'+i];
        result.members.push(member);
  }

  var htmlBody = 'Group Name: ' + result.groupName;
  for(var a in result.members) {
    var member = result.members[a];
    var date = member.dateOfBirth;
    var last = member.lastName;
    var first = member.firstName;
    var note = member.note;

    htmlBody += first + ' ' + last + ' was born on ' + date + ' and has this note: ' + note;
  }

  MailApp.sendEmail('fakeEmail@fake.com',"Test Subject Line", "", {htmlBody: htmlBody});
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top