tylerzika
1/31/2017 - 9:06 PM

gistfile1.txt

<apex:remoteObjects>
    <apex:remoteObjectModel name="tpslead__Lead_Territory__c" jsShorthand="Territory" fields="Id, Name">
         <apex:remoteObjectField name="tpslead__Assigned_To__c" jsShorthand="AssignedToName"/>
        <apex:remoteObjectField name="tpslead__Assigned_To_ID__c" jsShorthand="AssignedToId"/>
        <apex:remoteObjectField name="tpslead__Assigned_To_Type__c" jsShorthand="AssignedToType"/>
        <apex:remoteObjectField name="tpslead__Type__c" jsShorthand="Type"/>
    </apex:remoteObjectModel>
 </apex:remoteObjects>    
<head>
export default function() {
  return new Promise((resolve, reject) => {
    var territory = new SObjectModel.Territory();
    // Use the Remote Object to query
    territory.retrieve({limit: 10 }, function(err, records, event) {
    if (err) {
      //Promise Reject
      return reject({data: {message: err.message}, status:400});
    }
     return resolve({records});  //Promise Resolve
    });
  });
}