async function fieldschoosingvalues(selectedEventValue, fieldNameContainer, choicesContainer, buttonContainer, container, selectedFieldName = null, selectedChoices = null) {
  if (!selectedEventValue) {
    console.error("fieldschoosingvalues called with an undefined selectedEventValue.");
    return;
  }

  try {
    let statusResp = await makeApiCall(apiKeyInput1.value, domainInput1.value);

    if (statusResp && statusResp.ticket_fields) {
      let fields = statusResp.ticket_fields.filter(field =>
        field.field_type.startsWith('default_') &&
        field.choices &&
        field.choices.length > 0 &&
        field.required_for_agents
      );

      if (selectedFieldName) {
        // Initialize containers for field and choices
        const individualFieldContainer = document.createElement('div');
        individualFieldContainer.classList.add('field-container');
        fieldNameContainer.appendChild(individualFieldContainer);

        const individualChoicesContainer = document.createElement('div');
        individualChoicesContainer.classList.add('choices-container');
        choicesContainer.appendChild(individualChoicesContainer);

        // Find or create event object
        let eventObj = ticketworkflowconditions.find(event => event.eventName === selectedEventValue);
        if (!eventObj) {
          eventObj = { eventName: selectedEventValue, isEnabled: true, combinations: [] };
          ticketworkflowconditions.push(eventObj);
        }

        // Create new combination for this selection
        let combination = { fields: [] };
        eventObj.combinations.push(combination);

        for (const choice of selectedChoices) {
          combination.fields.push({ name: selectedFieldName, value: choice });

          // Initialize choices for the field
          await getFieldnamesfrom1stapi(
            individualFieldContainer,
            fields,
            individualChoicesContainer,
            selectedEventValue,
            buttonContainer,
            container,
            selectedFieldName,
            [choice]
          );
        }
      } else {
        // Handle field selection without initial data
        await getFieldnamesfrom1stapi(fieldNameContainer, fields, choicesContainer, selectedEventValue, buttonContainer, container);
      }
    } else {
      console.error('No fields found or data not available');
    }
  } catch (error) {
    console.error("Error fetching data for Dropdown:", error);
  }
}

// Create new combination when the choice changes
choicesDropdown.addEventListener('fwChange', (event) => {
  const selectedChoiceId = parseInt(event.target.value);

  if (!selectedEventValue || !selectedFieldName) {
    console.error('Event or field name is undefined');
    return;
  }

  let eventObj = ticketworkflowconditions.find(event => event.eventName === selectedEventValue);
  if (!eventObj) {
    eventObj = { eventName: selectedEventValue, isEnabled: true, combinations: [] };
    ticketworkflowconditions.push(eventObj);
  }

  // Create or find an existing combination
  let combination = eventObj.combinations.find(combo => combo.fields.some(field => field.name === selectedFieldName));
  if (!combination) {
    combination = { fields: [] };
    eventObj.combinations.push(combination);
  }

  // Update the combination with the new choice
  let fieldEntry = combination.fields.find(field => field.name === selectedFieldName);
  if (!fieldEntry) {
    fieldEntry = { name: selectedFieldName, value: selectedChoiceId };
    combination.fields.push(fieldEntry);
  } else {
    fieldEntry.value = selectedChoiceId;
  }

  console.log('Updated ticketworkflowconditions:', JSON.stringify(ticketworkflowconditions, null, 2));
});


fix this issue :

if i choose a set of fields and choices in same event keep as a combo, if i create another event with same event name and choosed another set of fields and choices, keep that as one combo 

fix this issu