Can a playbook assign a ticket to the person that initiated a playbook?

Travis Michigan
Mega Sage

I'm somewhat new to using playbooks, I'm trying to do something on one that I think I should, but I'm overlooking the how to accomplish this.

 

What I would like to do is if someone starts using this particular playbook, if the task it was used on does not have anyone in the assigned to field, that the person using the playbook automatically is assigned to the task.  Is this possible?

1 REPLY 1

Community Alums
Not applicable

Yes, what you're trying to achieve is absolutely possible using Playbooks in ServiceNow. You can use Playbook Actions along with a Script step to accomplish this logic

 

1. Edit the Playbook Template

  • Go to Playbook Experience → Playbook Templates.

  • Open the playbook where you want to add this logic.

2. Add a Script Action as the First Step

  • Add a Playbook Action of type Script.

  • Name it something like "Auto-Assign if Unassigned".

  • Set the Trigger condition to Playbook Start or early enough depending on your sequence.

  • In the script editor, add the following

 

(function executeStep(current, workflow, context) {
    // 'current' is the task the playbook is running on
    if (!current.assigned_to) {
        current.assigned_to = gs.getUserID();
        current.update(); // Save the change
    }
})(current, workflow, context);

 

 

3. Ensure Script Step Runs Only Once

  • Make sure this script is either the first step or marked with an appropriate condition so it only runs if assigned_to is empty.

4. Test Your Playbook

  • Open a record (e.g., an Incident or Case) with no assignee.

  • Launch the playbook.

  • Confirm that the assigned_to field is updated with your user ID after it starts.

 

 

 

  • If you only want to assign when launched manually (not via automation), you can check the source via context or define a flag.

  • You can also make the assignment optional via a Decision step before assignment.