ChrisBurks
Giga Sage

I'm not sure how to explain why if you send over the GlideRecord it ends up being empty but I think it has to do with it being a constructor (class) type object.

Also when passing data around many feel that it's best to pass as little data as possible to keep things optimized. So, unless you're trying to bring over the meta data and every thing that deals with that record (even data that the end user doesn't need) then it's best to just capture the fields that usually display value. 

Service Portal has a few methods that help minimize the burden of trying to list all the fields that may be necessary.

For instance lets take the example of the incident record. We can take advantage of some things we know about it like baseline (OOB) it has a "Major incident" view and a "self-service" (ess) list view. 

If I wanted to get an incident record with the same fields for the ess view I could grab the fields that are configured to display native side and use that in Service Portal.

var essFields = $sp.getListColumns('incident', 'ess'); // brings back a list of viewable fields for ess users on incident


Now lets build our object with the help of your GlideRecord script

var essFields = $sp.getListColumns('incident', 'ess');
var rec1 = new GlideRecord('incident');
if(rec1.get(sysid)){
   data.essInc = {};
   $sp.getRecordValues(data.essInc, rec1, essFields); 
   console.log(data.essInc)

   data.essInc.sys_id = rec1.getUniqueValue(); //add fields that aren't in the view
   console.log(data.essInc) //now sys_id is included with object
}

Or what if I had a condition to display the major incident view when it's a major incident I could either one without having to manually list different fields/columns

var fields = "";
var rec1 = new GlideRecord('incident');
if(rec1.get(sysid)){
   //if priority 1 use major incidents view else use ess view
   fields = rec1.getValue('priority') == 1 ? $sp.getListColumns("incident", "Major incidents") : $sp.getListColumns("incident", "ess");

   //create empty object literal
   data.inc = {};
   //use GlideRecord and list of fields to populate the empty object
   $sp.getRecordValues(data.inc, rec1, fields); 
   console.log(data.inc)
   
   //add extra fields if needed 
   data.inc.sys_id = rec1.getUniqueValue();
   console.log(data.inc) //now sys_id is included with object
}

In the client controller it can now be accessed via: c.data.essInc, this.data.essInc, c.data.inc or this.data.inc respective to the scripts above and then dot walk out to the property

For example

c.data.essInc.number

Since the examples above are leveraging the server data object it's also available in $scope and therefore accessible straight from the HTML template as well:

<div> Number: { { data.essInc.number } } </div>

Note: In case they don't display there are double curly braces around "data.essInc.number" in the HTML template example. The forum sometimes strips them out  

New views could be made as well to support your needs.