Skip to main content
17-Peridot
July 16, 2021
Solved

Need server name to pass url dynamically for organization login page

  • July 16, 2021
  • 2 replies
  • 5993 views

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??

Best answer by AP_9587236

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;

2 replies

22-Sapphire I
July 16, 2021

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

17-Peridot
July 16, 2021

@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."

22-Sapphire I
July 19, 2021

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.

22-Sapphire I
July 20, 2021

Potentially you can use CurrentUserSession functions as well.

17-Peridot
July 20, 2021

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

22-Sapphire I
July 20, 2021

GetCurrentIPAddress 

GetCurrentUserOrganizations 

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