Versions Compared

Key

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

StashincludebyfilepathrepoSlugsil-script-librarybranchIdrefs/heads/masterprojectKeyCAPfilepathSome 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:

Bitbucket file macro
showLineNumberstrue
titleupdateCustomField.sil
urlhttps://bitbucket.cprime.io/projects/CAP/repos/sil-script-library/raw/API/updateCustomField.sil
showLineNumberstrue
progLangjava
applicationLinke1651377-b920-3831-9722-2aeff6dc52cd
Stashincludebyfilepath
repoSlug?at=refs%2Fheads%2Fmaster
syntaxHighlightingJavaScript

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

Bitbucket file macro
showLineNumberstrue
titleupdateCustomField_curl.txt
urlhttps://bitbucket.cprime.io/projects/CAP/repos/sil-script-library
branchIdrefs/heads/master
projectKeyCAP
filepathAPI/updateCustomField.sil
showLineNumberstrue
progLangjava
applicationLinke1651377-b920-3831-9722-2aeff6dc52cd/raw/API/updateCustomField_curl.txt?at=refs%2Fheads%2Fmaster
syntaxHighlightingJavaScript

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