Structure formula help - extracting specific information from a summary bean field

snasello July 27, 2023

In our Jira system (server version) we have a Jira field called development that has data like this:

{summaryBean=com.atlassian.jira.plugin.devstatus.rest.SummaryBean@7b282e38[summary={pullrequest=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@58970e1f[overall=PullRequestOverallBean{stateCount=8, state='MERGED', details=PullRequestOverallDetails{openCount=0, mergedCount=8, declinedCount=0}},byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@3fa7f13e[count=8,name=GitHub Enterprise]}], build=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@5f20f723[overall=com.atlassian.jira.plugin.devstatus.summary.beans.BuildOverallBean@75980dae[failedBuildCount=0,successfulBuildCount=0,unknownBuildCount=0,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], review=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@5249b39b[overall=com.atlassian.jira.plugin.devstatus.summary.beans.ReviewsOverallBean@52e796ed[stateCount=0,state=<null>,dueDate=<null>,overDue=false,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], deployment-environment=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@aa6fa7d[overall=com.atlassian.jira.plugin.devstatus.summary.beans.DeploymentOverallBean@3f6673fa[topEnvironments=[],showProjects=false,successfulCount=0,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], repository=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@20accae6[overall=com.atlassian.jira.plugin.devstatus.summary.beans.CommitOverallBean@4e1260e0[count=3,lastUpdated=2023-05-12T16:52:15.000-0700,lastUpdatedTimestamp=2023-05-12T16:52:15.000-07:00],byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@735a1e4d[count=3,name=GitHub Enterprise]}], branch=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@7faf5a7f[overall=com.atlassian.jira.plugin.devstatus.summary.beans.BranchOverallBean@39124496[count=1,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@645a2634[count=1,name=GitHub Enterprise]}]},errors=[],configErrors=[]], devSummaryJson={"cachedValue":{"errors":[],"configErrors":[],"summary":{"pullrequest":{"overall":{"count":8,"lastUpdated":"2023-05-12T17:30:27.000-0700","stateCount":8,"state":"MERGED","details":{"openCount":0,"mergedCount":8,"declinedCount":0,"total":8},"open":false},"byInstanceType":{"githube":{"count":8,"name":"GitHub Enterprise"}}},"build":{"overall":{"count":0,"lastUpdated":null,"failedBuildCount":0,"successfulBuildCount":0,"unknownBuildCount":0},"byInstanceType":{}},"review":{"overall":{"count":0,"lastUpdated":null,"stateCount":0,"state":null,"dueDate":null,"overDue":false,"completed":false},"byInstanceType":{}},"deployment-environment":{"overall":{"count":0,"lastUpdated":null,"topEnvironments":[],"showProjects":false,"successfulCount":0},"byInstanceType":{}},"repository":{"overall":{"count":3,"lastUpdated":"2023-05-12T16:52:15.000-0700"},"byInstanceType":{"githube":{"count":3,"name":"GitHub Enterprise"}}},"branch":{"overall":{"count":1,"lastUpdated":null},"byInstanceType":{"githube":{"count":1,"name":"GitHub Enterprise"}}}}},"isStale":true}}

I’m looking to create a custom formula in structure to extract PullRequestOverallDetails .mergedCount. In this example I'd want my custom field to display 8

Based on my research, this prior support request suggests that I should be able to create a formula similar to the below to extract a matched group

REPLACE(development; "/(PullRequestOverallDetails\{openCount=([0-9]+), mergedCount=([0-9]+), declinedCount=([0-9]+)\})/"; "$3")

unfortunately i’m only getting the unchanged development string back.

I used regex101.com to validate the regex

Screen Shot 2023-07-27 at 9.38.17 AM.png

I’d love any help you could offer

other articles reviewed
Use Structure Formula to extract text from summary field 

1 answer

0 votes
Stepan Kholodov _Tempo_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2023

Hello @snasello 

The mergedCount= seems to be a unique combination of symbols, so you can try using it as reference in the formula like this:
left(split(development,"mergedCount=").last(), 1)

If you need further assistance, please reach out to us directly at our support portal.

Best regards,
Stepan Kholodov
Tempo

snasello July 28, 2023

Hi @Stepan Kholodov _Tempo_ I'm very happy to have this option and it's working pretty well for mergedCount :). 

