03-27-2019 05:19 AM
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)
Solved! Go to Solution.
03-27-2019 06:10 AM
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
03-27-2019 06:24 AM
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.
03-27-2019 11:15 AM
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.
03-28-2019 02:17 AM - edited 03-28-2019 02:24 AM
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!
03-28-2019 03:13 AM
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:
like we are used to do with the primary keys:
03-29-2019 08:16 AM
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