Unable to display record data on a SP widget

LRhodes
Tera Guru

Hi all,

A little background - I have created a new table (u_valuation_status) which extends the task table. In this new table we have a column called u_details. There is only one record in this table and will only ever be one record in this table.

 

The idea is that the company will continue to update the u_details string field.

 

So I have a business requirement to display the contents of the u_details field in a widget on the Service Portal, so when the data is updated in the table, it is updated in the widget.

 

I've tried to copy an existing widget as a starting point but I'm having no luck displaying the data.

 

Here's my HTML Template:

 

 

<div ng-if="!data.service || data.outages.length > 0" class="panel panel-{{options.color}} b">
  <div class="panel-heading">
    <h3 class="panel-title text-center">${Check Valuation Status}</h3>
  </div>

  <div class="panel-body">
		<div>
      <span style="font-size: 120%">System Valuation Check</span>
      <br />
      <br/ >
      <span>{{check.u_details}}</span>
      <br />
      <br/ >
      <span>Updated at 09:00 GMT on 20th March 2024.</span>
    </div>
    
</div>

 

 

 

 

Here's my Server Script:

 

 

// populate the 'data' object
// e.g., data.table = $sp.getValue('table');
var check = new GlideRecord("u_valuation_status");
check.query();

data.checks = [];
data.checkIDs = "";
while (check.next()) {		
	var out = {};
	out.details = check.u_details();
	out.updated = check.sys_updated_on();
	
	data.checks.push(out);
	data.checkIDs += "," + check.getUniqueValue();	
	
}

 

 

 

My client script and CSS is currently empty, I'm not sure if I need to add anything in there to get this working.

Here is how I want it to look (I've simply typed in an example string rather than pull it through from a record).

 

LRhodes_0-1713780858128.png

 

1 ACCEPTED SOLUTION

Anirudh Pathak
Mega Sage

Hi @LRhodes,

Please try the below code, assuming that there would be only record present in this table, as you mentioned above in your question.

HTML -

<div class="panel-heading">
    <h3 class="panel-title text-center">${Check Valuation Status}</h3>
  </div>
<div class="panel-body">
 <div>
      <span style="font-size: 120%">System Valuation Check</span>
      <br />
      <br/ >
      <span>{{data.details}}</span>
      <br />
      <br/ >
      <span>Updated at {data.timeStamp}</span>
    </div>
    
</div>

 

Server Side -

// populate the 'data' object
// e.g., data.table = $sp.getValue('table');

data.details = '';
data.timeStamp = '';


var check = new GlideRecord("u_valuation_status");
check.query();

if(check.next()) {		
	data.details = check.getValue('u_details');
        data.timeStamp = check.getValue('sys_updated_on');
}

 

View solution in original post

2 REPLIES 2

Anirudh Pathak
Mega Sage

Hi @LRhodes,

Please try the below code, assuming that there would be only record present in this table, as you mentioned above in your question.

HTML -

<div class="panel-heading">
    <h3 class="panel-title text-center">${Check Valuation Status}</h3>
  </div>
<div class="panel-body">
 <div>
      <span style="font-size: 120%">System Valuation Check</span>
      <br />
      <br/ >
      <span>{{data.details}}</span>
      <br />
      <br/ >
      <span>Updated at {data.timeStamp}</span>
    </div>
    
</div>

 

Server Side -

// populate the 'data' object
// e.g., data.table = $sp.getValue('table');

data.details = '';
data.timeStamp = '';


var check = new GlideRecord("u_valuation_status");
check.query();

if(check.next()) {		
	data.details = check.getValue('u_details');
        data.timeStamp = check.getValue('sys_updated_on');
}

 

Perfect Anirudh - that's worked for me. Thank you!