Configure Lens launcher using scripted screen

concept australia Updated Sep 10, 2026 1 min read config-lens-launcher-scripted-screen.md
Raw file servicenow.com

Configure a ServiceNow AI Lens launcher button with scripted screen.

The following example adds a button instance to the “top-icon” location of the scripted screen. The highlighted portions indicate the updates needed in an existing scripted screen to add the ServiceNow AI Lens Launcher button.

[Omitted image "na-lens-launcher-scripted-screen.png"] Alt text: scripted screen with new code highlighted

JavaScript
(function ScriptedScreen(input, result) {var builder = new sn_scripted_screen.ParameterScreenBuilder("scripted_screen_incident", "Edit Incident Scr");builder.nextLabel = gs.getMessage("Next");builder.previousLabel = gs.getMessage("Previous");builder.cancelLabel = gs.getMessage("Cancel");builder.submitLabel = gs.getMessage("Submit");var variableBuilder = new sn_scripted_screen.VariableBuilder("v_short_description", "db_field");variableBuilder.addAttribute("FieldName", "short_description");
var buttonInstanceBuilder = new sn_scripted_screen.ButtonInstanceBuilder("a719743e0f703210e83019e800d1b29d", "Lens Launcher", "top_icon");buttonInstanceBuilder.icon = "76d03b43ff6c721057e9ffffffffff1f";
var inputBuilder = new sn_scripted_screen.InputBuilder("short_description", "string", "Short Descrition");inputBuilder.autofillVariable(variableBuilder);builder.addInput(inputBuilder);builder.addButtonInstance(buttonInstanceBuilder);builder.addVariable(variableBuilder);builder.presentationStyle = "screen";builder.advancedPagination = "true";result.screenBuilder = builder;return result;})(input, result);

In this example, a719743e0f703210e83019e800d1b29d is the sys_id of the sys_sg_button of type lens_launcher. The button must be created declaratively.

76d03b43ff6c721057e9ffffffffff1f is the sys_id of the sys_sg_icon.

PresentationStyle should be screen to support a button instance on an input form screen or scripted screen.

The third parameter in ButtonInstanceBuilder() is the location. The location can be either top_icon or top.

Parent Topic:Configure Lens launcher button

Search documentation
Search document titles and file paths on the australia branch