Time Sheet Portal Enhancement

Rocky5
Kilo Sage

Hi Guys,

I am a rookie to the portal scripting. And we have a requirement on "Time Sheet Portal", We can see the "Tasks" (like scrum tasks, project tasks etc..) in Time Cards in Time sheet portal as shown below. But, We are not to able to to which "story" or "project" those tasks belong to. So, The requirement is to show the "Parent" number and "Short Description" on the card in the highlighted area below. Like, if it is a project task that time card should show the project number and short description and similarly for scrum tasks. 

Can somebody provide me the script ? The script should be updated on the "Time Sheet portal - Task selector" widget. 

find_real_file.png

 

Thanks in advance,

Rocky.

4 REPLIES 4

Jayarnab Saha
ServiceNow Employee
ServiceNow Employee

Hi Rocky,

In 'Time Card Portal - Task Selector' widget, do the following steps :- 

1. script include -> function _addRecordsToList ->inside while loop add below code ->

var parent = gr.parent;
if(parent){
  var glideRecParent = new GlideRecord(parent.sys_class_name);
  glideRecParent.get(parent.sys_id);
  record.parent = {
    display_value: glideRecParent.getValue('number'),
    short_description : glideRecParent.getValue('short_description'),
    sys_class_name : glideRecParent.getValue('sys_class_name'),
    sys_id : glideRecParent.getValue('sys_id')
  };
}

 

2. Use this parent object in html template to display in UI. 

-> after this below line

<a class="card-navigator pull-left" target="_blank" ng-href="/{{::card.sys_class_name}}.do?sys_id={{::card.sys_id}}" ng-click="stopPropagation($event)">{{::card.number.display_value}}</a>

 

-> add another anchor tag to display parent field

<a class="card-navigator pull-left" target="_blank" ng-href="/{{::card.parent.sys_class_name}}.do?sys_id={{::card.parent.sys_id}}" ng-click="stopPropagation($event)">{{::card.parent.short_description}} - {{::card.parent.display_value}}</a>

 

Hope this solution will help.

 

Hi Saha,

 

I exactly want the same as your screen shot. Can you please tell me in a more granular way on how to use parent object in html template to display in UI.

I have added the script include script that you have provided.

Thanks,

Rocky.

Priyanka Teke1
Mega Sage

Hello Rocky,

In 'Time Card Grid' widget update the code in below manner - 

 

data.fields = ['task.number', 'task.short_description'];

if(data.isAllowMultipleRateTypes)

data.fields.push('state');
data.fields.push('task.parent.short_description');
data.fields.push('task.close_notes');
//data.fields.push('task.u_project_type');
var dayObj = timesheet.week_starts_on.getGlideObject();
var day = dayObj.getDayOfWeekUTC();
for(var i = 1; i<=7;i++){
data.fields.push(dayFields[day-1]);
day = (day + 1 <= 7) ? day + 1 : 1;
}
data.fields.push('total');

var field_labels = {

'task.number' : gs.getMessage('Task Number'),

'task.short_description' : gs.getMessage('Task'),
'task.parent.short_description' : gs.getMessage('Project Name'),
'task.close_notes' :gs.getMessage('Activity'),
'monday' : gs.getMessage('Mon'),
'tuesday': gs.getMessage('Tue'),
'wednesday': gs.getMessage('Wed'),
'thursday': gs.getMessage('Thu'),
'friday': gs.getMessage('Fri'),
'saturday': gs.getMessage('Sat'),
'sunday': gs.getMessage('Sun'),
};

 

Regards,

Priyanka

Hi Priyanka,

 

Thanks for the response. When I tried your code, The new column "Project Name" is being added and the project name isn't fitting in the space provided. So, I am looking for something like displaying, Project number or project name under the project task number. Any idea on how to achieve it?

 

Thanks,

Rocky.