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

Detect if user logged in via API or web browser

I have an excel app I wrote with the excel connector, that allows users to login and do some inserts/deletes for some custom objects.  I would like to write some validation rules that detect when the user is logged in via this APP which will allow them to edit certain fields.  If they are logged in via the browser, they shouldn't be able to edit those same fields.


Is there a field/flag that allows me to detect that the login came from the API as opposed to the Web Browser?


Thanks in advance


I don't think there's anything that a validation rule can use to detect how/why a record is being updated. A trigger might give you more flexibility.


But if you want to stay with validation rules, try this. Add a datetime field to your object. Don't put the field on the page layout, so when a browser user submits the page, the field will always be unchanged. In your Excel app, always set the field to the current date/time. Your validation rule can determine whether it's the browser or the app that's updating the record by checking whether the datetime value is being changed.