Forum Discussion
Sharepoint Designer 2013 Looping and Looping Emails
ScottEQ Based on my experience, I recommend structuring the email body using an HTML table for a more organized presentation. Start by creating two columns in the table, with the first one dedicated
to listing domain names and the second one to display their respective expiration dates. This approach significantly enhances the clarity of the domain-to-date mapping, providing a readable format that simplifies understanding.
When constructing the domain and expiration dictionaries, I suggest opting for a more efficient approach by using arrays for each variable rather than relying on a long string.
For instance:
<script>
Domains = ["Domain1", "Domain2", "Domain3"];
Expiry = ["1/1/2023", "1/15/2023", "2/1/2023"];
</script>
In the email body, iterate over these arrays using a counter variable to dynamically print each domain and its corresponding expiration date on a new row within the table:
<script>
for (var i = 0; i < Domains.length; i++) {
document.write("<tr>");
document.write("<td>" + Domains[i] + "</td>");
document.write("<td>" + Expiry[i] + "</td>");
document.write("</tr>");
}
</script>
An alternative approach, drawing from my own experience, involves constructing the dictionary with key/value pairs for better manageability:
<script>
DomainsExpiryMap = {"Domain1": "1/1/2023", "Domain2": "1/15/2023", "Domain3": "2/1/2023"};
</script>
You can then seamlessly print these pairs in a table using key and value references:
<script>
for (var domain in DomainsExpiryMap) {
document.write("<tr>");
document.write("<td>" + domain + "</td>");
document.write("<td>" + DomainsExpiryMap[domain] + "</td>");
document.write("</tr>");
}
</script>