Human Capital Management Apex API Developer Reference

vanahcm.CandidateService

global with sharing class CandidateService

Represents a Candidate service structure

Methods

getByName

global static List<vanahcm.CommonService.Candidate> getByName(Set<String> names, Map<Schema.SObjectType, Set<Schema.SObjectField>> customFields)

Get candidate with related education and work experience records based on candidate name

Input Parameters

Name Type Description
names Set<String> Name of candidate records that need to be returned
customFields Map<Schema.SObjectType, Set<Schema.SObjectField>> Collection of custom fields that need to be queried for Candidate, Candidate Education, and Candidate Work Experience

Return Value

List of Candidate

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

Set<String> names = new Set<String>();

//Add Name of vanahcm__Candidate__c to names
names.add('foo bar');

Map<Schema.SObjectType, Set<Schema.SObjectField>> customFields = new Map<Schema.SObjectType, Set<Schema.SObjectField>>{
    vanahcm__Candidate__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate__c.vanahcm__Resume__c},
    vanahcm__Candidate_Education__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate_Education__c.CreatedById},
    vanahcm__Candidate_Work_Experience__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate_Work_Experience__c.vanahcm__Responsibilities__c}};

List<vanahcm.CommonService.Candidate> candidates = vanahcm.CandidateService.getByName(names, customFields);

getByEmail

global static List<vanahcm.CommonService.Candidate> getByEmail(Set<String> emails, Map<Schema.SObjectType, Set<Schema.SObjectField>> customFields)

Get Candidate with related Education and Work Experience records based on candidate email

Input Parameters

Name Type Description
emails Set<String> Email of candidate records that need to be returned
customFields Map<Schema.SObjectType, Set<Schema.SObjectField>> Collection of custom fields that need to be queried for Candidate, Candidate Education, and Candidate Work Experience

Return Value

List of Candidate

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

Set<String> emails = new Set<String>();

//Add Email of vanahcm__Candidate__c to emails
emails.add('foo@bar.com');

Map<Schema.SObjectType, Set<Schema.SObjectField>> customFields = new Map<Schema.SObjectType, Set<Schema.SObjectField>>{
    vanahcm__Candidate__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate__c.vanahcm__Resume__c},
    vanahcm__Candidate_Education__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate_Education__c.CreatedById},
    vanahcm__Candidate_Work_Experience__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate_Work_Experience__c.vanahcm__Responsibilities__c}};

List<vanahcm.CommonService.Candidate> candidates = vanahcm.CandidateService.getByEmail(emails, customFields);

getById

global static List<vanahcm.CommonService.Candidate> getById(Set<ID> ids, Map<Schema.SObjectType, Set<Schema.SObjectField>> customFields)

Get candidate with related education and work experience records based on candidate ID

Input Parameters

Name Type Description
ids Set<ID> ID of candidate records that need to be returned
customFields Map<Schema.SObjectType, Set<Schema.SObjectField>> Collection of custom fields that need to be queried for Candidate, Candidate Education, and Candidate Work Experience

Return Value

List of Candidate

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

Set<ID> candidateIds = new Set<ID>();
candidateIds.add('a0nj000000KcOqN');

Map<Schema.SObjectType, Set<Schema.SObjectField>> customFields = new Map<Schema.SObjectType, Set<Schema.SObjectField>>{
    vanahcm__Candidate__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate__c.vanahcm__Resume__c},
    vanahcm__Candidate_Education__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate_Education__c.CreatedById},
    vanahcm__Candidate_Work_Experience__c.SObjectType => new Set<Schema.SObjectField>{vanahcm__Candidate_Work_Experience__c.vanahcm__Responsibilities__c}};

List<vanahcm.CommonService.Candidate> candidates = vanahcm.CandidateService.getById(candidateIds, customFields);

create

global static List<vanahcm.CandidateService.Result> create(List<vanahcm.CommonService.Candidate> candidates)

Insert Candidates with related Education and Work Experience

Input Parameters

Name Type Description
candidates List<vanahcm.CommonService.Candidate> Candidate records that need to be inserted

Return Value

List of Result

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

vanahcm.CommonService.Candidate candidate = new vanahcm.CommonService.Candidate();
candidate.FirstName = 'foo';
candidate.LastName = 'bar';

List<vanahcm.CommonService.Candidate> candidates = new List<vanahcm.CommonService.Candidate>();
candidates.add(candidate);

List<vanahcm.CandidateService.Result> results = vanahcm.CandidateService.create(candidates);

//Add an Attachment to candidate record
Attachment resume = new Attachment();
resume.ParentId = results[0].RecordId;
resume.Body = Blob.valueOf('attachment body');
resume.Name = 'foobar.txt';
insert resume;

//Add a Note to candidate record
Note callLog = new Note();
callLog.ParentId = results[0].RecordId;
callLog.Title = 'Final HR Discussion';
callLog.Body = 'candidate approved for hiring';
insert callLog;

modify

global static List<vanahcm.CandidateService.Result> modify(List<vanahcm.CommonService.Candidate> candidates)

Insert or update candidates with related Education and Work Experience

Input Parameters

Name Type Description
candidates List<vanahcm.CommonService.Candidate> Candidate records that need to be inserted or updated

Return Value

List of Result

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

vanahcm.CommonService.Candidate candidate = new vanahcm.CommonService.Candidate();
candidate.Id = 'a20xs00230234sde';
candidate.FirstName = 'foo';
candidate.LastName = 'bar';

List<vanahcm.CommonService.Candidate> candidates = new List<vanahcm.CommonService.Candidate>();
candidates.add(candidate);

List<vanahcm.CandidateService.Result> results = vanahcm.CandidateService.modify(candidates);

createFromResume

global static vanahcm.CandidateService.Result createFromResume(String fileName, String fileBody, String ownerId)

Insert candidates with related Education and Work Experience from Resume

Input Parameters

Name Type Description
fileName String Name of the resume file from which Candidate records need to be inserted
fileBody String Content of the resume file in base-64 encoded format from which candidate, candidate education, and candidate work experience records need to be inserted
ownerId String User ID

Return Value

Result

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

String fileBody = EncodingUtil.base64Encode(Blob.valueOf('Name: FirstName LastName         Email: foo@bar.com'));;
String fileName = 'test.txt';
String ownerId = UserInfo.getUserId();

vanahcm.CandidateService.Result results = vanahcm.CandidateService.createFromResume(fileName, fileBody, ownerId);

vanahcm.CandidateService.Result

global with sharing class Result

Represents a Result

Properties

Name Type Description
RecordId ID Candidate ID
EducationIds List<ID> List of ID for Candidate's Education
WorkExperienceIds List<ID> List of ID for Candidate's Work Experience
© Copyright 2009–2017 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.