- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 12:47 PM
This is a long shot since it's custom code, but I'm hoping someone has an idea of where I can look that I haven't thought of yet. We have a custom drop-down field we have added to the time card table and the time sheet portal for Timecard Class. It looks like this and works fine.
However, when we impersonate a user, the drop-down values don't display. The users themselves can see them. We just can't see them when impersonating. It looks like this:
We can go to the time_card table (while impersonating) and see the values, so it's not an ACL issue. Here's what it looks like from there:
It has to be something on the time sheet portal code, but I can't find any code that seems to be returning incorrectly. Anyone have an idea of what I could check? Thanks in advance for your help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 05:22 AM
I was able to fix this by adding an ACL for sys_choice.* for all authenticated users.
Apparently in Washington DC Patch 4 Hotfix 1b, a change was made the security around API calls. Even though the users had access to see the choices when viewing them in the client, they could not execute the API call that was being made to pull them on the time sheet portal. Putting this here in case anyone else has a similar issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 05:00 AM
Well, it wasn't simple, and it's been a while since I did it, but here's what I recall:
- I created the field on the time_card table.
- I had to clone the "Time Card Portal Main Container" widget and add code for my field in there.
- I had to clone the "Time Card Grid" widget and add code for my field there.
- Because I wanted my field to be required upon submission, I had to modify the TimeCardUtil and TimeCardValidator script includes.
- Added an ACL to for sys_choice.* for all authenticated users.
The specific changes will vary depending on if you add a drop-down (like I did) or some other type of field. I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 11:49 AM
Thanks a ton for the answer. Exactly what I am looking for. Would you mind sharing the code if you have it on hand? If not it's totally fine. Again, thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2025 09:38 AM
@JenniferRah , I'm looking for similar customization, Could you please share the code .. It would be very helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 06:04 AM
I have hesitated to do this, because it's tedious and I have made other customizations since this, so adding the code would just be confusing. I tried to outline below what I did, though. Hopefully this helps. I would also suggest to always comment code you add or change yourself so you will remember later what you did and why you did it. 😊
- Add your new field to the time_card table & add to worker_portal view.
- Clone the Time Card Grid widget.
- In your new widget, make the following changes/additions:
- HTML Template: Add ||field === ‘yourfieldname’ to lines 40 & 41.
- Server Script:
- If it will be required, add it to the message in line 26.
- After line 42, add this line: data.fields.push('yourfieldname');
- Add your new field to line 106 (This line starts with “data.editable_fields = “)
- Copy lines 137-140 and change the field name to your field. Add them right after the existing lines.
- Copy line 205 and change the field name to your field. Add this line right after the existing line.
- Client Script:
- After the if statement that ends in line 71, add the following code:
if(field === "u_timecard_class"){ data[field] = record[field].display_value; }else{ - Close your new if loop after the current line 76 (which reads data[field] = val).
- After line 364, add the following line to refresh after submitting:
refreshWidget(); - Copy line 527 and add it right under the existing one. Replace the “_ptc” with something that represents your field, and replace the project_time_category.value with your field.
- After line 534, add the line below, replacing the values as indicated:
var _yourname = (list_item.yourfieldname && list_item.yourfieldname.value) || ''; - On line 536, add your variable from above to the list;
- After the if statement that ends in line 71, add the following code:
- Link Function:
- Duplicate line 17, and change the names to match your field. Make sure to put a comma after the existing line 17.
- Delete or comment out lines 66 & 67.
- Add the following function. I added it right before _initializeFieldSelect2 in line 185, but I don’t think it matters where you add it.
function getYourFieldChoices(record) { var field = "your fieldname"; return function(data, page) { var more = (page * 20) < data.total; var responseData = []; if(data) { var items = data.items; responseData.push({ "id" : "", "text" : scope.data.messages.none, "field": field, "sys_id": record.sys_id }); for (var i = 0; i < items.length; i++) { responseData.push({ "id": items[i].label.display_value, "text": items[i].label.display_value, "field": field, "sys_id": record.sys_id }); } } return { results: responseData, more: more }; } } - Add the following function. I added it right after _initializeResourceAssignmentSelect2 in line 222, but I don’t think it matters where you add it.
function _initializeYourFieldSelect2(closestElem, evt, record) { _initializeFieldSelect2("yourfieldname", closestElem, evt, record, scope.data.messages.selectYourField); } - Add the following line after 302.
_initializeYourFieldSelect2(closestElem, evt, record);
- Clone the Time Card Portal Main Container widget.
- In your new widget, make the following changes:
- Server Script: In line 36, change tc-grid to the new widget you created in step 2 above.
- CSS-SCSS: add “overflow: scroll;” to the .center-panel block.
- In the script include TimeCardValidator:
- If your field is going to be required, add the following at line 15:
rules.push(this._validateRequireYourFieldRule); - If your field is going to be required, add the following function. I added it around line 36:
_validateRequireYourFieldRule: function() { var blankYourField = this._timeCard.getValue('yourfieldname') == null || this._timeCard.getValue('yourfieldname') == '--None--'; if (blankYourField) gs.addErrorMessage(gs.getMessage('Cannot submit a time card with a yourfieldof "None"')); return !blankTimecardClass; },
- If your field is going to be required, add the following at line 15:
- In the script include TimeCardPortalService, add the following line before the existing line 454:
timecard.addQuery('yourfieldname', record.yourfieldname && record.yourfieldname.value);
