- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 08:42 AM
Hi everyone! How are you?!
I am using the Email Script (Template script - Email Notification), including It's done, but I did the inline css style for each <th>, so to reduce the number of lines of code and reuse them (because they're the same) image_1, I thought about creating an Array of Objects and using a for() loop and inside the "For" block insert the template.print (image_2):
template.print('<th style="font-size:12px; border:1px solid #000;background: #BFE1D0">Name Company</th>');
In this case, the customization would apply to each <th>, without the need to write the lines of code several times, since they are the same, but is not working.
Would anyone have any tips?
I thank!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 09:05 AM
Could you try something like this:
var arryStyleElement = [{
Label: 'Name Company',
Name: 'u_company',
TH: 'th'
},
{
Label: 'Name Software',
Name: 'u_software',
TH: 'th'
},
{
Label: 'Area',
Name: 'u_area',
TH: 'th'
},
{
Label: 'New Department',
Name: 'u_department',
TH: 'th'
},
];
var str = "<table><tr>";
for(var i = 0; i < arryStyleElement.length; i++){
str = str + '<th style="font-size:12px; border:1px solid #000;background: #BFE1D0">' + arryStyleElement[i].TH + '</th>';
}
str = str + "</tr></table>";
template.print(str);
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 09:05 AM
Could you try something like this:
var arryStyleElement = [{
Label: 'Name Company',
Name: 'u_company',
TH: 'th'
},
{
Label: 'Name Software',
Name: 'u_software',
TH: 'th'
},
{
Label: 'Area',
Name: 'u_area',
TH: 'th'
},
{
Label: 'New Department',
Name: 'u_department',
TH: 'th'
},
];
var str = "<table><tr>";
for(var i = 0; i < arryStyleElement.length; i++){
str = str + '<th style="font-size:12px; border:1px solid #000;background: #BFE1D0">' + arryStyleElement[i].TH + '</th>';
}
str = str + "</tr></table>";
template.print(str);
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 03:26 PM
Hi @Prince Arora , how are you?!
I really want to thank you!
I performed the test here with your code and initially it worked, it just crashed, because you called the variable <table> <tr> at the same time. example var str = "<table><tr>".
Thank you very much!