You need to sign in to do that
Don't have an account?
Is it possible to get saleforce client OS or browser type in Apex ?
My requirement is when a record is edited in web client field Data_Source__c should be set to 'WEB'.
If it is edited in mobile application then Data_Source__c should be set to 'MOBILE'.
We are able to set value 'MOBILE' since it is custom edit screen in mobile application. We do not know how to set it to 'WEB' since we use standard layout in web client and there is no provision to override Save button.
What I am thinking is if somehow I get OS or browser type in Apex, I can use it in trigger and set Data_Source__c field.
Please let me know if anyone can offer help for this request.
Nathan.
Hello ,
When you login through your mobile there is a parameter USER-AGENT which passed in the URL, using this you can redirect users to specific pages.
Code Snippet:
String userAgent = ApexPages.currentPage().getHeaders().get(‘USER-AGENT’);
if(userAgent.contains(‘iPhone’)) deviceType = ‘iPhone’;{//Your iphone code goes here}
else if(userAgent.contains(‘BlackBerry’)) deviceType = ‘BlackBerry’;{//Your blackberry code goes here}
Check this link for a code snippet.
Also , JavaScript is always an option to get the Browser and the current OS with its version. You can find the browser details by using javascript in your visual force page. Here is the sample code :
Check this blog and the w3 school link for concepts.
Hope this fulfills your requirement.
Important :
Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for others benefits.
Thank You
ApexPages.currentPage() is not working inside trigger. It is null.
Nathan.