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

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

how do I set Transaction Context in triggers

mbohanon
1-Newbie

how do I set Transaction Context in triggers

There is a script command called getTransactionContext in the Server Bean. In the description, it mentions a map that can be used to pass information from one script to the next during a transaction. I cannot find how to set or add to this map however.

Would someone please let me know how to add to this map?

Thanks

Mark

1 ACCEPTED SOLUTION

Accepted Solutions

Hello everyone,

I figured it out. After browsing one of the MKS_ALM scripts, I found this: sb.getTransactionContext().put("AutoLabel", "1");

I was confused by the word "get" in getTransactionContext. You can add your own by using .put(key,value)

View solution in original post

7 REPLIES 7

Mark,

You are correct that there is little documentation provided regarding this method. There is an RFC in the system to provide better data for this here: Docs request for getTransactionContext method in the server bean

Please contact PTC Integrity Support if you would like to be added to this RFC.

In the meantime, I can give you some examples on how this may be used. This example applies to the document model context, but it might give you an idea of how it works.

For document model operations, the context map will have the key "operation" set, with value = "<document model op>" where <document model op> can be

one of:

createcontent

createsegment

insertsegment

movecontent

removecontent

branchsegment

changesegmentproject

refmode

baseline

removebaseline

propagatetraces

segmentroots

geneology

viewsegment

togglereference

documentedit

For all other issue edits, there are no values in the context map.

if operation=createsegment, two key/value pairs are added if there is a parent id:

parent=<parentID>

include=true|false

if operation=insertsegment, one additional key/value pair is added:

include=true|false

e.g. if I run the command: im createsegment --insertMode=reference --parentID=971 --type="ALM_Input Document" --field=Project="/ALM_Projects/Release2" --field="ALM_Document Short Title"="test"

then getTransactionContextMap will return:

Key: operation Value: createsegment

Key: parentid Value: 971

Key: include Value: false

Hello Jeremy,

Is there any way to create a Key-Value pair? I was interested in having some method of passing information from one trigger to the next since delta beans don't know where they came from (other than Secondary Issue Change).

Mark,

This is tricky as I'm not sure that we have a properties class or some kind of thread local storage that we can use to pass around data. What kind of info are you looking to share between triggers?

Hello Jeremy,

I was looking for a way to determin where a delta bean came from, such as the name of the script.

From the ScriptServerBean:

getTransactionContext

public java.util.Map getTransactionContext() throws mks.frame.triggers.TriggerException
Returns a map that can be used for the duration of the transaction by all trigger API clients. Any client can read or write lookup values using this map. One possible use is to communicate between scripts involved in the same transaction.

Returns:
Map
Throws:
mks.frame.triggers.TriggerException


Mark,

Can I get you to open a support case for this? I would like to get some more resources behind this to get you the best answer.

KaelLizak
14-Alexandrite
(To:mbohanon)

For anyone else looking for an answer to this, please see CS93203, which currently indicates this enhancement is not available. If you would like to be added to enhancement RFC 766713, please contact PTC Integrity Support.

-Kael


Kind Regards,
Kael Lizak

Senior Technical Support Engineer
PTC Integrity Lifecycle Manager

Hello everyone,

I figured it out. After browsing one of the MKS_ALM scripts, I found this: sb.getTransactionContext().put("AutoLabel", "1");

I was confused by the word "get" in getTransactionContext. You can add your own by using .put(key,value)

Top Tags