Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How Do I Make the Contents of a Table Dynamically Change When Variables in a Record Change

cwolfe01
Giga Guru

I'm doing some work with notifications that get sent to users from the time they create an incident, to the incidents resolution. My notification fires whenever the incident state changes to "In Progress" or when "Assigned To" changes, and has a table populated with information from the incident. I want one of the rows to change depending on whether the incident's state is changed to in progress without the assigned to field being populated, or if the assigned to field is changed after the state is changed.

incident link 3.png incident link 4.png

 

Here's a snippet of the code I'm using:

template.print('<tr>');
			if (current.variables.assigned_to == null) {
				template.print('<td style="border:1px solid black; border-right-color: gray; border-bottom-color: gray">Assignment Group</td>');
				template.print('<td style="border:1px solid black; border-right-color: gray; border-bottom-color: gray">${assignment_group}</td>');
			}
			else {
				template.print('<td style="border:1px solid black; border-right-color: gray; border-bottom-color: gray">Assigned To</td>');
				template.print('<td style="border:1px solid black; border-right-color: gray; border-bottom-color: gray">${assigned_to}</td>');
			}
			// template.print('<td style="border:1px solid black; border-right-color: gray; border-bottom-color: gray">Assigned To</td>');
			// template.print('<td style="border:1px solid black; border-right-color: gray; border-bottom-color: gray">${assigned_to}</td>');
		template.print('</tr>');

As it stands, the table is only being populated with the Assignment Group, even if the Assigned To field is populated at the same time the state is changed to "In Progress". Can someone point me in the right direction?

1 ACCEPTED SOLUTION

Tim Deniston
Mega Sage

You probably don't need the "variables" part of "current.variables.assigned_to == null". So, that line would just be...

 

if (current.assigned_to == null) {

 

You might want to also change it to...

 

if (gs.nil(current.assigned_to) || current.assigned_to == '') {

 

 

View solution in original post

1 REPLY 1

Tim Deniston
Mega Sage

You probably don't need the "variables" part of "current.variables.assigned_to == null". So, that line would just be...

 

if (current.assigned_to == null) {

 

You might want to also change it to...

 

if (gs.nil(current.assigned_to) || current.assigned_to == '') {