Jayarnab Saha
ServiceNow Employee
ServiceNow Employee

OOB Time Sheet Portal shows all the task records present in tasks table. If we want to modify the OOB behaviour to show desired task type, we need to update in two widgets.

Task pane

find_real_file.png

If you wish to add more tables or remove OOB task types to show in Task tab (in left pane), then follow below steps:

  1. Navigate to Service portal -> widgets from module.
  2. Search for record with ID : timecard-portal-container (Time Card Portal Main Container).
  3. Search in Server Script -> data.taskSelector = $sp.getWidget('timecard-task-selector'
  4. You can see a list of tables mentioned there. You can modify the list to show expected tasks ( OOB there is no widget input present, but if you have already some inputs, then this modification of tasks will get skipped).

 

Task selector

find_real_file.png

If you wish to add/remove specific task types from the task selector dropdown, i.e. Add unassigned tasks to Time Sheet, follow below steps.

  1. Navigate to Service portal -> widgets from module.
  2. Search for record with ID : tc-grid (Time Card Grid).
  3. Search in Server Script -> var taskSelector = $('#task-selector');
  4. The select2 component is using OOB Table rest api to fetch records from task table, i.e. url: '/api/now/table/task'
  5. You can create your own Rest api to fetch specific records and replace the url here OR 
  6. Extend the OOB Table rest api to query specific records. https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_TableAPI

 

N.B.:

  • This is completely a customisation, so while upgrading instance version it needs special attention to get updated version along with this customisation.
  • Adding many task types, may cause performance degradation of Time Sheet Portal. Querying to a huge number of records, will delay the page load/operations.
Comments
Aditya24
Giga Expert

Hi,

I am hoping there must be similar way of updating what information we see about the tasks on the task selector widget. Like as of now we see a task state, priority, updated date and title. What if I want to see more information there so I can take a more informed decision there. I would like to add a custom field value there. Could you please guide me with the same?

Jayarnab Saha
ServiceNow Employee
ServiceNow Employee

You can edit Service portal widget 'Time Card Portal - Task Selector' to update the task selector cards layout.

In server script, you can see defaultLayout , which contains primary fields, secondary fields ect. You can add your custom field in the secondary_fields array. it will show up in the card layout.

In Body HTML template, you can search for class="card" for the structure of layout.

 

Hope this help you.

 

regards,

Jayarnab

Aditya24
Giga Expert

Hi Jayarnab,

I did try adding the field in the secondary fields array but it broke the portal. 

Would it be possible for you to share an example here?

Also, what if there is a different field for Demand which I want to add and that doesn't not exist on project. Are there separate places to define as per the task type?

Chandler2
Tera Guru

Hi @Jayarnab Saha 

I want to restrict what tasks I see in the "Add unassigned task" and was following the steps you mentioned but as mentioned in step 3.

I didn't find anything like "taskSelector"

Search in Server Script -> var taskSelector = $('#task-selector');

 

Can you please suggest?

Chandler2
Tera Guru

I am also trying to update the task pane view and followed the steps but wasn't able to move forward step 3 and 4 as I don't see list of tables in the server script.

  1. Search in Server Script -> data.taskSelector = $sp.getWidget('timecard-task-selector'
  2. You can see a list of tables mentioned there. You can modify the list to show expected tasks ( OOB there is no widget input present, but if you have already some inputs, then this modification of tasks will get skipped).

 

Below is what I see.

 

find_real_file.png

Chandler2
Tera Guru

Hi @Jayarnab Saha 

I am trying to follow the steps you mentioned but not ale to find the points listed.

If you wish to add/remove specific task types from the task selector dropdown, i.e. Add unassigned tasks to Time Sheet, follow below steps.

  1. Navigate to Service portal -> widgets from module.
  2. Search for record with ID : tc-grid (Time Card Grid).
  3. Search in Server Script -> var taskSelector = $('#task-selector'); NOT FOUND
    There isn't anything like taskselector I could see either in my PDI or client instance.
  4. The select2 component is using OOB Table rest api to fetch records from task table, i.e. url: '/api/now/table/task'
  5. You can create your own Rest api to fetch specific records and replace the url here OR 
  6. Extend the OOB Table rest api to query specific
User177031
Kilo Guru

@Jayarnab Saha 

Do you have any update on the question asked by Chandler?

I too have the same issue. Can you please help.

- Thank you.

Tarish
Kilo Contributor

Yes, same for me. 
Did anything resolve your issue?

 

HazzN
ServiceNow Employee
ServiceNow Employee

@Tarish  and @Chandler ,

 

You want to look at defaultTables/tables in 2 separate locations:

1. In the Time Card Portal - Task Selector Widget about a quarter of the way down you should see this:

find_real_file.png

2. The Widget Instance titled "Time Card Portal Container"

find_real_file.png

Talya
Tera Contributor

Hi @HazzN ,

 

We are in Tokyo version and I need to hide tasks from specific tables under both tasks tab and also from ' Add unassigned Tasks to Timesheet option.

 

I made changes in Time Card Portal - Task Selector Widget , now its is working fine under Tasks tab. 

But from 'Add unassigned Tasks to Timesheet' . I can still see records from all tables. 

 

How to fix it? Please help.

 

Thanks,

Talya

Avery Brown
Tera Contributor

Is there a way to restrict the record types that are generated from the 'generate time cards' button? We only want to generate time cards for PRJ records, and I'd like to do that without having to modify some sort of script that's OOB. Wondering if there is a simpler way

 

Tejaswi Gundu
Tera Contributor

I have a requirement where I need to add 'Interactions' to time sheet portal.It isn't part of Task table.So, how can we configure that. If anyone have idea on this please help me.

Thank you!

Version history
Last update:
‎11-26-2020 11:37 PM
Updated by: