Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Add Resolution Information tab in the ticket opened in employee center.

shivatmika_19
Tera Guru

Expected Functionality:

 

Screenshot 2024-11-28 at 3.56.19 PM.png

 

1. Navigate to All > Standard Ticket > Standard Ticket Configuration and click on incident from the list of records.

2. Change the application scope to Service Portal - Standard Ticket

3. Click New button in the Tab Configurations related list.

4. A new record will be opened select Type as Custom, set visible when incident state is resolved or closed.

5. Navigate to All > Service Portal > widgets and create a new Widget.

6. Add the following codes:

HTML:

<div>
    <div>
         <h3>Resolution Code: </h3>
         <span>{{data.code}}</span>
    </div>
     <div>
         <h3>Resolution Notes: </h3>
         <span>{{data.notes}}</span>
      </div>
</div>

 

CSS:

div > div {
margin-bottom: 10px; 
}

div > div h3 {
font-size: 16px;
color: #333;
display: inline; 
margin-right: 10px; 
}

div > div span {
font-size: 14px;
color: #555;
display: inline; 
vertical-align: middle; 
}

Server script:

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var table = $sp.getParameter('table');
var sysId = $sp.getParameter('sys_id');

var incGR = new GlideRecord(table);
 
data.code = "";
data.notes = "";
if(incGR.get(sysId)){
 
data.code += incGR.close_code;
data.notes += incGR.close_notes;
}
})(); 
7. Save the record.
8. Navigate to the Tab Configuration record where you previously added the fields, and then add the widget to the designated Widget field.
 
Explanation of Server Script:

The out-of-the-box (OOTB) widget, Standard Ticket Tab, calls the custom widget by passing the table name and sys_id to custom-created widgets. As a result, we can access the values provided by the OOTB widget within our custom widget. 

 

 

2 REPLIES 2

mfhaciahmetoglu
Mega Sage

Hey @shivatmika_19 ,

 

Thanks for this.

 

I tried it but it does not work. The tab appears but it is all empty. 

 

mfhaciahmetoglu_1-1740480558187.png

 

 

mfhaciahmetoglu_0-1740480474379.png

I added a debug gs.info but nothing is printed, either.

 

I am not sure if the server script it executed.

 

Best,

Firat

@shivatmika_19 , 

I found why! You just need to fill in the widget id, otherwise the widget is not run. 🙂