Posts

Showing posts from October, 2017

Batch class on External objects

Overview As you know, we use lightning connect to integrate external databases with Salesforce.  You can pull data from legacy systems such as SAP, Microsoft and Oracle in real time, without making a copy of the data in Salesforce. Salesforce Connect maps data tables in external systems to external objects in your org. Read more about Lightning Connect            Sometime there is a requirement to copy the data in the External object to some custom object in your Org. As there is no way you can write trigger or Apex managed sharing on the External Object, so that you can move the same data to the custom object. The only way is to write batch class on the external object, schedule it on daily basis to copy data to the custom objects. Previously, only Iterable<sObject> was supported. When you use Iterable<sObject> you cannot query more than 2000 records in iterable class and you get below error: Error : First Error : Inline...

Encoding URL in Tooling API call

Encoding URL in Tooling API: When using Tooling API to fetch the metadata for a particular component, we add query in the endpoint URL many times. Sometime the parameters we add has a space in between. If you insert a keyword with a space in the endpoint URL, calling the Tooling API through Rest will throw below error: Tooling API Call: String query = '/services/data/v40.0/tooling/query/?q=Select+id,Name,Metadata+from+Profile+where+name+=\''+profileName+'\'';         req.setEndpoint(baseURL + query); The profileName variable hold 'System Administrator' ERROR: 13:16:25:020 CALLOUT_RESPONSE [75]|System.HttpResponse[Status=Unknown Version, StatusCode=400] 13:16:25:021 USER_DEBUG [77]|DEBUG|response<h1>Bad Message 400</h1><pre>reason: Unknown Version</pre> To resolve this error make sure to encode the endpoint URL with method urlEncode() of EncodingUtil class. Something as below: String query = '/services/data/...