Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Button handy
blanktrue
color#0052CC
nameSend Feedback
linkhttps://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Configuring+scripts+for+generic+fields+-+543031310
widthauto

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.

Image Modified

DEFAULT

The DEFAULT script is triggered when creating an issue and you have to configure it . It needs to be configured only 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:

Code Block
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 is displayed in a Jira page. The frequency with which it runs depends on the Refresh type that is configured for the field (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 configuredthe column set as Primary Key is the only indexed parameter that should be used by this script.

SQL Example:

Code Block
SELECT id, code, name, independence, gdp_capita, capital, is_eu FROM countries WHERE id = {:1}
Image Added

SET

The SET script is triggered every time the field value is stored in Jira. It is not mandatory to configure it, it's just a helpful instrument in case you need to take an additional step, simultaneous with setting the field’s value.

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 search and set values for the field in Jira. Clicking on the following icon:

Image Added

will open a dialog in which the SEARCH script will be run, providing it with values present in the dialog’s form that is composed of all the columns marked as searchable in the column list configuration https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15481863/Columns#Searchable.

If a value from the result set is selected, it is stored in Jira and the SET script is triggered.

Important: the column set as Primary Key is the only indexed parameter that should be the only one used by this script, to ensure the uniqueness of the resultthe SET script.

SQL Example: Let’s assume every time you set a value for the field you want to trigger a script that writes in a separate audit table. You will have to configure the SET script like this:

Code Block
SELECTINSERT id, name FROM countries WHERE id =INTO countries_audit (issue_key, country_id, update_date) VALUES ({issue:key}, {:1}
Image Removed

SET

The SET script
, CURRENT_DATE)
Image Added

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 rows 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.

The parameters to be used in the INSERT script should be coded like: {:1}, {:2} etc. which, at runtime, will receive the form value for the field’s column with the specified index.

Important: you have to refer to the same columns previously defined in the Columns tab and make sure you are using the correct index equivalent.

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

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

UPDATE

The UPDATE script is triggered every time the Update 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 update existing rows in the database. Clicking on the following icon:

Image Added

will render a form with inputs corresponding to the columns in the field configuration.

Submitting this form will run the UPDATE script, providing it with the values filled in the form.

The parameters to be used in the UPDATE script should be coded like: {:1}, {:2} etc. which, at runtime, will receive the form value for the field’s column with the specified index.

Important: you have to refer to the same columns previously defined in the Columns tab and make sure you are using the correct index equivalent.

SQL Example: If you want to allow updating rows from your table, you have to configure the UPDATE script similar to this:

Code Block
UPDATE countries SET code = {:2}, name = {:3}, independence = {:4}, gdp_capita = {:5}, capital = {:6}, is_eu = {:7} WHERE id = {:1}
Image Added

DELETE

The DELETE script is triggered every time the Delete 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 delete existing rows from the database. Clicking on the following icon:

Image Added

will ask for confirmation to delete the currently selected row. Accepting it will run the DELETE script, providing it with values present in the field.

The parameters to be used in the DELETE script should be coded like: {:1}, {:2} etc. which, at runtime, will receive the value for the field’s column with the specified index.

Important: you have to refer to the same columns previously defined in the Columns tab and make sure you are using the correct index equivalent.

SQL Example: If you want to allow deleting rows from your table, you have to configure the DELETE script similar to this:

Code Block
DELETE FROM countries WHERE id = {:1}
Image Added

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

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 search and set values for the field in Jira. Clicking on the following icon:

Image Added

will open a dialog in which the SEARCH script will be run, providing it with values present in the dialog.

The parameters to be used in the SEARCH script should be coded like: {:1}, {:2} etc. which, at runtime, will receive the value for the field’s column with the specified index.

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)search criteria the code and name of the countries and you want to search for countries having a code or name that contains the values entered in the screen inputs. You will have to configure the SEARCH script like this:

Code Block
SELECT id, code, name, independence, gdp_capita, capital, is_eu FROM countries 
WHERE is_eu = true
Image Removed
 code LIKE '%' || {:2} || '%' OR name LIKE '%' || {:3} || '%'
Image Added

SEQ

Contents

Table of Contents

See More

Child pages (Children Display)
depth2
pageAdvanced Configuration