- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 11:42 AM
I have a task to define a link to a new incident which is prefilled with caller information based on the callers user_id. The requirements are:
- New Incident form opened up directly via a URL-link from a telephony system
- Caller field prefilled based on user_id (other system creating link do only have access to AD and not ServiceNow)
- Location field prefilled based on above users location
- And then some other fields that are always set to same (example "Contact type" = 'Phone')
- Preferably this should be done without giving access rights to telephony system as it should be the helpdesk agent that should be linked and hence the helpdesk agents access rights should be used
What I have found is a thread that never got a solution: https://community.servicenow.com/community?id=community_question&sys_id=62048be5dbd8dbc01dcaf3231f96...
It uses a link that uses: opened_by=javascript:getreqid(%27dhamas%27)
And claimes it do not work. Anybody has a solution on how to proceed?
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 08:02 PM
How about trying the following content?
- Create "Client callable"script include. Sample code is following:
-
var SISampleClient = Class.create(); SISampleClient.prototype = Object.extendsObject(AbstractAjaxProcessor, { getUserSysId: function (user_name) { var sysId = ''; var gr = new GlideRecord('sys_user'); gr.addQuery('user_name', user_name); gr.query(); if (gr.next()) { sysId = gr.getUniqueValue(); } return sysId; }, type: 'SISampleClient' });
-
- Open the incident form from the following URL.
-
https://instance_name.service-now.com/nav_to.do?uri=/incident.do?sys_id=-1%26sysparm_query=active=true^caller_id=javascript:new SISampleClient().getUserSysId('user_name')
-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 12:33 PM
The other post you referenced, the reason they gave that it didn't work for them is that they wanted the link to work on first click when they are logged out. Otherwise on second click (when user is logged in) it worked fine. Obviously being logged out the system isn't going to run internal scripting unless the page is public.
Thus if you're not looking for this requirement to work while logged out OOB ServiceNow is built to auto-populate form fields in the platform UI based on a sysparm_query parameter. For example:
https://<instance-name>.service-now.com/incident.do?sys_id=-1&sysparm_query=caller_id=javascript:gs.getUserID()^short_description=test%20url
That link will auto-populate a new incident record with the current logged in user as the caller and populate short description with "test url".
I don't think there is an OOB script that will do this with user_id (username). So, a script include or business rule will need to be made to replace "gs.getUserID()" if the caller needs to be different than the current logged in user and based on the provided user id (username).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 01:56 PM
I'm no expert so take my advice with a grain of salt. However, I would try creating a client script for the form that does what you want. The process for creating the client script is different depending on if you are wanting to create incidents from a record producer on the service-portal or directly via the "back-end" of SN.
I think if you check that the current logged in user has does not have itil and is creating a new record you could then populate the caller with gs.getUser().
It might make sense that if you have location fields that you want to auto-populate with the user's location that should be handled in a separate client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 04:03 PM
I think you're looking for the cti.do page;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2018 06:44 AM
Yes, that is one way of doing it. It all depends on your requirements. This time the customer wants to work from the telephony system. Who am I to argue that much about that... 🙂