Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-03T09:17:22.947Z
Answers.Text: 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.
Answers.UserDisplayName: nstCactus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-04T07:06:54.187Z
Answers.LastActivityDate: 2020-06-04T07:13:27.247Z
Answers.LastEditDate: 2020-06-04T07:13:27.247Z
Answers.UserDisplayName: user9975
Body: <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>
  
Tags: <craft3><plugin-feedme><import>
Title: Feed me: set entrytype dynamically
ThreadText: # 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](https://docs.craftcms.com/feed-me/v4/developers/events.html#the-stepbeforeelementsave-event) 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](https://craftcms.stackexchange.com/questions/28842/craft-3-preventing-element-from-saving-in-plugin)
  
  > **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.  
  
  ---
  
  