I'm implementing a custom UI for Salesforce using Visualforce and Remote Actions. When I'm displaying a specific record, I look for all visible fields and display it on the screen.
The code in the Apex Remote Action is something like this:
String queryString = 'SELECT ' + String.join(fieldNames, ',') + ' FROM ' + dr.getName() +' WHERE Id = :recordId FOR VIEW';
The problem is that not all objects accept FOR VIEW in the SOQL query. Sometimes, the following error is displayed:
Visualforce Remoting Exception: FOR VIEW/REFERENCE can only be used on an object where viewing is tracked
Doing a little bit of research, I've found out that if the object does not have any Tab, you can't use FOR VIEW. How do I know if the object has a Tab or accepts FOR VIEW? Is calling Schema.describeTabs() the only solution?