How to display the case number in portal widget

Sri56
Tera Contributor

Hi Team,

 

I have created one widget which i'm mapping to standard ticket tab config.

in that widget, i need to display the "current case number"in html link.

like <p><a href="https://xyz.com(guid='',reference_number='<case_number>')" target="_blank">Process Link</a></p>

How can i display?

 

Please help!

 

Thanks!

6 REPLIES 6

Anand Kumar P
Giga Patron

Hi @Sri56 ,

You can write server side script to get current case and pass it to html use below sample code

Example widget

HTML:
<div>
<table>
<pre> sort by = {{orderField}}</pre>
<tr>
<th><button ng-click="changeSort('NUMBER')">Number</button></th>
<th><button ng-click="changeSort('SHORT DESCRIPTION')">Short Description</button></th>
<th><button ng-click="changeSort('PRIOPRTY')">Priority</button></th>
<th><button ng-click="changeSort('CREATED')">Created</button></th>
<th><button ng-click="changeSort('CATEGORY')">Category</button></th>
</tr>
<tr ng-repeat="incident in data.incidents">
<td>{{incident.number}}</td>
<td>{{incident.short_description}}</td>
<td>{{incident.priority}}</td>
<td>{{incident.sys_created_on}}</td>
<td>{{incident.category}}</td>
</tr>
</table>
</div>


SERVER SCRIPT:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.incidents = [];

/*var gr = new GlideRecord('incident');//use case table as per your reuuirment
//gr.addQuery('active',true);
gr.setLimit(10);
//gr.orderBy('sys_created_on');
gr.query();
while(gr.next()){

var incident = {};
incident.number = gr.getDisplayValue('number');
incident.short_description = gr.getDisplayValue('short_description');
incident.priority = gr.getDisplayValue('priority');
incident.sys_created_on = gr.getDisplayValue('sys_created_on');
incident.category = gr.getDisplayValue('category')
data.incidents.push(incident);
}*/

var gr = new GlideRecord('sys_user');
//gr.addQuery('active',true);
gr.setLimit(10);
//gr.orderBy('sys_created_on');
gr.query();
while(gr.next()){

var incident = {};
incident.number = gr.getDisplayValue('user_name');
incident.short_description = gr.getDisplayValue('first_name');
incident.priority = gr.getDisplayValue('last_name');
incident.sys_created_on = gr.getDisplayValue('sys_created_on');
//incident.category = gr.getDisplayValue('category')
data.incidents.push(incident);
})();


CLIENT CONTROLLER:
function($scope) {
/* widget controller */
var c = this;
$scope.orderField = "number";

$scope.changeSort = function(field){
$scope.orderField = field;
}

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Hi Anand,

 

I need to use the case number in the link above.

please help me with the code.

 

Thanks!

Maddysunil
Kilo Sage

@Sri56 

can you check if below example can help you:

 

var currentCaseNumber = current.getValue('number');
    // Check if the case number is available
    if (currentCaseNumber) {
        var linkContainer = document.getElementById('processLinkContainer');
        var linkParagraph = document.getElementById('processLinkParagraph');
        // Construct the link
        var linkHTML = '<p><a href="https://xyz.com?guid=&reference_number=' + currentCaseNumber + '" target="_blank">Process Link</a></p>';

 

 

Kindly mark helpful/accepted if it helps you.

Thanks

Sri56
Tera Contributor

Hi Maddy,

 

I need to use the link with case number in widget body HTML.

 

Please help me with the code.

 

Thanks!

Sri