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

Thingworx REST CALL to obtain the full URL containing session id and mashup name

nikkolasep
10-Marble

Thingworx REST CALL to obtain the full URL containing session id and mashup name

Hi all,

 

I'm currently trying to trace down the usage from some mashups. The idea is to create an extension containing js code that will be triggered whenever index.html > CombinedExtension get called. This will happen everytime any user opens any mashup (which is desired). It will contain (user, datetime, mashupname, current session id). Does anyone know how to obtain the current session id and also current mashup and master mashup name from the opened mashup (see the url below). 

 

There is a suggestion to use Function > Expression to call TW.location.href, which actually works only in Thingworx runtime. But if using this I need to create this function expression in every mashup and I have dozens of them. I will try to implement it in a deeper layer which is via extension and for this I need to use REST call, is there a way to call a Function > Expression > TW.location.href via REST Call? I tried to call TW.location.href from outside Thingworx runtime and failed It's also fine if there is a syntax that can get the same result via service or similar. 

 

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

 

2 REPLIES 2
PaiChung
22-Sapphire I
(To:nikkolasep)

Why not run a service within the Mashup on load that adds the info from CurrentSessionInfo services and the mashup name (hard coded value or parameter on mashup) into a Stream?

nmutter
14-Alexandrite
(To:nikkolasep)

I am not sure how you want to intercept the "whenever index.html > CombinedExtension get called" via an extension.

 

But to answer your issue that "TW.location.href" is not available outside thingworx runtime -> location.href is what you want to use instead. The "TW."-object is just some helper for TWX-expression sandbox which runs the expression javascript code in a sandbox-env where normal js objects (like "location.") are not present. They make some info available via the "TW." object.

Top Tags