Query on Email script

instance
Tera Contributor

I have Created Email script that displays like this table method

i need the Change_request and Incident Records to be Displayed Separately.

in Separate table .

 

email Script:

 

var tas = new GlideRecord("task");
tas.addQuery('assigned_to',current.sys_id);
tas.query();
if (tas.hasNext()) {
template.print('<br />');
template.print('<table style="height: 23px;" width="100%"><tbody><tr><td style="background-color: #0e5399;"><font color="#FFFFFF"><strong>InActive Users in Task :</strong></font></td></tr></tbody></table>');
var tb2 = '<table style="height: 293px;" width="100%"><tbody>';

var tab2 = '<table style="width: 100%; border-collapse : collapse; " border = "2" cellpadding = "10"> <tbody>' + '<tr>' +

'<td style="background-color: #aeaeae;">' + '<b>Number</b>' + '</td>' +
'<td style="background-color: #aeaeae;">' + '<b>Assigned To</b>' + '</td>' +


'</tr>';
template.print(tab2);
}

while (tas.next()) {

var clsed2 = '<tr>' +
'<td>' + tas.number + '</td>' +
'<td>' + tas.assigned_to.name + '</td>'
'</tr>';
template.print(clsed2);

 

what changes needs to be done?
}

var tab_end2 = '</tbody> </table>';
template.print(tab_end2);

8 REPLIES 8

instance
Tera Contributor

@Dubz  order is not an issue.

but i need Incident Records in the Task should be in one table with Rows and Coloumn.

and Change_request in the task should in different table with rows and coloumn.

Then Hemants solution is what you need. Query the incident table and print incidents into 1 table and then query the change table and print those into another table. If you want it in one code block then just write it as a function and pass in the table name as an argument. eg:

 

function printTable(tableName){
var gr = new GlideRecord(tableName);
etc

instance
Tera Contributor

@Dubz 

Hemant has written the code out for you. I'm happy to answer specific questions but i'm not going to write out the code for you, you'll learn more by playing around with it yourself.