How to import time cards to time_card and time_sheet tables

Talya
Tera Contributor

Hi All,

 

We have a requirement where one group of users will not be entering timecards via Time sheet portal. Instead they are asking us for a template where they can fill their time and send. These records state can be submitted/Approved.

 

1. Some records should be imported as Submitted where system should trigger request to their managers for approval 2. Some records should be imported as Approved. So no approval request should be triggered. But expense line should be created and after that time cards should be marked as processed.

 

Please help

 

Thanks,

Talya

8 REPLIES 8

DrewW
Mega Sage
Mega Sage

ServiceNow has a whole process around time cards and time sheets that you are going to need to learn.

 

You can import time cards and the system will attach them to the correct time sheet provided you get the week starts on field correct.  You can then set the state to approved for the ones that need to be auto processed and the others you set the state to Submitted.  Then you can trigger your approval and notifications if the time sheet is in a submitted state once all of the data is imported since the state of a time sheet is based on the state of the time cards that are attached to it.

 

Ultimately your requirement could turn out to be very complicated or supper simple depend on if you are using PPM or not and if you are using resource management or not.

Talya
Tera Contributor

Thank you @DrewW for your reply.

Yes we are using the PPM application, we have Resource plans are created at Group level and allocated to all the users.

When I am trying to import the time cards , I am facing the following issues:

  1. For Project time cards, The Business Rule: ‘Validate resource plan’ is not allowing me to insert the time cards though I am associating right Resource plans. For the same user when I go and check in Time Sheet Portal UI, it is showing the same Resource Plan which I am trying to add through import set.

Talya_3-1674526613189.png

 

Attaching the Business Rule code snippet , 

 

Talya_2-1674526265858.png

 

Talya_1-1674573099746.png

When I check the Reference qualifier of Resource Plan field in Time Card form

Talya_2-1674577040324.png

 

 

2. For Operational Tasks ,Time card is getting created with ‘Pending’ State in time card table, though I am passing the state as ‘Submitted’. When I went ahead and checked all the Business Rules, I found out that is due to the Business Rule: ‘Set values for new time card

 

My requirement is to submit time cards through import set for one of the groups who have 80 users, remaining groups (around 500 users) will be logging time in Time sheet portal.

 

Please suggest me how can resolve the above 2 issues and insert time cards with 'Submitted' and 'Approved' states and not in Pending state via import set.

 

Thanks,

Talya

 

 

The system does not like it when you try and insert a time card that has a state other than pending.  So you have to insert the time card with state Pending then update the time card with state Submitted.

 

As for the Resource plan try inserting the time card without the resource plan being set and then add the value when you update the state to Submitted.

Talya
Tera Contributor

Hi @DrewW , I can disable the Business Rule: ‘Set values for new time card’ , so that I can insert the time cards with Submitted state. I am fine with doing that before import.

 

Now my issue is inserting the time card with Resource plan, I cannot update each time card with Resource plan field every week for around 80+ users. 

I want to be able to update the time card fields with correct values with import set. I do not want to disable the BR: Validate resource plan, as I want the system to flag the error for the record where user is putting Resource plan that is still not allocated for them. If I disable this BR then if user specify wrong Resource Plan, system would still insert into the table.

 

I feel OOTB _getResourcePlanForTimeCardHelper  method has some bug since it is not getting the right Resource plan that is allocated for user.

 

When I try from Time Sheet portal for the same user, the same Resource plan is displayed and allowing the user to submit the time card.

 

The functions used to get the Resource Plan ID are different for Time Sheet portal and when I insert from import set, as I have high-lighted in screenshot.

 

Talya_0-1674576411291.png

 

When I check the Reference qualifier of Resource Plan field in Time card form:

Talya_1-1674576723534.png

I want to understand whether Reference qualifier needs some changes or _getResourcePlanForTimeCardHelper() function.

I need help with fixing the same.

 

Thank you,

Talya