iprint2 Posted November 21, 2017 Posted November 21, 2017 This is what I need it to look like. It’s my pleasure to provide you with the enclosed annual endowment report(s) for the <Designation 1>. It’s my pleasure to provide you with the enclosed annual endowment report(s) for the <Designation 1> and the <Designation 2>. It’s my pleasure to provide you with the enclosed annual endowment report(s) for the <Designation 1>, <Designation 2> and the <Designation 3>. It’s my pleasure to provide you with the enclosed annual endowment report(s) for the <Designation 1>, <Designation 2>, <Designation 3> and the <Designation 4>. This is what I have but it is not returning like the above. if (Field("Designation 1") != "") { return "<span>" + TaggedDataField("Designation 1") + RawText(" and the ") + TaggedDataField("Designation 2") + RawText(".") + "</span>"; } if (Field("Designation 1") && Field("Designation 2") && Field("Designation 3") != "") { return "<span>" + TaggedDataField("Designation 1") + RawText(", ") + TaggedDataField("Designation 2 ") + RawText("and the") + TaggedDataField("Designation 3") + RawText(".") + "</span>"; } if (Field("Designation 1") && Field("Designation 2") && Field("Designation 3") && Field("Designation 4") != "") { return "<span>" + TaggedDataField("Designation 1") + RawText(", ") + TaggedDataField("Designation 2") + RawText(", ") + TaggedDataField("Designation 3") + RawText(" and the ") + TaggedDataField("Designation 4") + RawText(".") + "</span>"; } else { return "<span>" + TaggedDataField("Designation 1") + RawText(".") + "</span>"; } Quote
Dan Korn Posted November 21, 2017 Posted November 21, 2017 var arr = []; for (var i = 1; i <= 4; i++) arr.push(TaggedDataField("Designation " + i)); arr = arr.filter(String).map(function(s) { return "the " + s; }); return arr.slice(0, -2).join(', ') + (arr.slice(0, -2).length ? ', ' : '') + arr.slice(-2).join(' and '); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.