[Playbook API] Launching playbooks with input parameters<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } .kb-wrapper { font-family: 'Lato', sans-serif; color: #000000; font-size: 12pt; line-height: 1.7; max-width: 100%; } .kb-wrapper h2 { font-family: 'Lato', sans-serif; font-size: 14pt; font-weight: 900; color: #032D42; border-bottom: 2px solid #e8fce4; padding-bottom: 4px; margin: 24px 0 12px 0; } .kb-wrapper p { font-size: 12pt; line-height: 1.7; margin: 0 0 12px 0; } .kb-wrapper ul, .kb-wrapper ol { font-size: 12pt; line-height: 1.7; margin: 0 0 12px 0; padding-left: 24px; } .kb-wrapper li { font-size: 12pt; line-height: 1.7; margin-bottom: 6px; } .kb-wrapper code { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 3px; padding: 1px 5px; font-family: 'Consolas', 'Courier New', monospace; font-size: 11pt; } .kb-wrapper pre { background: #e6f0f5; color: #032D42; border: 1px solid #b8cfd8; border-radius: 4px; padding: 12px 14px; overflow-x: auto; margin: 12px 0; font-family: 'Consolas', 'Courier New', monospace; font-size: 11pt; line-height: 1.5; } .kb-wrapper pre code { background: none; border: none; padding: 0; color: #032D42; font-size: 11pt; } .kb-wrapper .kb-note { border-left: 4px solid #52B8FF; background: #e6f4ff; padding: 10px 14px; margin: 12px 0; border-radius: 0 4px 4px 0; } .kb-wrapper .kb-note p { margin: 0; } .kb-wrapper table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 12pt; } .kb-wrapper th { background: #032D42; color: #FFFFFF; text-align: left; padding: 8px 10px; border: 1px solid #032D42; font-weight: 700; } .kb-wrapper td { padding: 8px 10px; border: 1px solid #cdd9e0; vertical-align: top; line-height: 1.6; } .kb-wrapper tbody tr:nth-child(even) td { background: #e8fce4; } .kb-wrapper a { color: #032D42; text-decoration: underline; } Issue The Playbook method triggerPlaybook(String scopedName, GlideRecord parentRecord) accepts only a scoped name and a parent record. It does not provide a way to pass input parameters to the playbook execution. When a playbook is configured to accept inputs, those values cannot be supplied at launch through triggerPlaybook. To launch a playbook and provide inputs, use the launchPlaybook API instead. Symptoms A playbook launched with triggerPlaybook starts without its configured input values populated, because the method has no parameter for supplying inputs.There is no available argument on triggerPlaybook to pass key-value input parameters defined on the playbook. Facts The launchPlaybook capability is exposed through the sn_playbook.PlaybookExperience scoped API.Two variants are available: launchPlaybook and launchPlaybookSecure. The secure variant performs a permission check before launching.The playbook being launched must be activated with a valid snapshot. Release Zurich, Australia Cause The triggerPlaybook method signature does not include an input parameter, so passing inputs at launch is not supported by that method. Launching a playbook with inputs requires a method that accepts an input object. Resolution Use the launchPlaybook API to launch a playbook with inputs provided. It can be called from a UI Action, a Script Include, a script step in a subflow or action, and similar server-side scripts. Method signatures sn_playbook.PlaybookExperience.launchPlaybook(processDefinitionId, parentRecord, input) sn_playbook.PlaybookExperience.launchPlaybookSecure(processDefinitionId, parentRecord, input) Parameters ParameterTypeRequiredDescriptionprocessDefinitionIdStringMandatoryThe ID of the process definition (playbook) to launch. The playbook must be activated with a valid snapshot. Returns a PROCESS_DEFINITION_ID_NOT_VALID error if the ID is invalid or does not exist.parentRecordGlideRecordOptionalThe parent record to launch the playbook on. If the activated snapshot contains a parent record input, this must be a valid record in the parent table. Can be empty. If empty, a record is created in sys_playbook_execution and used as the dummy parent record.inputObjectOptionalAn object containing input parameters for the playbook. Must be a valid JavaScript object of key-value pairs. Keys must match the expected input parameters defined in the playbook, and values must be of the types the playbook expects. Return value contextId — the sys_id of the created playbook context. launchPlaybookSecure performs a canLaunchPlaybook check to verify the user has permission to launch the playbook before it is started. Sample script // Playbook parent record var parentRecord = new GlideRecordUtil().getGR("incident", "<incident_sys_id>"); // Playbook to launch var playbookDefinitionId = "<playbook_definition_id>"; // Define input parameters var inputs = { 'input': 'ServiceNow Test' }; // Launch the playbook with input parameters var playbookExecution = sn_playbook.PlaybookExperience.launchPlaybook(playbookDefinitionId, parentRecord, inputs); gs.info(playbookExecution); Related Links PlaybookExperience - Scoped API reference