I am a new developer, and I have a task that I need to complete, and I absolutely do not know how to handle it. This is an angular calendar app. And my task in this large project is simply to make it function so that when a user enters a field in a search query, he searches against certain accounts "Agent" and "MasterAgent" instead of searching all accounts. So this is an Apex application, angular. I created the RecordHelper class, and here is the snippet below:
public static Set<Id> getAgencyRecordTypeIds(){
Set<Id> recordTypeIds = new Set<Id>();
recordTypeIds.add(GetRecordTypeIdByDeveloperName('Account','Agency'));
recordTypeIds.add(GetRecordTypeIdByDeveloperName('Account','MasterAgency'));
return recordTypeIds;
}
Then I created another class so that I could use remoteAction to pass it to Angular, the snippet shown below:
@RemoteAction
public static Set<Id> passRecordsIds() {
Set<Id> fetchRecordTypeIds = RecordTypeHelper.getAgencyRecordTypeIds();
return fetchRecordTypeIds;
}
Then I used the .vfr method to pass the results of remote actions to Angular. Here is the angular code for it:
var passRecordsIds = vfr.send('S1_PAV_CalendarController.passRecordsIds', $scope.data.SFSendOpts, false);
passRecordsIds().then(function(result){
$scope.typeRecord = result;
$log.debug($scope.typeRecord);
}
,function(error){
$log.error('passRecordsIds error');
$log.error(error);
$window.alert(error.message);
});
, , angular Query, MasterAccount. , AND . , , , .
var queryString = $scope.ACCOUNT_SELECT_PART + " FROM Account WHERE" + " (Name Like '%" + searchTerm + "%' OR Safeco_Sub_Stat__c Like '%" + searchTerm + "%') AND RecordTypeId IN ('Agency', 'MasterAgency')";
var queryString = $scope.ACCOUNT_SELECT_PART + " FROM Account WHERE" + " (Name Like '%" + searchTerm + "%' OR Safeco_Sub_Stat__c Like '%" + searchTerm + "%') AND typeRecord IN :passRecordsIds";
, , , RecordTypeId.
, , , . .