Open Site Navigation

Send Surveys to Guest Users

Updated: Oct 21, 2021

I came across this use case recently and found some information on public surveys but nothing really cohesive, which meant taking bits and pieces from different community articles, so I decided to document my solution and what it may be used for here. This solution will be specific to my use case though I'll touch on some other ways to use public surveys in the Takeaways section.

Use Case

The organization is logging Incidents under the Guest user within the Caller field for Incidents, and gathering their email address on a field that exists specifically on the Incident table (not Task, though I will tell you how this may be more helpful) and wants to send a survey associated the Incident record out to the email captured in the Incident, allowing a user who is not logged in to take the survey and associate the results to the Incident.

Just a quick aside on the Guest user, normally this is used in Inbound Email Actions for when an email is received by someone who is not recognized as a user in the system (putting in code to add the email address the user sent the email from to the Watch List is a nice to have), but it can also be used by Service Desk users logging Incidents, etc. for users who cannot authenticate in the system, but need to place Incidents, etc. for the purposes of the organization.

This approach works for the Guest user because the Guest user cannot login via SSO, so when the survey link hits the Service Portal or whichever portal you're using, the Assessment Instance is tied to the Guest user, and the link won't make the user try to login while allowing them to still take the survey that is associated to a record. While the Guest user is the Assigned To on the assessment instance, the responses are recorded, and we know from the record associated to the Assessment Instance what the survey was for, and what email address it was sent to.

Survey and Trigger Conditions

For my purposes I'm going to reuse an OOTB survey found in my PDI. In order to make the survey public, click the Enable Public Access related link. A message will appear stating: Survey: Short Customer Satisfaction Survey using Smiley Face is now publicly available to users that are not logged in.

Per the Product Documentation, the Enable Public Survey link allows users that are not logged in to take a public survey and is available to users and non-users to respond anonymously. When public surveys are completed, the Assigned To field is set as Guest. This is kind of the opposite of our use case here, because we're associating a Survey to a Task record type, and setting the Caller as Guest before creating the Assessment Instance.

I also modified the Trigger Condition for the survey, to not repeat every 30 days, because Guest can be anyone and I want it to send every time. So let's just use 'Short Customer Service Satisfaction Survey using Smiley Face' and modify the Trigger Condition for it.

The Survey will kick off every time an Incident has been Closed and Universal Request is Empty and it will be Assigned To the Guest user.

Setting up a Business Rule that Triggers an Event

I purposely didn't hit the easy button on this scenario and create the email field I'm filling out on my Incident on the Task table to align with how organizations may come across this same scenario, and to discuss events. Since the Task field is on the Assessment Instance record, if your field to capture email is on the Task table, you can easily dot walk on your Survey notification to Task.YourEmailField in the Who will receive section under Users/Groups in Fields.

For my purposes I've created an Email (u_email) field on the Incident table, which as a Service Desk user I will manually populate when someone calls in, while logging the Caller field as Guest, this could be used for Record Producers, etc. as well. I did this because a lot of organizations probably have done it this way, i.e. created a field to capture this information specifically on Incident and not Task, because that's the best practice stated way of creating the field, i.e. not clogging up Task with un-necessary fields and I wanted to show how this ask could be accomplished with a method a lot of organizations are using.

I want to create an Assessment Instance when the Incident is closed, and send the Survey notification to the email in the Email (u_email) field, while having the Assigned To on the Assessment Instance as the Guest user. For the Assessment Instance creation, I don't have to do anything, just let the Assessment Business Rules do their thing and it will automatically capture the Guest user.

Next I registered an event called survey.guest and will use it in a Business Rule. I want to be specific when the Business Rule triggers, so I basically copied the conditions from the 'Survey User Invite' notification, and limited it to my specific Survey for now, which can be extended in the future for other surveys that allow the Guest user.

Name: Notify Guest User

Table: asmt_assessment_instance

Advanced: True

When: after

Insert: True

Update: True

Here's a screenshot of the conditions I used:

And here's the code I used to trigger the event:

(function executeRule(current, previous /*null when async*/) {

    var email;
    var task = current.task_id;
    var incGr = new GlideRecord('incident');
    email = incGr.u_email;
    gs.eventQueue('survey.guest', current, email);

})(current, previous);

