How do you grab the source of your ticket?

NeilH2
Giga Guru

Hi all

We have a requirement to show the number of incidents and requests logged via our portal.

I was wondering if anyone had already addressed this or if anyone had any ideas on how it could be implemented?

I know there is a Contact Type field in Service Now but i'm at a loss on how this can be populated correctly.

Neil

9 REPLIES 9

jordanr
Tera Contributor

Hi Neil,



I was curious if you were able to figure out how to set the contact_type of requests to self service if they are coming from the portal. I have been tasked with this as well and I have not been able to narrow down the logic by groups or roles enough to set it correctly all of the time. If you found a solution I would really appreciate your input on this.



Thanks,



Jordan R.


I don't know how valid this is but it may help.  



document.referrer will give you the URL that was used to access the current page.



You may be able to parse the referring URL string to determine if it came from your portal.



Document.referrer - Web API Interfaces | MDN


Thanks for the response Justin. I have tried to incorporate this information in a Dictionary Override on the Request contact_type, but I have not been able to get any thing working. Should I use these scripts in another place? The 2 scripts I have tried are below. If you have any suggestions to where I am going wrong, it would be appreciated.



1.)


Javascript:


if (document.URL.indexOf('ess_portal')==-1){


current.contact_type= 'phone' ;


      }


      else {


current.contact_type= 'self-service';


      }



2.)


Javascript:



if (document.referrer == ""){


current.contact_type= 'phone' ;


      }


      else {


current.contact_type= 'self-service';


      }



Thanks,


Jordan


Joe Wilmoth
ServiceNow Employee
ServiceNow Employee

Hi Jordan,



You can take advantage of the $[current_site] variable.



<j:set_if var="jvar_is_ess" test="${current_site.url_suffix == 'ess'}" true="true"   false="false" />


<j:if test="${jvar_is_ess}">


    <!-- Do some logic here -->


</j:if>



    Thank you,


Thank you Joe. Where is the best place to put this script? Also, I am fairly new to using jelly. I can follow along with what you have put up so, but am not sure what kind of syntax I would use to set the contact_type. Any more detail you could provide would definitely help me out.   Would it just be current.contact_type or do I need to use g:evaluate?   Thank you for your patience, this particular task is a bit over my head as a beginner.