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
SujanSaiSujanSai 

Integrating Salesforce and Heroku with Salesforce Connect

Hi EveryOne,

Unable to execute the Apex adapter in Heroku Trailhead(https://trailhead.salesforce.com/en/salesforce_heroku_integration/integrating_with_salesforce_connect)

 
SandhyaSandhya (Salesforce Developers) 
Hi,

You need to add method definition and return type as given in the module.

Please refer below code which is executing.
 
override global DataSource.TableResult query(DataSource.QueryContext queryContext) {
  List<Map<String, Object>> properties = DataSource.QueryUtils.process(queryContext, getProperties());
  DataSource.TableResult tableResult = DataSource.TableResult.get(queryContext, properties);
  return tableResult;
}

public List<Map<String, Object>> getProperties() {
  Http httpProtocol = new Http();
  HttpRequest request = new HttpRequest();
  String url = 'https://ionic2-realty-rest-demo.herokuapp.com/properties/';
  request.setEndPoint(url);
  request.setMethod('GET');
  HttpResponse response = httpProtocol.send(request);

  List<Map<String, Object>> properties = new List<Map<String, Object>>();

  for (Object item : (List<Object>)JSON.deserializeUntyped(response.getBody())) {
    Map<String, Object> property = (Map<String, Object>)item;
    property.put('ExternalId', property.get('id'));
    property.put('DisplayUrl', 'https://ionic2-realty-rest-demo.herokuapp.com/');
    property.put('Name', property.get('title'));
    properties.add(property);
  }

  return properties;
}

Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks and Regards
Sandhya