Expand my Community achievements bar.

SOLVED

Need help with javascript...

Avatar

Level 4

I have a form that I want to email. When it creates the email, I have a script that inputs the sender's email, a subject line that inputs the name of the person filling the form from the "empName" field, and the body text including the employee name as well as the date specified in the "weekEnd" field. I want to add the totals for each row (Regular, Vacation and Sick). For some reason the script breaks when I try to add the row totals. Here is my script when it works:

var oDoc = event.target;

oDoc.mailDoc({
bUI: true,
cTo: "jsmith@example.com",
cCC: "dpsmith@example.com",
cSubject: "Weekly Employee Time Summary for "+empName.rawValue,
cMsg: "Attached is the Weekly Employee Time Summary for "+empName.rawValue +" for the week ending "+weekEnd.formattedValue
});

If I just add one of the row totals, the submit button doesn't work. Here is the code with the addition of one row total:

var oDoc = event.target;

oDoc.mailDoc({
bUI: true,
cTo: "jsmith@example.com",
cCC: "dpsmith@example.com",
cSubject: "Weekly Employee Time Summary for "+empName.rawValue,
cMsg: "Attached is the Weekly Employee Time Summary for "+empName.rawValue +" for the week ending "+weekEnd.formattedValue +". Vacation Total: "+vacTotal.rawValue
});

Any ideas why it's failing? Attached is the file itself

https://drive.google.com/uc?export=download&id=0B3ZhSiIWrwvWUUhfa0hCZlJFX00

1 Accepted Solution

Avatar

Correct answer by
Level 10

You should write the path to the object... you can only access the object if it's in the same subform or if it has a similar parent

you should write this to access your total value inside the table

Table1.vacation.vacTotal.rawValue

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

You should write the path to the object... you can only access the object if it's in the same subform or if it has a similar parent

you should write this to access your total value inside the table

Table1.vacation.vacTotal.rawValue

Avatar

Level 4

One more followup question. Is it possible to add some code to the script that would set any empty integer fields to 0? I'm guessing some form of if statement with isNull.