Prefilling Campaign Order Form
How can we map values and prefill the Campaign Order Form?
Each ATS has different campaign object structure thus a mapping needs to be implemented to the VONQ campaign structure.
Let's consider that you have a campaign structure as such:
const job = {
company_id: "your-users-company-id",
job_title: "Some Job Title",
job_description: "Some Job Description",
job_category: "Customer Service",
job_education_level: "Bachelor's Degree",
job_industry: "Communications",
job_seniority: "Manager",
job_hours: "Full-Time",
job_locations: [
{
address_1: "Address 1",
address_2: "Address 2",
city: "Some City",
country: "Some Country",
postal_code: "123"
}
],
job_urls: [
{
job_details_url: "https://some-url.com",
apply_url: "https://some-url.com"
}
],
recruiter_company: "Recruiter's Company Name",
recruiter_company_logo_url: "https://some-url.com/some-logo.png",
recruiters: [
{
email: "recruiteremail@gmail.com",
first_name: "Recruiter's First Name",
last_name: "Recruiter's Last Name",
user_id: "user-id-123",
user_name: 'username-123'
}
],
}
The above object needs to be mapped to the structure of CampaignCreateForm type.
An example is given below on how that can be accomplished:
const mapPostingDetailsEmploymentType = (job) => {
switch (job.job_hours) {
case 'Full-Time':
// for other possible values, check "Getting mapping values" section of this recipe
return 'permanent';
default:
return '';
}
};
// please note that version 2.6 added support for `weeklyWorkingMinutes`
const mapPostingDetailsWeeklyWorkingHoursFrom = (job) => {
switch (job.job_hours) {
case 'Full-Time':
return 40;
default:
return 0;
}
};
// please note that version 2.6 added support for `weeklyWorkingMinutes`
const mapPostingDetailsWeeklyWorkingHoursTo = (job) => {
switch (job.job_hours) {
case 'Full-Time':
return 40;
default:
return 0;
}
};
const mapTargetGroupEducationLevel = (job) => {
switch (job.job_education_level) {
case "Bachelor's Degree":
// for other possible values, check "Getting mapping values" section of this recipe
return [
{
"id": 2,
"name": [
{
"languageCode": "de_DE",
"value": "Bachelor / Absolvent"
},
{
"languageCode": "en_GB",
"value": "Bachelor / Graduate"
},
{
"languageCode": "nl_NL",
"value": "HBO / Bachelor"
}
]
}
];
default:
return [];
}
};
const mapTargetGroupSeniority = (job) => {
switch (job.job_seniority) {
case "Manager":
// for other possible values, check "Getting mapping values" section of this recipe
return [
{
"id": 2,
"name": [
{
"languageCode": "de_DE",
"value": "Manager"
},
{
"languageCode": "en_GB",
"value": "Manager"
},
{
"languageCode": "nl_NL",
"value": "Manager"
}
]
}
];
default:
return [];
}
};
const mapTargetGroupIndustry = (job) => {
switch (job.job_industry) {
case "Communications":
// for other possible values, check "Getting mapping values" section of this recipe
return [
{
"id": 2,
"name": "Communications"
}
];
default:
return [];
}
};
const mapTargetGroupJobCategory = (job) => {
switch (job.job_category) {
case 'Customer Service':
// for other possible values, check "Getting mapping values" section of this recipe
return [
{
value: 11,
label: 'Customer Service'
}
];
default:
return [];
}
};
const mapTargetGroup = (job) => {
return {
educationLevel: mapTargetGroupEducationLevel(job),
seniority: mapTargetGroupSeniority(job),
industry: mapTargetGroupIndustry(job),
jobCategory: mapTargetGroupJobCategory(job)
}
}
const mapRecruiterInfo = (job) => {
return {
name: `${job.recruiters[0].first_name} ${job.recruiters[0].last_name}`,
emailAddress: job.recruiters[0].email
}
}
const mapPostingDetailsWeeklyWorkingHours = (job) => {
return {
from: mapPostingDetailsWeeklyWorkingHoursFrom(job),
to: mapPostingDetailsWeeklyWorkingHoursTo(job)
}
}
const mapPostingDetailsSalaryIndication = (job) => {
return {
period: 'yearly', // for other possible values, check "Getting mapping values" section of this recipe
range: {
from: 0,
to: 0,
currency: 'USD' // ISO-4217 currency
}
}
}
const mapPostingDetailsOrganization = (job) => {
return {
name: job.recruiter_company,
companyLogo: job.recruiter_company_logo_url
}
}
const mapPostingDetailsWorkingLocation = (job) => {
return {
addressLine1: job.job_locations[0].address_1,
addressLine2: job.job_locations[0].address_2,
city: job.job_locations[0].city,
country: job.job_locations[0].country,
postcode: job.job_locations[0].postal_code
}
}
const mapPostingDetails = (job) => {
return {
title: job.job_title,
description: job.job_description,
yearsOfExperience: 0,
employmentType: mapPostingDetailsEmploymentType(job),
// please note that version 2.6 added support for `weeklyWorkingMinutes`
weeklyWorkingHours: mapPostingDetailsWeeklyWorkingHours(job),
salaryIndication: mapPostingDetailsSalaryIndication(job),
organization: mapPostingDetailsOrganization(job),
workingLocation: mapPostingDetailsWorkingLocation(job),
jobPageUrl: job.job_urls[0].job_details_url,
applicationUrl: job.job_urls[0].apply_url
}
}
const getMappedJobToHapiElementsCampaignForm = (job) => {
return {
companyId: job.company_id,
targetGroup: mapTargetGroup(job),
recruiterInfo: mapRecruiterInfo(job),
postingDetails: mapPostingDetails(job),
orderedProductsSpecs: {},
orderedProducts: []
};
};
Use the "mapping" utility functions for the given job, validate and set to the HAPI Elements Campaign Form:
const job = {
company_id: "your-users-company-id",
job_title: "Some Job Title",
job_description: "Some Job Description",
job_category: "Customer Service",
job_education_level: "Bachelor's Degree",
job_industry: "Communications",
job_seniority: "Manager",
job_hours: "Full-Time",
job_locations: [
{
address_1: "Address 1",
address_2: "Address 2",
city: "Some City",
country: "Some Country",
postal_code: "123"
}
],
job_urls: [
{
job_details_url: "https://some-url.com",
apply_url: "https://some-url.com"
}
],
recruiter_company: "Recruiter's Company Name",
recruiter_company_logo_url: "https://some-url.com/some-logo.png",
recruiters: [
{
email: "recruiteremail@gmail.com",
first_name: "Recruiter's First Name",
last_name: "Recruiter's Last Name",
user_id: "user-id-123",
user_name: 'username-123'
}
],
}
const mappedJob = getMappedJobToHapiElementsCampaignForm(job)
// validate
window.hapi.campaign.validation.campaignForm.parse(mappedJob)
// if no errors are thrown then the mapped object is valid, then set it:
window.hapi.campaign.state.campaignForm = window.hapiUtils.mergeDeepOverwriteArrays(
window.hapi.campaign.state.campaignForm.value,
mappedJob
)
Version 2.6 added support for weeklyWorkingMinutes
. If you intend to use weeklyWorkingMinutes
which provides ability to specify not only the hours but minutes as well, like 2 hours 30 minutes
, then please refer to the changelog.
Please note that there is no easy way yet to map objects with IDs such as educationLevel
, seniority
, ìndustry
, jobCategory
.
When mapping to VONQ objects that include an ID, like this example:
const mapTargetGroupJobCategory = (job) => {
switch (job.job_category) {
case 'Customer Service':
return [{ value: 11, label: 'Customer Service' }];
default:
return [];
}
};
The ID with value: 11
will differ from environment to environment meaning that 11
might be a different ID based on the environment of HAPI Elements you are using. Our sandbox environment has the same IDs as production thus you won't need to change your IDs.
Getting mapping values
In order to find values of period
, you can do:
console.log('Salary Indication Period:', window.hapi.campaign.validation.salaryPeriod)
The output will be an array of strings of type SalaryPeriod enum
In order to find values of employmentType
, you can do:
console.log('Employment Types:', window.hapi.campaign.validation.supportedEmploymentType)
The output will be an array of strings of type EmploymentType enum
In order to find the IDs of educationLevel
, you can use the API function to get list of Education Levels:
const educationLevelsResponse = await window.hapi.campaign.api.getEducationLevels()
console.log('Education Levels:', educationLevelsResponse)
The output will be an array of objects of type TaxonomyEducationAndSeniorityLevel type
In order to find the IDs of seniority
, you can use the API function to get list of Seniorities:
const senioritiesResponse = await window.hapi.campaign.api.getSeniorities()
console.log('Seniorities:', senioritiesResponse)
The output will be an array of objects of type TaxonomyEducationAndSeniorityLevel type
In order to find the IDs of industry
, you can use the API function to get list of Industries:
const industriesResponse = await window.hapi.product.api.getIndustries()
console.log('Industries:', industriesResponse)
The output will be an array of objects of type ProductIndustry type
In order to find the IDs of jobCategory
, you can use the API function to get list of Job Categories:
const searchText = "test"
const jobCategoriesResponse = await window.hapi.product.api.getJobFunctions(searchText)
console.log('Job Categories:', jobCategoriesResponse)
The output will be an array of objects of type ProductJobFunction type
Keep in mind that the above functions return results based on the languages HAPI Elements & HAPI Backend supports. To read more about internalization, please refer to Internalization.