- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 07:04 AM
My organization has a use case for needing several non-task time cards to be created for the same category. For example, we've added a field to the time_card table that is a reference back to core_company. This will allow our employees to track time to specific clients without a ticket. Example: I have a meeting with a client and want to make sure my time is logged to that client.
I've added the field to the time sheet portal, and it's displaying the company without issue. I can create a time card for the "Meeting" category and select the appropriate client. However, when I click the "Add to Time Sheet" link on the "Meeting" category again for a new client, the time sheet portal wants to use the existing time card instead of creating a new one. Is there a way to change the qualifier for what ServiceNow considers a duplicate time card?
I can add a new time card tracked to that category through the classic UI, but not the portal (which flags the time cards as duplicates).
This image should help illustrate the issue.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 02:07 PM
In case anyone stumbles across this use case in the future, I was able to make some adjustments to meet my needs. I don't consider making changes to core script includes or portal widgets ideal (for a variety of reasons), but this seemed like my only option. If anyone from ServiceNow reads this, the ability to make these adjustments through configuration and not code would be great.
- Add the field to the Time Card Portal Container (Widget Instance) in the Additional options, JSON format field.
- Modify the copyTimeCard method in the TimeSheet script include. Specifically, I added my field (u_company) to the fieldsToCopy list. This allows time cards copied from another time sheet to carry over the custom field.
- Modify the getTimeCardFilter method in the TimeCardUtil script include to include my custom field in the query that checks for duplicates.
- Modify the highlightDuplicates method in the Time Card Grid Widget to add my custom field value to the uniqueItemKey variable. This will prevent the time cards as being flagged as duplicates.
With these modifications, I'm able to see the company in the Time Sheet Portal grid, add multiple time cards assigned to the same category with different companies, and copy the company values from previous time sheets/cards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:00 PM
This sounds like the solution I need but since I can't see what you modified I am struggling to determine how it was done. In my case I simply want to be able to add multiple time entries for say KTLO and be able to associate them to different resource plans. Below I was only able to do so by first adding a KTLO time entry and submitting, then adding another. This is a problem because once the first one is submitted a user cannot update the card.
I think your solution might work but in my case I don't think I need to add any custom fields. I simply need to figure out how to allow for a second card of the same type to be added. If you have any of the code to share or ideas that would be great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 04:30 AM
Hi there Chris, did you had any breakthrough on this issue? I'm facing the same challenge right now and i can't seem to find the sweet spot to make this exception for some users with a specific role.
I allready changed some bits of the widget, including the task selector and time card grid on some methods like mergeDuplicateTc, but i can't seem to find the key method that is working here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2024 08:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
This is awesome, thanks man. BTW for anyone else who's going to use this, the difference in the script is he added this section after line 150. It seems to work very well.
var resourcePlan = values.resource_plan;
if(resourcePlan)
query += '^resource_plan' + resourcePlan;
else
query += '^resource_planISEMPTY';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 12:46 AM
Hello , did you manage to acomplish this?
I have the same requirment, thanks.