cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Need server name to pass url dynamically for organization login page

AP_9587236
17-Peridot

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

ACCEPTED SOLUTION

Accepted Solutions

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;

View solution in original post

10 REPLIES 10
PaiChung
22-Sapphire I
(To:AP_9587236)

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

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

PaiChung
22-Sapphire I
(To:AP_9587236)

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.

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;

PaiChung
22-Sapphire I
(To:AP_9587236)

Potentially you can use CurrentUserSession functions as well.

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

PaiChung
22-Sapphire I
(To:AP_9587236)

GetCurrentIPAddress 

GetCurrentUserOrganizations 

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

Yes, we need IP address and current organisation. Any service available in thingworx to get  port number also?

PaiChung
22-Sapphire I
(To:AP_9587236)

Don't know about port, not sure if the 'location' object client side would provide that or not.

Okay

Thanks

Announcements


Top Tags