Posts

Showing posts from January, 2021

Fetch dependent picklist values depending on record type

Image
The problem The main problem with getting picklist based on recordtype, there is no "out of box" solution. You can easly fetch all values from picklist but without information about recordtypes.  The solution You need use "User Interface API", not very elegant solution, but it works. Give more time Salesforce for implement such obvious functionality (the idea arose only 8 years ago). /ui-api/object-info/{objectApiName}/picklist-values/{recordTypeId}/{fieldApiName} Step by step: public static String innerSalesforceCallout(String serviceEndpoint) {      if (String.isEmpty(serviceEndpoint)){           return null;      } Http http = new Http(); HttpRequest webReq = new HttpRequest(); webReq.setMethod('GET'); webReq.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId()); webReq.setEndpoint(serviceEndpoint);     try { HttpResponse res = http.send(webReq);     } c...

Security Vulnerabilities in Salesforce

Image
  In Salesforce we are using a lots of custom user interfaces. That’s why we should be aware about  various types of security vulnerabilities. The most common you can find here:          SOQL injection,          Cross-Site Scripting (XSS),          Cross-Site Request Forgery (CSRF). Let's discuss each of them briefly. SOQL injection From definition SQL injection can happen when we have insecure construction of database queries with user-supplied data e.g.:         queries are built directly with user data inlined,         queries are   concatenated directly with the query text (not type-safe bind parameters). When designing SOQL queries there are basically three places where behavior of the query can be based on input from User:     Behaviors of the WHERE clause to change the set of returned records.   Selecting fields from ...