Written by

Question David Foard · Jul 8, 2016

Use SessionId as value for target field

Can you assign the SessionId to a target field in a DTL. There is a %Ensemble("SessionId") variable that looks like it would be available to use.

Comments

Brendan Batchelder · Jul 14, 2016

%Ensemble("SessionId") does hold the session id, but by using it you're breaking the abstraction barrier.  There's no guarantee that variable name will continue to be used in future versions.  Why do you need the SessionId in a DTL?  There may be a better way to solve the problem you're trying to solve.

0
Michael Brady · Jul 20, 2016

Hi David,

$$$JobSessionId should work. That will return the session ID for the message being processed if there is one. Brendan, is there any reason that David should not use this? 

As a note, when we create a new Ens.AlertRequest, we call  %OnNew and do the following 

Set ..SessionId = $get($$$JobSessionId)

-Michael

0
Richard W. (VetsEZ) Walker  Oct 26, 2022 to Michael Brady

I have been struggling with "Managed Alerts" and trying to make betters sense of the emails recieved.

This was most helpful because I would like to pinpoint the system and SessionId where the error/warning occurred... well, the "ManagedAlert.SessionId" was not being populated in the Ens.Alerting.NofificationRequest so this was able to capture in the DTL.  Thanks so much for that advice. Now however, it is not populating in the email received... i.e. the "Session" is then Instance name, as is the "System" name...  I'm still trying to find out where these variables are being set and how, if possible, to modify to set them?  Any assistance would be greatly appreciated!  (IRIS for Health version 2020.1 ). 

Sincerely,

r2w

0
Kevin Kindschuh · Apr 17, 2024

To make it easy to get the SessionId from DTL, BPL, or rules, where the $$$JobCurrentHeaderId macro is not defined, add methods like these to your extended function class that Extends Ens.Rule.FunctionSet:

/// Return the current Ens.MessageHeader Id
ClassMethod XCurrentMessageHeaderId() As %String [ CodeMode = expression ]
{
$GET($$$JobCurrentHeaderId)
}

/// Return the current SessionId
ClassMethod XSessionId() As %String [ CodeMode = expression ]
{
$GET($$$JobSessionId)
}

/// Return the current SuperSession
ClassMethod XSuperSession() As %String [ CodeMode = expression ]
{
$GET($$$JobSuperSession)
}
 

0