Skip to main content
Jul 16, 2021 2:59 PM UTC
Solved

Need server name to pass url dynamically for organization login page

On clicking logout button, it needs to be land on organisation page.
If i need to provide organisation page url for redirectURL of logout button means, syntax will be
<server name>/Thingworx/FormLogin/<Organization Name>.

 

The server name differs system to system. I want to provide this dynamically.
1. So when the user logging in the organisation page, any possibility is there to store the url in session variable? So that i can reuse the url for logout widget redirectURL.
2. (or) any other way is there to get server name of any server dynamically using service??

Jul 19, 2021 1:07 PM UTC

Yes. The javascript code to capture server name is not running inside services. So i created an expression with the code: Output=location.host; It is returning server name of current server. Along with this i attached the url format and passed current Organization Name from service of CurrentSessionInfo. Now this code is returning the organization page url successfully. Output="http://"+location.host+"/Thingworx/FormLogin/"+OrgName;

10 replies

Jul 16, 2021 7:31 PM UTC

I've at times been able to do this successfully with setups like ./Thingworx/FormLogin/OrgName or ../ worth a try.

Jul 16, 2021 9:03 PM UTC

@PaiChung Can you please eloborate? 

In the above mentioned setup how you will pass the hostname and port number? from where you will get it ?? ( It should not be hardcoded!!! )

How this will help in passing a complete organization url dynamically?

 

I tried these codes to capture login page url using service, but it doesnt worked.

window.location.href;
window.location.origin;
var result= window.innerWidth;
var url = window.location.host;
var url = window.location.hostname;
var port = window.location.port;

The error is "Error executing service Trial. Message :: ReferenceError: "window" is not defined. - See Script Error Log for more details."

Jul 19, 2021 12:33 PM UTC

I probably misunderstood what you were looking to do.

the ./ or ../ will utilize the Tomcat folder structure the pages are in.

 

Not sure, but perhaps you'll have to maintain a piece of information associated with the user and generate that into a link with a service.

Jul 20, 2021 12:13 PM UTC

Potentially you can use CurrentUserSession functions as well.

Jul 20, 2021 12:29 PM UTC

Can you please name any service in currentsessioninfo which returns hostname/servername like that?

Jul 20, 2021 2:05 PM UTC

GetCurrentIPAddress 

GetCurrentUserOrganizations 

But I think it's not the user IP you are looking for ...