Skip to end of banner
Go to start of banner

Configuring scripts for generic fields

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The operations supported by generic fields are: DEFAULT, GET, SET, INSERT, UPDATE, DELETE, SEARCH and SEQ.

Configuring a read-only field via the Configuration Wizard will only generate the GET, INSERT, UPDATE, DELETE and SEARCH scripts. This is just a starting point, feel free to adjust the scripts according to your needs for the field.

DEFAULT

The DEFAULT script is triggered when creating an issue and you have to configure it if you want to initialize the field with a default value. The default value is set only if no other value is manually selected for the field in the Issue Create screen.

Important: you have to refer to the same columns previously defined in the Columns tab. The output of this script has to respect the names, data types and exact order in which the columns are configured.

SQL Example: Let’s assume that for all newly created issues, you want to initialize the Country field with the corresponding values of the table record that has ‘Germany' value in the 'name’ column. You will have to configure the DEFAULT script like this:

SELECT id, code, name, independence, gdp_capita, capital, is_eu FROM countries WHERE name = 'Germany'

GET

The GET script is triggered when the field has to be displayed in a Jira page. The frequency with which it runs depends on the Refresh type that is configured (https://appfire.atlassian.net/wiki/spaces/PSJ/pages/540574265/General+settings+for+read-only+fields#Refresh-type ).

Important: you have to refer to the same columns previously defined in the Columns tab. The output of this script has to respect the names, data types and exact order in which the columns are configured.

Important: the column set as Primary Key should be the only one used by this script, to ensure the uniqueness of the result.

SQL Example:

SELECT id, name FROM countries WHERE id = {:1}

SET

The SET script

INSERT

The INSERT script is triggered every time the Insert action is completed.

If the security configured for the field (https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15482145/General+settings+for+generic+fields#Security-Type ) allows it, users are able to insert new values in the database. Clicking on the following icon:

will render a form with inputs corresponding to the columns in the field configuration. Submitting this form, which can be done either using ‘Insert only’ or ‘Insert & Set’ buttons, will run the INSERT script, providing it with the values filled in the form.

Important: you have to refer to the same columns previously defined in the Columns tab.

SQL Example: If you want to allow adding new values to your table, you have to configure the INSERT script like this:

INSERT INTO countries(id, code, name, independence, gdp_capita, capital, is_eu) VALUES ({:1}, {:2}, {:3}, {:4}, {:5}, {:6}, {:7})

UPDATE

DELETE

The SEARCH script is triggered every time the field has to display the list of possible values for the user to select from.

Important: you have to refer to the same columns previously defined in the Columns tab. The output of this script has to respect the names, data types and exact order in which the columns are configured.

SQL Example: Let’s assume you want to use as options in your field only countries that are members of the European Union (having the ‘is_eu’ column set to true in the table of origin). You will have to configure the SEARCH script like this:

SELECT id, name FROM countries WHERE is_eu = true

SEQ

  • No labels