cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

New Branch ID from Branch Triggers

New Branch ID from Branch Triggers

"Item is branched" triggers, which use the imBranchArgsBean, should have access to the ID of the newly created branch.

 

Possibly related: Branching & Create from Template actions detectable by event triggers

3 Comments
lreveillere
1-Newbie

Hello Cody,

I have just crossed that problem because I wanted a relationship field linking the branched item from the original one.

It is possible to get something like that by simply calling a post-trigger in branched (there you can get with the branchResultBean the IDs of the original and branched one)

if (branchResultBean != null)

    {

        branchingIssueID    = branchResultBean.getBranchingIssue();

        resultingIssueID      = branchResultBean.getResultingIssue();       

    }

Then if you need to do something with one of them you can directly make a JAVA call and modify those items (example below)

var apiSession = eb.createAPISessionBean();

var commandRunner = apiSession.createAPICommandRunnerBean();

resetCommandRunner(commandRunner);

commandRunner.setCommand("im","editissue");

commandRunner.addOption("field", "MY_RELATIONSHIP_FIELD_NAME" + "=" + branchingIssueID);

commandRunner.addSelectionElement(resultingIssueID);

try{

   var result = commandRunner.execute();

   Packages.com.mks.api.util.ResponseUtil.printResponse(result, 1, java.lang.System.out,true);

}

So this does but it can have some performances issues if the document is really big and the server is slow.

I hope it helped.

Best Regards

Mr. Lionel Réveillère

PTC ALM Consultant

dpeter
5-Regular Member

Hi Cody Carey  ,

Does the solution provided by Lionel help?

Can you confirm that you are interested to get the value of resultingIssueID from imBranchArgsBean?

KartikOak
15-Moonstone
Status changed to: Archived

Archived in the absence of the requested clarification.

 

Thanks

Kartik