'How can I import relational data when parsing a file in Strapi?
I’m writing a script to import bulk data entries for organizations. In Strapi, however, I have a number of relational fields for the organizations with things like “area_of_focus”, “languages”, etc. My question is, how can I import the data properly for the relational when it’s in a dropdown in the strapi admin panel? I’ve included the section of the code that maps and a screenshot of the relational data for reference.
All the data without a relation imports fine, it’s just any relational field that doesn’t work. I just have a feeling it’s how I’m calling them, but I’m unsure.
Relational Fields:
Mapping Code:
await Promise.all(data.map(entry =>
strapi.query('organization').create({
name: entry.name,
EIN: entry.EIN,
locations: [
{
streetAddress: entry.streetAddress,
city: entry.city,
state: entry.state,
zipCode: entry.zipCode,
county: entry.county,
locationType: entry.locationType,
}
],
contact: [
{
firstName: entry.firstName,
lastName: entry.lastName,
email: entry.email,
phone: entry.phone,
phoneExtension: entry.phoneExtension,
}
],
description: entry.description,
webSite: entry.webSite,
email: entry.orgEmail,
phone: entry.orgPhone,
priority_area_topics: entry.priority_area_topics,
organizationType: entry.organizationType,
areaOfFocus: entry.organization_area_of_focus,
localServiceArea: entry.local_service_areas,
localServiceAreaDescription: entry.localServiceAreaDescription,
helpDesk: entry.helpDesk,
officeHours: entry.officeHours,
maximumResponseTime: entry.maximumResponseTime,
languages: entry.languages,
})
));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

