Skip to end of metadata
Go to start of metadata

Some fields just can't be set using the regular Jira REST API, the Portfolio Parent Link is one of those fields. Fortunately, you can easily create a script that uses the Power Scripts REST Service to do the job when the Jira API can not.

To start, we need to the script that will run when called by the REST Service. This script is actually very generic, any custom field can be set using a simple script like this:

//This script updates the value of a custom field
//Custom field and value is passed to script as a parameter

string field = argv[0];
string value = argv[1];
%field% = value;

This is an example Curl script that calls the Power Scripts REST Service to run the script.

curl -X POST -u admin:admin http://localhost:8080/rest/keplerrominfo/refapp/latest/async-script/runScript \
  -H 'Content-Type: application/json' \
  -d '{"source":{
        "type": "FILE",
        "code": "updateCustomField.sil"
   "properties": [{
        "key": "sil.issue.key",
        "value": "TP-123"
   "args": ["customfield_12345", "PORT-456"]}'

To customize this curl script you need to do the following:

  1. update the username and password with a valid user account. This is set in the beginning after the -u parameter.
  2. Update the Jira base URL. The address format is <your_base_url>/rest/keplerrominfo/refapp/latest/async-script/runScript.
  3. Make sure the name and path of the script are correct. This is set in the "code" field in the JSON data. In this example, the script is called "updateCustomField.sil".
  4. Update the key of the issue that will be updated. This is set in the "value" field in the JSON data. In this example, the script is called "TP-123".
  5. Update the custom field ID of the Parent Link field or the name of the SIL alias was set up previously. This is passed in the "args" field array in the JSON data. In this example, the ID is "customfield_12345".
  6. Update the key that the issue should be linked to (the parent). This is the second value in the args array. In this example, the parent link is "PORT-456".
  • No labels