Open new incident via URL with caller preset based on user_id

davidgustafsson
Tera Expert

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:

  1. New Incident form opened up directly via a URL-link from a telephony system
  2. Caller field prefilled based on user_id (other system creating link do only have access to AD and not ServiceNow)
  3. Location field prefilled based on above users location
  4. And then some other fields that are always set to same (example "Contact type" = 'Phone')
  5. 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?

1 ACCEPTED SOLUTION

masateru_tomiok
Kilo Expert

How about trying the following content?

  1. 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'
      });
  2. 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')

View solution in original post

5 REPLIES 5

masateru_tomiok
Kilo Expert

How about trying the following content?

  1. 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'
      });
  2. 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')