Forum Discussion

creyes17's avatar
New Contributor
8 years ago

Accessing internalCustomFields for Triggers in Collaborator

Hello world,


I can use the http://collaborator.server/services/json/v1 API with the following JSON body to get data about a review.

[ {
  "command" : "ReviewService.findReviewById",
  "args" : {
    "reviewId" : "42"

Specifically, it includes the following internalCustomFields key:

    "internalCustomFields" : [ {
      "name" : "JiraIssueId",
      "value" : [ "10600" ]
    }, {
      "name" : "ExternalTaskId",
      "value" : [ "" ]
    } ]

I would like to use this JiraIssueId field for a review as an argument to one of the configurable Triggers (say Review Phase Changed for example).


Does anyone know how I would access this internal field?


I know I can use


for visible custom fields that I create, but the internal custom fields are not documented in the http://collaborator.server/manual/index.html?admin_var_subst.html documentation. I've tried 

${review.internal.JiraIssueId}, ${review.internalCustomFields.JiraIssueId}, and ${review.custom.JiraIssueId}

 but none of them work (giving me the following error)

Error: Invalid input: Parameters: ${review.internalCustom.JiraIssueId} is not a valid substitution keyword

Thanks for any help!




1 Reply

  • creyes17's avatar
    New Contributor

    I heard back from SmartBear that there's no supported way to access the fields as a variable in the Trigger.


    I just wanted to post my workaround in case it helps anyone else.


    I created this python script to parse JSON, inspired by this stackoverflow post: .

    (You should be able to replace it with pretty much any json parsing library though).

    #! /bin/python
    import sys,json
    if len(sys.argv) != 2:
      sys.stderr.write('Usage: ' + sys.argv[0] + " [requested attribute(s)]\n")
      sys.stderr.write('    For example: ' + sys.arg[v] + ' "obj[0]"' + "\n")
      sys.stderr.write("    This would get you the first element of the list in the JSON object passed to the script via stdin\n")
      exec "sys.stdout.write(json.dumps(" + sys.argv[1] + "))"
    except ( AttributeError, KeyError ):
      sys.stderr.write('Error: Requested JSON attribute does not exist.')
      sys.stderr.write('    Requested: ' + sys.argv[1])
      sys.stderr.write('    JSON: ' + json.dumps(obj))

    Assuming that this script lives at /bin/parse-json on the same machine, I wrote the following script to get the internal JiraIssueId field:

    #! /bin/bash
    if [ -z $collaboratorReviewId ];
      echo "Code Collaborator Review Id is required";
      exit 2;
    jiraIssueId=$(curl -X "POST" -H "Content-Type: application/json" -d $data $commandUrl | /bin/parse-json '[field["value"][0] for field in obj[0]["result"]["internalCustomFields"] if field["name"] == "JiraIssueId"][0]' | sed -e 's/"//g');
    # Do whatever you want with the $jiraIssueId here

    There are some obvious downsides to this approach, but I think it should work for now.