<p>i don't think it is possible via GUI but you can do this via feed me <a href="https://docs.craftcms.com/feed-me/v4/developers/events.html#the-stepbeforeelementsave-event" rel="nofollow noreferrer">events</a> and a simple plugin.</p>

<p>because entrytype's fieldlayout and field mappings are different, in my solution, you should edit feed and update fieldmapping for each entry type, change the if condition of the code and run the feed again.</p>

<pre><code>    Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function (FeedProcessEvent $event) {
        $entryTypeId=$event-&gt;feedData['entrytype'];
        if ($entryTypeId==1){
            $event-&gt;element-&gt;typeId=1;
        }
        //maybe, if field mapping for entrytype1 and entrytype2 are same
        elseif ($entryTypeId==2){
            $event-&gt;element-&gt;typeId=2;
        } 
        else {
            //skip saving element for other entry types because they have different field mapping.
            $event-&gt;isValid=false;
        }
    });
</code></pre>

<ul>
<li><a href="https://craftcms.stackexchange.com/questions/28842/craft-3-preventing-element-from-saving-in-plugin">about event->isValid</a></li>
</ul>

CC BY-SA 4.0
2021-09-03T09:17:22.947Z
Beware using this trick when trying to update entries. When FeedMe tries to find an existing element, it includes the entryType in the query, so it will create duplicate entries instead of updating the existing ones.
nstCactus
CC BY-SA 4.0
2020-06-04T07:06:54.187Z
2020-06-04T07:13:27.247Z
2020-06-04T07:13:27.247Z
user9975
<p>Can someone confirm that when importing entries with Feed-Me, the entrytype can NOT be set dynamically based on a field of the feed?</p>

<craft3><plugin-feedme><import>
Feed me: set entrytype dynamically
# Feed me: set entrytype dynamically

(Asked by: username_0 on 2020-06-03)

Can someone confirm that when importing entries with Feed-Me, the entrytype can NOT be set dynamically based on a field of the feed?

**Tags:** craft3, plugin-feedme, import

---

## 1 answers

### Answer by username_1 on 2020-06-04. Score: 1 | Accepted answer

i don't think it is possible via GUI but you can do this via feed me events and a simple plugin.
because entrytype's fieldlayout and field mappings are different, in my solution, you should edit feed and update fieldmapping for each entry type, change the if condition of the code and run the feed again.
    Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function (FeedProcessEvent $event) {
        $entryTypeId=$event->feedData['entrytype'];
        if ($entryTypeId==1){
            $event->element->typeId=1;
        }
        //maybe, if field mapping for entrytype1 and entrytype2 are same
        elseif ($entryTypeId==2){
            $event->element->typeId=2;
        } 
        else {
            //skip saving element for other entry types because they have different field mapping.
            $event->isValid=false;
        }
    });


about event->isValid

> **Comments:**
> **username_2**: Beware using this trick when trying to update entries. When FeedMe tries to find an existing element, it includes the entryType in the query, so it will create duplicate entries instead of updating the existing ones.  

---

