function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Keith987Keith987 

Any way to obtain the currently selected app id (AKA tab set or tsid) in server-side Apex code?

I have a side bar component written in Visualforce that is only relevant to one of my apps and would like its output to only be present when that app is selected. I can also imagine other use cases where knowing the currently selected app would be useful.

 

Anyone know if this information can be obtained in Apex code?

 

Thanks,

Keith

JitendraJitendra

Hi,

 

If you will check the HTML generated by salesforce, below code will be observed.

 

<div class="menuButtonButton" id="tsidButton">
	<span class="menuButtonLabel" id="tsidLabel" tabindex="0" style="">Sales</span>
	<div class="tsid-buttonArrow mbrButtonArrow" id="tsid-arrow"></div>
	<div class="tsidButton-tr mbrButton-tr mbrButton-rc"></div>
	<div class="tsidButton-tl mbrButton-tl mbrButton-rc"></div>
	<div class="tsidButton-btm mbrButton-btm mbrButton-rc"></div>
</div>

 As you can see in above code, the currently selected app name is "Sales" and component id is "tsidLabel".

 

So, i hope you have already got what i mean to say. Use GetElementByID call of the javascript and check whether the innerHTLM value of the componenet is your application name, and if yes, run your script.

Keith987Keith987

Thanks but I am looking to get the tsid server-side not client-side so I can use it in Visualforce/Apex logic generally e.g. an arbitrary Visualforce page that is served from a different domain and so cannot access the tsid div. I take your point that for sidebar components your approach looks possible.