Error in server script in scoped widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 05:13 AM
Hi Snow enthusiasts,
I'm facing an issue while cloning a global widget into a scoped environment. When I preview the widget this is the error :
What I am actually doing is copying the global workers portal to a completely scoped environment. I have made the necessary changes in script though may be not all since I'm very new service portal (actually starting from zero).
here is the server script where the error line is present :
Could anyone please direct me how to correct this and most importantly what is this error all about so that I can learn why is it so?
Also I would request if anyone has done this implementation for their client. The requirement is :
"Moving the Global Workers Portal to a Private scope for generating time cards" OR we can simply put this way :
"Make the Global Workers Portal work in a private scope exactly the way it is now in global scope"
Many Thanks,
Arnab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 05:47 AM
It appears that there no sysparm_timesheet_id being specified in the URL so it is assuming that it can find it in the form submission data (i.e. 'input'). It's barking about not having an input object so there's no timesheetId property to get this from.
"I couldn't find it on the URL and I don't see an input object, so I quit" is what the script is saying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 10:49 PM
Hi Chuck,
Well written I would say.
So you are saying the code line must get a predefined timesheetId to execute. If so where do i define the timesheetId or let's say how do I remove this error?
I'm actually very new to portal (starting from zero to be exact). I have seen the Technow video. What I want to know about portal is :
1. What is the flow of execution of a widget. e.g. 1st server script then client then ...etc etc. This will help me debug in the further course of action.
2. What are the common functions and service portal variables not present in a scoped application?
Please let me know how do I proceed.
Thanks,
Arnab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 04:47 AM
Arnab,
To fix your error, you need to understand what the widget does and how it behaves. It appears that it needs an ID specified on the URL OR via the form input (even a hidden field.) How you supply that may come from clicking another link on another widget or somewhere in that widget. Either way, someone somewhere needs to supply sysparm_timesheet_id to make this thing work the first time, otherwise it's going to default to input.timesheetId, which doesn't exist on initial invokation.
Order of execution when the widget starts is Server code (usually to retrieve data and load the data object if desired) then render HTML, and client scripts react to the HTML behavior (e.g. click a button.) Not always... A client script could re-call the server script via the c.server.update() method and that's where your 'input' object would come from.
Your questions are very broad and not really suited for a community post so much as a workshop. I recommend continuing to explore videos on the TechNow list and the ServiceNow Developer YouTube channel and come back with specific questions if you have them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 07:02 AM
Thanks a lot Chuck for the explanation.
I will try to explore more and let you know my proceedings. Right now I'm really out of ideas.
Thanks,
Arnab