Jump to content

Recommended Posts

Posted

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>";

}

Posted
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 ');

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...