clear contact details when switching from existing to new contact
- Ensure previously selected contact details are removed when toggling - Clear all fields in the 'contact_details_section' when choosing an existing contact - Set 'contact' field to null when switching to a new contact - Prevents unnecessary data from being sent to the API
This commit is contained in:
parent
7101fadd36
commit
cf43935508
@ -190,6 +190,24 @@ function createDeal() {
|
|||||||
if (deal.website && !deal.website.startsWith('http')) {
|
if (deal.website && !deal.website.startsWith('http')) {
|
||||||
deal.website = 'https://' + deal.website
|
deal.website = 'https://' + deal.website
|
||||||
}
|
}
|
||||||
|
if (chooseExistingContact.value) {
|
||||||
|
const contactDetailsFields = new Set(
|
||||||
|
tabs.data.flatMap((tab) =>
|
||||||
|
tab.sections
|
||||||
|
.filter((section) => section.name === 'contact_details_section')
|
||||||
|
.flatMap((section) =>
|
||||||
|
section.columns.flatMap((column) =>
|
||||||
|
column.fields.map((field) => field.fieldname),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
contactDetailsFields.forEach((field) => {
|
||||||
|
deal[field] = null
|
||||||
|
})
|
||||||
|
} else deal['contact'] = null
|
||||||
|
|
||||||
createResource({
|
createResource({
|
||||||
url: 'crm.fcrm.doctype.crm_deal.crm_deal.create_deal',
|
url: 'crm.fcrm.doctype.crm_deal.crm_deal.create_deal',
|
||||||
params: { args: deal },
|
params: { args: deal },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user