Hexagon Geospatial
MENU

GeoMedia Smart Client

GeoMedia Smart Client community discussion board is where you can create, contribute and share information and knowledge in regards to configuring as well as working with GeoMedia Smart Client. Find your answers, share your knowledge and help build a strong GeoMedia Smart Client community.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Regular Contributor
Posts: 170
Registered: ‎07-07-2016
Accepted Solution

How to get SESSION value from js?

Hi,

I'm using GMSC 2016 SP4.

Is there a way to get session value using javascript? (i.e. how to get SESSION.USERID value)

 

Staff
Posts: 966
Registered: ‎10-19-2015

Re: How to get SESSION value from js?

Hi,

 

what you can do is to create a formfield called for instance "UserId" (persisted="false") with defaultvalue="{SESSION.USERID}" and the get the value in JS using IG.getItemById('UserId').getValue().

 

Stefano

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Regular Contributor
Posts: 170
Registered: ‎07-07-2016

Re: How to get SESSION value from js?

Ok, that works. But I don't want this field to be on my form. If I change field to be not visible than IG.getItemById('UserId').getValue(). doesn't work.

Contributor
Posts: 23
Registered: ‎01-31-2018

Re: How to get SESSION value from js?

Hullo mzebrows,

 

Have you tried to set the visible-attribute to "hidden"?

 

Here is an example, how to test the behaviour of some values for that attribute:

 

<FormGroup name="Grp1" template="GroupNoLabelTemplate">
    <FormField name="UserIdTrue" visible="true" persisted="false" defaultvalue="{SESSION.USERID}" />
    <FormField name="UserIdHidden" visible="hidden" persisted="false" defaultvalue="{SESSION.USERID}" />
    <FormField name="UserIdFalse" visible="false" persisted="false" defaultvalue="{SESSION.USERID}" />
    <FormField name="Trace" persisted="false" editable="false" type="textarea" />
    <FormAction name="TraceUserIdTrue" label="Trace vis=true field value" action="SCRIPT[IG.getItemById('Trace').value('UserIdTrue='+IG.getItemById('UserIdTrue').value())]" />
    <FormAction name="TraceUserIdHidden" label="Trace vis=hidden field value" action="SCRIPT[IG.getItemById('Trace').value('UserIdHidden='+IG.getItemById('UserIdHidden').value())]" />
    <FormAction name="TraceUserIdFalse" label="Trace vis=false field value" action="SCRIPT[IG.getItemById('Trace').value('UserIdFalse='+IG.getItemById('UserIdFalse').value())]" />
</FormGroup>

As you can see, the trace message written by the TraceUserIdFalse-action is only "UserIdFalse=" whereas the TraceUserIdHidden prints "UserIdHidden=<guid>"

 

Hope this helps you out.

Regular Contributor
Posts: 170
Registered: ‎07-07-2016

Re: How to get SESSION value from js?

[ Edited ]

Ok, I've checked it and the conclusion is:

 

when visible="false" (this value is set my Workflow Manager), then, IG.getItemById('name') doesn't work.

when visible="hidden" (this value can be set manually), then, IG.getItemById('name') works correct.

 

Thanks for the answer!

 

Staff
Posts: 966
Registered: ‎10-19-2015

Re: How to get SESSION value from js?

works as designed. The visibility property can be in general list or form. if you set it to false it means that it will NOT be part of the form at all. if you want to use it you must use hidden. To do this you can still use the workflow editor, using the value editor, from the doc:

Annotazione 2019-03-28 110953.png

 

like we are used to do with the primary keys:

Annotazione 2019-03-28 111249.png

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Occasional Contributor
Posts: 19
Registered: ‎06-18-2018

Re: How to get SESSION value from js?

Hi there,

 

I have seen the solution and understand that it works. Does that mean there is no way to get this value purely through Javascript?

 

I am asking because I want to write a JS function that will be called in the 'on smartclient ready' event and get a session variable. This function will be called in every form of my application, so instead of adding a formfield to every single form, I would like to get this variable through JS alone if possible? Thanks in advance.

 

Kind Regards,

Ryan

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.