Sending a notification based upon an Event

There's two things I'm going to do here. First, I'll add a condition to the OOTB Survey User Invite notification to exclude Assigned To as Guest, because I don't want my notifications competing with one another. Next I'll create a new notification called Survey User Invite (Guest):

When to send:

Send when: Event is fired

Event name: survey.guest

Who will receive:

Event parm 1 contains recipient

What it will contain:

I just copied what was in Survey User Invite, and created a new mail script for the survey link.

Here's the mail script, I called public_survey instead of take_survey since it's a public portal page and take_survey is only for logged in users.

(function runMailScript(current, template, email, email_action, event) {

    var instanceUrl = gs.getProperty('glide.servlet.uri');
    var url = instanceUrl + "sp?id=public_survey&instance_id=" + current.sys_id;
    template.print('<a href=' + url + '>Take Survey</a>');

})(current, template, email, email_action, event);

Testing it out

First, I'll create an Incident for the Guest user, capture an email in the Email (u_email) field and work through setting it in a Closed state.

Next, I'll verify the Assessment Instance was created and it is assigned to the Guest user.

To verify, I'll also check the Event log to make sure my event triggered and is passing the email address as Parm1.

For this article I had email sending turned on in my PDI, but you can test this by previewing the email in the Outbox in either copying the link into an incognito window, or logging out of the instance and pasting it in. To reduce confusion, if a logged in user clicks/pastes the link, the public_survey page will redirect to the take_survey page and since the Assessment Instance is assigned to the Guest user, they will see a message informing them the URL is invalid.

I clicked the link from the email listed in the Email field on my Incident and am able to view and take the survey.

As an admin/survey_admin, I can see the Assessment Instance is now complete, and view the user's response.


This article was a specific use case for allowing public users to take surveys that are assigned to the Guest user and related to a specific record. There are other ways of creating public surveys that I'll mention here.

Public Surveys: The wording in the product documentation is a little fuzzy to me here. Since it states users and non-users can anonymously take a survey and the Assigned To is Guest after they complete the survey, this leads me to believe the Assessment Instance itself is not tied to a Task record (because that wouldn't be very anonymous unless you make sure to click 'Anonymize responses' in the survey though this still leaves a trace of who created it to the survey_admin), and users are accessing this link via a generic link that has been distributed in a notification and creates the Assessment Instance after the link has been clicked, and not via Trigger Conditions creating Assessment Instances based off Task record conditions.

I will note, there is a Now Support article that details triggering static URLs for consumers which can append a Case that triggered the notification. As I read through this more, it seems like it could've worked for my use case, because you can append the table and sys_id of the record that triggered the notification to the survey link, except for the note at the bottom regarding the Service Portal, which seems a bit clunky to me, because I didn't want users taking the survey from the back-end view, I have a nice portal, and my public survey is customer facing, so I would want to ensure consistency with their experience by showing them the survey in the portal as the same interface they use to log their incidents. Also, since the public_survey link needs an instance_id passed as a parameter, we have to have the Assessment Instance created before the user enters the link for the Service Portal.

Note: Set the Allow survey link from email to open in service portal view (applies only for surveys) property value to false to disable survey records from opening in Service Portal.

The sendable link looks like this:

Here's what that public survey would look like using that link:

Here's the link with the mentioned parameters:

As always with ServiceNow there are a number of ways to accomplish a goal, but it really depends on your instance, your process, if you want a task record associated with your survey, and what interface you want the survey to be taken on to determine which path you choose. My solution is just what I came up with for the instance I was in, and how I wanted to present the survey to the user but as you can see it could've been done other ways as well. I hope this article shed some light on Public Surveys and ways you can send them out to non-logged in users. Feel free to drop some comments in with other ways this can be done, or any questions.


ServiceNow Product Documentation: Configure a survey in the survey designer

ServiceNow Product Documentation: Obtain and distribute a general survey URL

ServiceNow Product Documentation: Survey URLs

ServiceNow Product Documentation: Surveys in Service Portal

Now Support KB: Creating Public Surveys for Consumers

381 views0 comments