Add Description and Short Description to Service Portal widget

Alex307
Kilo Guru

I'm still learning the ropes with Service Portal, so I'm looking for a bit of help with this. I think it should be fairly simple. We need the Short Description and Description to show on a widget.

Any help would be appreciated!

Body HTML:

<div ng-if="data.canRead" class="panel b">
  <div class="panel-heading bg-primary">
    <div ng-init="spSearch.targetRequests()">
      <sp-c-link target="form" table="data.table" id="data.sys_id"/>
    </div>
    <span ng-if="data.agent" >
      ${Agent working on this {{data.tableLabel}}}:
      <div>{{data.agent}}</div>
    </span>
    <span ng-if="!data.agent && data.agentPossible" >${Your request has been submitted}</span>
    <span ng-if="!data.agentPossible">${{{data.tableLabel}} record details}</span>
  </div>

  <div class="panel-body">
    <div ng-if="data.fields.length > 0">
      <div class="row">
        <div class="col-md-6 col-sm-12 col-xs-6 m-b break-word" ng-repeat="field in data.fields" 
             ng-if="field.value && (field.type != 'decimal' || field.type == 'decimal' && field.value != 0)" >
          <label class="m-n field-label">{{field.label}}</label>
          <span ng-switch="field.type">
            <div ng-switch-when="glide_date_time" title="{{field.display_value}}">
              <sn-time-ago timestamp="::field.value" />
            </div>
            <div ng-switch-default ><span ng-if="field.label != 'Request'">{{field.display_value}}</span><span ng-if="field.label == 'Request'"><a href="{{data.requestLink}}" target=>{{field.display_value}}</a></span></div>
          </span>
        </div>
      </div>
    </div>

    <div ng-if="data.variables.length > 0" ng-init="variable_toggle=true">
      <h4 ng-click="variable_toggle = !variable_toggle" style="cursor: pointer;">
        <span style="font-size: 12px;" class="glyphicon" 
              ng-class="{'glyphicon-chevron-down': !variable_toggle, 'glyphicon-chevron-up': variable_toggle}"></span>
        ${Options}
      </h4>
      
      <div ng-if="variable_toggle">
        <hr>
        <div class="m-b break-word" ng-repeat="variable in data.variables">
          <label class="m-n field-label">{{variable.label}}</label>
          <div>{{variable.display_value}}</div>
        </div>
      </div>
    </div>
  </div>

  <div ng-if="data.agentPossible && !data.agent && options.pickup_msg" class="panel-footer">
    <div id="ticket_fields_footer" class="text-center text-muted" style="font-style: italic;" ng-bind-html="data.pickupMsg">
    </div>
  </div>

</div>

 

 

 

Server Script:

(function(){
	data.pickupMsg = gs.getMessage(options.pickup_msg);
	var gr = $sp.getRecord();
	data.canRead = gr.canRead();
	if (!data.canRead) 
		return;

	var agent = "";
	var a = $sp.getField(gr, 'assigned_to');
	if (a != null)
		agent = a.display_value;

	var fields = $sp.getFields(gr, 'number,state,request,priority,sys_created_on,approval');
	if (gr.getValue("sys_mod_count") > 0)
		fields.push($sp.getField(gr, 'sys_updated_on'));

	if (gr.getValue('price') > 0) {
		fields.push($sp.getField(gr, 'price'));
		fields.push($sp.getField(gr, 'u_total_price'));
	}
	
	//fields.push($sp.getField(gr, 'approval'));
	fields.push($sp.getField(gr, 'quantity'));
	
	if (gr.getValue('recurring_price') > 0) {
		var rp = $sp.getField(gr, 'recurring_price');
		if (gr.isValidField("recurring_price"))
			rp.display_value = rp.display_value + " " + gr.getDisplayValue("recurring_frequency");
		fields.push(rp);
	}
	
	data.requestLink = '?id=sc_request&table=sc_request&sys_id=' + gr.getValue('request');

	data.tableLabel = gr.getLabel();
	data.fields = fields;
	data.variables = $sp.getVariablesArray();
	data.agent = agent;
	data.agentPossible = gr.isValidField("assigned_to");
	data.table = gr.getTableName();
	data.sys_id = gr.getUniqueValue();
})()

1 ACCEPTED SOLUTION

kiara1
Tera Expert

Hi Alex, 

 Just add the required column names in your server side code. 

var fields = $sp.getFields(gr, 'number,state,request,priority,sys_created_on,approval, description, short_description');

Thanks

Kunpriya

 

View solution in original post

4 REPLIES 4

Dylan Mann1
Giga Guru

There's a couple ways you can do it.

Create a data object for the Glide Record you want containing it's information, like:

data.obj.description = gr.description;

data.obj.short_description = gr.short_description;

 

Then you can bind it to the client like so:

<p>{{c.data.obj.description}}</p>

<p>{{c.data.obj.short_description}}</p>

 

You can clean up the code a bit but you get the general idea.

Let me know if this helps,

Dylan

 

kiara1
Tera Expert

Hi Alex, 

 Just add the required column names in your server side code. 

var fields = $sp.getFields(gr, 'number,state,request,priority,sys_created_on,approval, description, short_description');

Thanks

Kunpriya

 

Ive tried to add this too...

1. I can't seem to find that line of code above

2. When I add the entire line, I then get a blank result.

 

Thoughts?

Keerti2
Mega Expert

kindly let me know to add short description for request , as of now i can isee "item name , request number" when i click on My tickets.

 

now i want to see " item name , short description and request number" . kindly let me know code and where can we update that code.