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
bhanu_prakashbhanu_prakash 

how to find class run in which box

Hi,

i want to find out a class run on which box either sandbox/production how i identify easily ?

regards,
Bhanu

 
Best Answer chosen by bhanu_prakash
salesforceMannsalesforceMann
Hello Bhanu,

We can use the fact that sandbox users have a suffix to their usernames. Lets say you chose "sb01".
Based on this, you can use:
if(Userinfo.getUserName().contains('sb01')) 
{ ..do something.. }
Or even better:
if (Userinfo.getUserName().substringBeforeLast('.') == 'sb01')
{ ..do something..}

Hope this helps.
Thanks.

Please mark as answer if it answers your question.