I do need to grab one more piece of information out of this string that might not work with your suggestion.

I need to get the number of commits as well, given by the path of:
devSummaryJson.cachedValue.summary.pullrequest.repository.overall.count

Are there any regex options rather than using the split command?

Screen Shot 2023-07-28 at 6.29.54 AM.png

 

{summaryBean=com.atlassian.jira.plugin.devstatus.rest.SummaryBean@544cf105[summary={pullrequest=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@545cf5b[overall=PullRequestOverallBean{stateCount=6, state='MERGED', details=PullRequestOverallDetails{openCount=0, mergedCount=6, declinedCount=2}},byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@4d12b1c3[count=6,name=GitHub Enterprise]}], build=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@6686802d[overall=com.atlassian.jira.plugin.devstatus.summary.beans.BuildOverallBean@37cbd4bb[failedBuildCount=0,successfulBuildCount=0,unknownBuildCount=0,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], review=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@64e382aa[overall=com.atlassian.jira.plugin.devstatus.summary.beans.ReviewsOverallBean@3c27ab5c[stateCount=0,state=<null>,dueDate=<null>,overDue=false,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], deployment-environment=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@6ef2d31d[overall=com.atlassian.jira.plugin.devstatus.summary.beans.DeploymentOverallBean@775ac74[topEnvironments=[],showProjects=false,successfulCount=0,count=0,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={}], repository=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@7f7b88e2[overall=com.atlassian.jira.plugin.devstatus.summary.beans.CommitOverallBean@7e87a11a[count=29,lastUpdated=2023-07-05T15:55:29.000-0700,lastUpdatedTimestamp=2023-07-05T15:55:29.000-07:00],byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@695ffec[count=29,name=GitHub Enterprise]}], branch=com.atlassian.jira.plugin.devstatus.rest.SummaryItemBean@2c29e546[overall=com.atlassian.jira.plugin.devstatus.summary.beans.BranchOverallBean@f3654b9[count=9,lastUpdated=<null>,lastUpdatedTimestamp=<null>],byInstanceType={githube=com.atlassian.jira.plugin.devstatus.summary.beans.ObjectByInstanceTypeBean@4cfabb34[count=9,name=GitHub Enterprise]}]},errors=[],configErrors=[]], devSummaryJson={"cachedValue":{"errors":[],"configErrors":[],"summary":{"pullrequest":{"overall":{"count":6,"lastUpdated":"2023-07-05T15:55:30.000-0700","stateCount":6,"state":"MERGED","details":{"openCount":0,"mergedCount":6,"declinedCount":2,"total":8},"open":false},"byInstanceType":{"githube":{"count":6,"name":"GitHub Enterprise"}}},"build":{"overall":{"count":0,"lastUpdated":null,"failedBuildCount":0,"successfulBuildCount":0,"unknownBuildCount":0},"byInstanceType":{}},"review":{"overall":{"count":0,"lastUpdated":null,"stateCount":0,"state":null,"dueDate":null,"overDue":false,"completed":false},"byInstanceType":{}},"deployment-environment":{"overall":{"count":0,"lastUpdated":null,"topEnvironments":[],"showProjects":false,"successfulCount":0},"byInstanceType":{}},"repository":{"overall":{"count":29,"lastUpdated":"2023-07-05T15:55:29.000-0700"},"byInstanceType":{"githube":{"count":29,"name":"GitHub Enterprise"}}},"branch":{"overall":{"count":9,"lastUpdated":null},"byInstanceType":{"githube":{"count":9,"name":"GitHub Enterprise"}}}}},"isStale":true}}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events