Skip to main content
12-Amethyst
June 7, 2023
Solved

Get the current session id from the opened mashup

  • June 7, 2023
  • 1 reply
  • 1958 views

Hi all,

 

I'm currently trying to trace down the usage from some mashups. The idea is to create a service that will be triggered by auto refresh every 60 secs containing (user, datetime, mashupname, current session id). Does anyone know how to obtain the current session id from the opened mashup (see the link below). Is there any session parameter that contains this?

 

e.g. https://thingworx-server/Thingworx/Runtime/index.html?mashup=Templatename&forceClose=true&__enableBMF=true&__fromNextGen=8587fe65-9d60-4cb0-bbcb-7d41a78d2169&features=#master=Mastertemplate&mashup=&forceClose=true&features=

 

Best answer by jensc

Hello,

 

You could use the "TW.location.href" function that is available in the Thingworx runtime (expression or validator).

This function gives you the entire URL, so you would have to write some code to get just the token.

 

The following gives some information around the runtime functions in Thingworx: PTC Help Center

 

Hope it helps.

 

Regards,

Jens

1 reply

jensc17-PeridotAnswer
17-Peridot
June 7, 2023

Hello,

 

You could use the "TW.location.href" function that is available in the Thingworx runtime (expression or validator).

This function gives you the entire URL, so you would have to write some code to get just the token.

 

The following gives some information around the runtime functions in Thingworx: PTC Help Center

 

Hope it helps.

 

Regards,

Jens

12-Amethyst
June 12, 2023

I tried to call the function via expression function but I don't get any value. What I did is I created a expression function and write the following:

output = TW.location.href; //Output as a String

I then bind it with a label

Do you know what is the cause of this error or is there another way to get the complete url? 

17-Peridot
June 12, 2023

Hello,

 

Did you trigger the service in any way?

As an example, you can use the mashups "Loaded" event to trigger the service.

The "Auto Evaluate" doesn't work unless you have an input that changes.

 

Regards,

Jens