Service Portal Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 05:28 PM
Hey,
I tried impersonating a user in servicenow and trying to access the new build portal.
But getting this error--
java.lang.NullPointerException: Cannot invoke "java.util.Map.containsKey(Object)" because "sourceFields" is null
it show the eforms, but for specific user, getting above error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 06:23 PM
Hi @Kartik Swaroop ,
java.lang.NullPointerException: Cannot invoke "java.util.Map.containsKey(Object)" because "sourceFields" is null — typically indicates that some script or widget on the portal is trying to access a field or map that hasn't been initialized properly for the impersonated user.
Check the widget script (client/controller/server) and look for the code line using .containsKey(). Wrap that line with a null check:
if (sourceFields && sourceFields.containsKey('your_field')) {
// safe to proceed
}
est the impersonated user’s profile:
Does the user have the same roles as the working user?
Is the user missing some mandatory field values (e.g., Department, Location, etc.)?
✅ Use gs.info() or console.log() debugging in your widget/server script to log the state of sourceFields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi!
I am not sure if the error is still relevant. However, I had the same error and in my case the reason was a missing translation. You can try to switch the language to English for the impersonated user and then give it another try in the Service Portal. Hope this helps!
Kind regards
