/
Set default values for system fields on the Create screen

Set default values for system fields on the Create screen

Problem

You want to provide default values for fields on the Create issue screen.

Solution

You can solve this problem using Power Scripts™ Live Fields. For details on accessing the current screen with Live Fields, go to our documentation.

Following this example, you can set the default values on Create issue screen for a specific project.

Consider a given rule that requires users to set the Description, Components, and Affected Versions on the Create issue screen. This script allows you to automatically set certain fields when the issue is created.

First, use the following script to set up your Live Fields to watch for issueType and project.

init.sil
lfInstantHook({"project", "issueType"}, "hook.sil"); lfWatch("issueType", {"issueType", "project"}, "hook.sil");

Next, in the hook script, set the fields to your preferred values to ensure that the event responds.

hook.sil
if(argv["screen"] == "create" && contains(argv["project"], "DEMO") && argv["issueType"] == "Bug") { //on Create Issue screen lfSet("description", "Please describe what's happening: \n\n" + "What you think should be happening: \n" + "Where it's found: \n" + "Steps to reproduce: \n#action 1\n#action 2\n#action3"); lfSet("components", {"ui", "business"}); lfSet("affectedVersions", {"1.0.1", "1.0.2"}); }

The script is only effective for the Create issue pop-up window. When creating an issue in a new tab, the Issue type and Project system fields are already set and thus the hook is not applied.

Related content