Quotes
The Quotes module provides access to contextual information about the current quote when a widget is rendered within supported quote-related pages. Widgets can retrieve quote identifiers, associated customer references, and conversion-related metadata for use in validations, conditional logic, and UI extensions.
- Methods
- Events
Methods
Get Estimate Details
Retrieves data related to the current context. This method allows your widget to fetch record details, field values, or metadata required for rendering or processing logic.
- Fetch record information
- Read field values
- Access contextual module data
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
ZFAPPS.get('estimate').then(function (data) {
//response Handling
}).catch(function (err) {
//error Handling
});
});
}
| Property | Request |
|---|---|
| estimate_id | estimate.estimate_id |
| estimate_number | estimate.estimate_number |
| crm_owner_id | estimate.crm_owner_id |
| crm_custom_reference_id | estimate.crm_custom_reference_id |
| zcrm_potential_id | estimate.zcrm_potential_id |
| zcrm_potential_name | estimate.zcrm_potential_name |
| date | estimate.date |
| date_formatted | estimate.date_formatted |
| created_date | estimate.created_date |
| created_date_formatted | estimate.created_date_formatted |
Show More Supported Input Keys
| Property | Request |
|---|---|
| reference_number | estimate.reference_number |
| status | estimate.status |
| status_formatted | estimate.status_formatted |
| customer_id | estimate.customer_id |
| branch_id | estimate.branch_id |
| documents | estimate.documents |
| customer_name | estimate.customer_name |
| place_of_supply | estimate.place_of_supply |
| place_of_supply_formatted | estimate.place_of_supply_formatted |
| contact_category | estimate.contact_category |
| tax_treatment | estimate.tax_treatment |
| tax_treatment_formatted | estimate.tax_treatment_formatted |
| contact_persons | estimate.contact_persons |
| currency_id | estimate.currency_id |
| currency_code | estimate.currency_code |
| currency_symbol | estimate.currency_symbol |
| exchange_rate | estimate.exchange_rate |
| expiry_date | estimate.expiry_date |
| expiry_date_formatted | estimate.expiry_date_formatted |
| discount | estimate.discount |
| discount_applied_on_amount | estimate.discount_applied_on_amount |
| is_discount_before_tax | estimate.is_discount_before_tax |
| discount_type | estimate.discount_type |
| is_viewed_by_client | estimate.is_viewed_by_client |
| client_viewed_time | estimate.client_viewed_time |
| client_viewed_time_formatted | estimate.client_viewed_time_formatted |
| is_inclusive_tax | estimate.is_inclusive_tax |
| tax_rounding | estimate.tax_rounding |
| estimate_url | estimate.estimate_url |
| line_items | estimate.line_items |
| submitter_id | estimate.submitter_id |
| submitted_date | estimate.submitted_date |
| submitted_date_formatted | estimate.submitted_date_formatted |
| submitted_by | estimate.submitted_by |
| approver_id | estimate.approver_id |
| shipping_charge | estimate.shipping_charge |
| shipping_charge_formatted | estimate.shipping_charge_formatted |
| bcy_shipping_charge | estimate.bcy_shipping_charge |
| adjustment | estimate.adjustment |
| adjustment_formatted | estimate.adjustment_formatted |
| bcy_adjustment | estimate.bcy_adjustment |
| adjustment_description | estimate.adjustment_description |
| roundoff_value | estimate.roundoff_value |
| roundoff_value_formatted | estimate.roundoff_value_formatted |
| transaction_rounding_type | estimate.transaction_rounding_type |
| sub_total | estimate.sub_total |
| sub_total_formatted | estimate.sub_total_formatted |
| bcy_sub_total | estimate.bcy_sub_total |
| sub_total_inclusive_of_tax | estimate.sub_total_inclusive_of_tax |
| sub_total_inclusive_of_tax_formatted | estimate.sub_total_inclusive_of_tax_formatted |
| sub_total_exclusive_of_discount | estimate.sub_total_exclusive_of_discount |
| sub_total_exclusive_of_discount_formatted | estimate.sub_total_exclusive_of_discount_formatted |
| discount_total | estimate.discount_total |
| discount_total_formatted | estimate.discount_total_formatted |
| bcy_discount_total | estimate.bcy_discount_total |
| discount_percent | estimate.discount_percent |
| total | estimate.total |
| total_formatted | estimate.total_formatted |
| bcy_total | estimate.bcy_total |
| tax_total | estimate.tax_total |
| tax_total_formatted | estimate.tax_total_formatted |
| bcy_tax_total | estimate.bcy_tax_total |
| price_precision | estimate.price_precision |
| taxes | estimate.taxes |
| comments | estimate.comments |
| invoice_ids | estimate.invoice_ids |
| billing_address | estimate.billing_address |
| shipping_address | estimate.shipping_address |
| customer_default_billing_address | estimate.customer_default_billing_address |
| notes | estimate.notes |
| terms | estimate.terms |
| custom_fields | estimate.custom_fields |
| template_id | estimate.template_id |
| template_name | estimate.template_name |
| template_type | estimate.template_type |
| template_type_formatted | estimate.template_type_formatted |
| created_time | estimate.created_time |
| last_modified_time | estimate.last_modified_time |
| created_by_id | estimate.created_by_id |
| last_modified_by_id | estimate.last_modified_by_id |
| contact_persons_associated | estimate.contact_persons_associated |
| contact_persons_details | estimate.contact_persons_details |
| salesperson_id | estimate.salesperson_id |
| salesperson_name | estimate.salesperson_name |
| attachment_name | estimate.attachment_name |
| allow_partial_payments | estimate.allow_partial_payments |
| payment_options | estimate.payment_options |
| payments | estimate.payments |
| subject_content | estimate.subject_content |
| approvers_list | estimate.approvers_list |
Set Estimate Details
Updates or sets data within the current context. This method allows your widget to modify field values, update state, or pass data back to the host application.
- Update field values
- Set widget or module state
- Pass data to the parent application
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
ZFAPPS.set('estimate.name', <value>).then(function (data) {
//response Handling
}).catch(function (err) {
//error Handling
});
});
}
| Property | Request |
|---|---|
| estimate_id | estimate.estimate_id |
| estimate_number | estimate.estimate_number |
| crm_owner_id | estimate.crm_owner_id |
| crm_custom_reference_id | estimate.crm_custom_reference_id |
| zcrm_potential_id | estimate.zcrm_potential_id |
| zcrm_potential_name | estimate.zcrm_potential_name |
| date | estimate.date |
| date_formatted | estimate.date_formatted |
| created_date | estimate.created_date |
| created_date_formatted | estimate.created_date_formatted |
Show More Supported Input Keys
| Property | Request |
|---|---|
| reference_number | estimate.reference_number |
| status | estimate.status |
| status_formatted | estimate.status_formatted |
| customer_id | estimate.customer_id |
| branch_id | estimate.branch_id |
| documents | estimate.documents |
| customer_name | estimate.customer_name |
| place_of_supply | estimate.place_of_supply |
| place_of_supply_formatted | estimate.place_of_supply_formatted |
| contact_category | estimate.contact_category |
| tax_treatment | estimate.tax_treatment |
| tax_treatment_formatted | estimate.tax_treatment_formatted |
| contact_persons | estimate.contact_persons |
| currency_id | estimate.currency_id |
| currency_code | estimate.currency_code |
| currency_symbol | estimate.currency_symbol |
| exchange_rate | estimate.exchange_rate |
| expiry_date | estimate.expiry_date |
| expiry_date_formatted | estimate.expiry_date_formatted |
| discount | estimate.discount |
| discount_applied_on_amount | estimate.discount_applied_on_amount |
| is_discount_before_tax | estimate.is_discount_before_tax |
| discount_type | estimate.discount_type |
| is_viewed_by_client | estimate.is_viewed_by_client |
| client_viewed_time | estimate.client_viewed_time |
| client_viewed_time_formatted | estimate.client_viewed_time_formatted |
| is_inclusive_tax | estimate.is_inclusive_tax |
| tax_rounding | estimate.tax_rounding |
| estimate_url | estimate.estimate_url |
| line_items | estimate.line_items |
| submitter_id | estimate.submitter_id |
| submitted_date | estimate.submitted_date |
| submitted_date_formatted | estimate.submitted_date_formatted |
| submitted_by | estimate.submitted_by |
| approver_id | estimate.approver_id |
| shipping_charge | estimate.shipping_charge |
| shipping_charge_formatted | estimate.shipping_charge_formatted |
| bcy_shipping_charge | estimate.bcy_shipping_charge |
| adjustment | estimate.adjustment |
| adjustment_formatted | estimate.adjustment_formatted |
| bcy_adjustment | estimate.bcy_adjustment |
| adjustment_description | estimate.adjustment_description |
| roundoff_value | estimate.roundoff_value |
| roundoff_value_formatted | estimate.roundoff_value_formatted |
| transaction_rounding_type | estimate.transaction_rounding_type |
| sub_total | estimate.sub_total |
| sub_total_formatted | estimate.sub_total_formatted |
| bcy_sub_total | estimate.bcy_sub_total |
| sub_total_inclusive_of_tax | estimate.sub_total_inclusive_of_tax |
| sub_total_inclusive_of_tax_formatted | estimate.sub_total_inclusive_of_tax_formatted |
| sub_total_exclusive_of_discount | estimate.sub_total_exclusive_of_discount |
| sub_total_exclusive_of_discount_formatted | estimate.sub_total_exclusive_of_discount_formatted |
| discount_total | estimate.discount_total |
| discount_total_formatted | estimate.discount_total_formatted |
| bcy_discount_total | estimate.bcy_discount_total |
| discount_percent | estimate.discount_percent |
| total | estimate.total |
| total_formatted | estimate.total_formatted |
| bcy_total | estimate.bcy_total |
| tax_total | estimate.tax_total |
| tax_total_formatted | estimate.tax_total_formatted |
| bcy_tax_total | estimate.bcy_tax_total |
| price_precision | estimate.price_precision |
| taxes | estimate.taxes |
| comments | estimate.comments |
| invoice_ids | estimate.invoice_ids |
| billing_address | estimate.billing_address |
| shipping_address | estimate.shipping_address |
| customer_default_billing_address | estimate.customer_default_billing_address |
| notes | estimate.notes |
| terms | estimate.terms |
| custom_fields | estimate.custom_fields |
| template_id | estimate.template_id |
| template_name | estimate.template_name |
| template_type | estimate.template_type |
| template_type_formatted | estimate.template_type_formatted |
| created_time | estimate.created_time |
| last_modified_time | estimate.last_modified_time |
| created_by_id | estimate.created_by_id |
| last_modified_by_id | estimate.last_modified_by_id |
| contact_persons_associated | estimate.contact_persons_associated |
| contact_persons_details | estimate.contact_persons_details |
| salesperson_id | estimate.salesperson_id |
| salesperson_name | estimate.salesperson_name |
| attachment_name | estimate.attachment_name |
| allow_partial_payments | estimate.allow_partial_payments |
| payment_options | estimate.payment_options |
| payments | estimate.payments |
| subject_content | estimate.subject_content |
| approvers_list | estimate.approvers_list |
Get Estimates List
Retrieves multiple data points or a collection of records related to the current context. This method is useful for fetching lists, related records, or bulk data required for your widget's functionality.
- Fetch related records
- Retrieve collections of data
- Access lists or tables of information
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
ZFAPPS.get('estimates').then(function (data) {
//response Handling
}).catch(function (err) {
//error Handling
});
});
}
| Property | Request |
|---|---|
| estimate_id | estimate.estimate_id |
| zcrm_potential_id | estimate.zcrm_potential_id |
| zcrm_potential_name | estimate.zcrm_potential_name |
| customer_name | estimate.customer_name |
| customer_id | estimate.customer_id |
| company_name | estimate.company_name |
| status | estimate.status |
| status_formatted | estimate.status_formatted |
| estimate_number | estimate.estimate_number |
| reference_number | estimate.reference_number |
Show More Supported Input Keys
| Property | Request |
|---|---|
| date | estimate.date |
| date_formatted | estimate.date_formatted |
| currency_id | estimate.currency_id |
| currency_code | estimate.currency_code |
| total | estimate.total |
| total_formatted | estimate.total_formatted |
| created_time | estimate.created_time |
| last_modified_time | estimate.last_modified_time |
| accepted_date | estimate.accepted_date |
| accepted_date_formatted | estimate.accepted_date_formatted |
| declined_date | estimate.declined_date |
| declined_date_formatted | estimate.declined_date_formatted |
| expiry_date | estimate.expiry_date |
| expiry_date_formatted | estimate.expiry_date_formatted |
| has_attachment | estimate.has_attachment |
| is_viewed_by_client | estimate.is_viewed_by_client |
| client_viewed_time | estimate.client_viewed_time |
| client_viewed_time_formatted | estimate.client_viewed_time_formatted |
| is_emailed | estimate.is_emailed |
| template_type | estimate.template_type |
| template_id | estimate.template_id |
| salesperson_id | estimate.salesperson_id |
| salesperson_name | estimate.salesperson_name |
| selected | estimate.selected |
Set Estimate customfields
Specifically designed to update custom field values within the current context. This method allows your widget to target and modify custom fields without affecting standard fields, ensuring precise data management.
- Update custom field values
- Manage user-defined data points
- Ensure targeted updates to specific fields
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
ZFAPPS.set('estimate.<custom_field_api_name>',<value>).then(function (data) {
//response Handling
}).catch(function (err) {
//error Handling
});
});
}
Get Line Items
This method allows you to retrieve the line items associated with the current estimate. It can be used to fetch details such as product information, quantity, rate, and total for each line item. This is particularly useful when you want to display or utilize the sales order's line item details within your widget or extension.
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
ZFAPPS.get('estimate.line_items').then(function (res) {
console.log('estimate line items : ', res);
}).catch(function (err) {
console.log('Error while fetching estimate line items : ', err);
});
});
}
| Property | Request |
|---|---|
| line_item_id | line_item_id |
| item_order | item_order |
| item_id | item_id |
| rate | rate |
| name | name |
| description | description |
| quantity | quantity |
| discount | discount |
| discounts | discounts |
| tax_id | tax_id |
Show More Supported Input Keys
| Property | Request |
|---|---|
| tags | tags |
| product_type | product_type |
| tax_exemption_code | tax_exemption_code |
| tax_exemption_id | tax_exemption_id |
| avatax_tax_code | avatax_tax_code |
| item_custom_fields | item_custom_fields |
| hsn_or_sac | hsn_or_sac |
| gst_treatment_code | gst_treatment_code |
| tax_treatment_code | tax_treatment_code |
| header_name | header_name |
| header_id | header_id |
| pricebook_id | pricebook_id |
| is_discounted | is_discounted |
| tds_tax_id | tds_tax_id |
| unit | unit |
| unit_conversion_id | unit_conversion_id |
| item_meta_fields | item_meta_fields |
| sat_item_key_code | sat_item_key_code |
| unitkey_code | unitkey_code |
| type | type |
| non_taxable_amount | non_taxable_amount |
| tax_category | tax_category |
| product_tax_category | product_tax_category |
| mapped_items | mapped_items |
| tax_selection_mode | tax_selection_mode |
| line_item_taxes | line_item_taxes |
| line_item_tds | line_item_tds |
| cost_source | cost_source |
| purchase_price | purchase_price |
Set Line Items
This methods is to allowed for set a list of line items in the current estimate. It can be used to set details such as product information, quantity, rate, and total for multiple line items. This is particularly useful when you want to update or set multiple line items details within your widget or extension.This methods is append the line items to the existing line items in the estimate.
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
var lineItemMetaData =[{'rate':'1000','description':'Table','name':'Table'},{'rate':'1000','description':'Monitor','name':'Monitor'}]
ZFAPPS.set('estimate.line_items',lineItemMetaData).then(function (res) {
console.log('estimate line items : ', res);
}).catch(function (err) {
console.log('Error while fetching estimate line items : ', err);
});
});
}
| Property | Request |
|---|---|
| line_item_id | line_item_id |
| item_order | item_order |
| item_id | item_id |
| rate | rate |
| name | name |
| description | description |
| quantity | quantity |
| discount | discount |
| discounts | discounts |
| tax_id | tax_id |
Show More Supported Input Keys
| Property | Request |
|---|---|
| tags | tags |
| product_type | product_type |
| tax_exemption_code | tax_exemption_code |
| tax_exemption_id | tax_exemption_id |
| avatax_tax_code | avatax_tax_code |
| item_custom_fields | item_custom_fields |
| hsn_or_sac | hsn_or_sac |
| gst_treatment_code | gst_treatment_code |
| tax_treatment_code | tax_treatment_code |
| header_name | header_name |
| header_id | header_id |
| pricebook_id | pricebook_id |
| is_discounted | is_discounted |
| tds_tax_id | tds_tax_id |
| unit | unit |
| unit_conversion_id | unit_conversion_id |
| item_meta_fields | item_meta_fields |
| sat_item_key_code | sat_item_key_code |
| unitkey_code | unitkey_code |
| type | type |
| non_taxable_amount | non_taxable_amount |
| tax_category | tax_category |
| product_tax_category | product_tax_category |
| mapped_items | mapped_items |
| tax_selection_mode | tax_selection_mode |
| line_item_taxes | line_item_taxes |
| line_item_tds | line_item_tds |
| cost_source | cost_source |
| purchase_price | purchase_price |
Set Single Line Items
This methods is to allowed for setting/updating a single line item in the current estimate. It can be used to set details such as product information, quantity, rate, and total for a single line item. This is particularly useful when you want to update or set a single line item details within your widget or extension.
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
ZFAPPS.set('estimate.line_items[0]',{'rate':'1000'}).then(function (res) {
console.log('estimate line item rate : ', res);
}).catch(function (err) {
console.log('Error while fetching estimate line item rate : ', err);
});
});
}
| Property | Request |
|---|---|
| line_item_id | line_item_id |
| item_order | item_order |
| item_id | item_id |
| rate | rate |
| name | name |
| description | description |
| quantity | quantity |
| discount | discount |
| discounts | discounts |
| tax_id | tax_id |
Show More Supported Input Keys
| Property | Request |
|---|---|
| tags | tags |
| product_type | product_type |
| tax_exemption_code | tax_exemption_code |
| tax_exemption_id | tax_exemption_id |
| avatax_tax_code | avatax_tax_code |
| item_custom_fields | item_custom_fields |
| hsn_or_sac | hsn_or_sac |
| gst_treatment_code | gst_treatment_code |
| tax_treatment_code | tax_treatment_code |
| header_name | header_name |
| header_id | header_id |
| pricebook_id | pricebook_id |
| is_discounted | is_discounted |
| tds_tax_id | tds_tax_id |
| unit | unit |
| unit_conversion_id | unit_conversion_id |
| item_meta_fields | item_meta_fields |
| sat_item_key_code | sat_item_key_code |
| unitkey_code | unitkey_code |
| type | type |
| non_taxable_amount | non_taxable_amount |
| tax_category | tax_category |
| product_tax_category | product_tax_category |
| mapped_items | mapped_items |
| tax_selection_mode | tax_selection_mode |
| line_item_taxes | line_item_taxes |
| line_item_tds | line_item_tds |
| cost_source | cost_source |
| purchase_price | purchase_price |
Set Bulk Line Items
This methods is to allowed for replacing/updating all the existing line items in the current estimate. It can be used to set details such as product information, quantity, rate, and total for multiple line items. This is particularly useful when you want to update or set multiple line items details within your widget or extension.
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
var lineItemMetaData =[{'rate':'1000','description':'Table','name':'Table'},{'rate':'1000','description':'Monitor','name':'Monitor'}]
ZFAPPS.set('estimate.line_items.bulk_update',lineItemMetaData).then(function (res) {
console.log('estimate line items : ', res);
}).catch(function (err) {
console.log('Error while fetching estimate line items : ', err);
});
});
}
| Property | Request |
|---|---|
| line_item_id | line_item_id |
| item_order | item_order |
| item_id | item_id |
| rate | rate |
| name | name |
| description | description |
| quantity | quantity |
| discount | discount |
| discounts | discounts |
| tax_id | tax_id |
Show More Supported Input Keys
| Property | Request |
|---|---|
| tags | tags |
| product_type | product_type |
| tax_exemption_code | tax_exemption_code |
| tax_exemption_id | tax_exemption_id |
| avatax_tax_code | avatax_tax_code |
| item_custom_fields | item_custom_fields |
| hsn_or_sac | hsn_or_sac |
| gst_treatment_code | gst_treatment_code |
| tax_treatment_code | tax_treatment_code |
| header_name | header_name |
| header_id | header_id |
| pricebook_id | pricebook_id |
| is_discounted | is_discounted |
| tds_tax_id | tds_tax_id |
| unit | unit |
| unit_conversion_id | unit_conversion_id |
| item_meta_fields | item_meta_fields |
| sat_item_key_code | sat_item_key_code |
| unitkey_code | unitkey_code |
| type | type |
| non_taxable_amount | non_taxable_amount |
| tax_category | tax_category |
| product_tax_category | product_tax_category |
| mapped_items | mapped_items |
| tax_selection_mode | tax_selection_mode |
| line_item_taxes | line_item_taxes |
| line_item_tds | line_item_tds |
| cost_source | cost_source |
| purchase_price | purchase_price |
Set Line Items Customfields
This method is allowed for setting/updating custom fields for line items in the current estimate. It can be used to set details such as product information, quantity, rate, total, and custom field values for multiple line items. This is particularly useful when you want to update or set multiple line items details along with their custom field values within your widget or extension.
window.onload = function () {
ZFAPPS.extension.init().then(function(App) {
var lineItemMetaData =[{'rate':'1000','description':'Table','name':'Table','item_custom_fields':[{'api_name':'<line_item_custom_field_name>', 'value':'<value>'}]}]
ZFAPPS.set('estimate.line_items',lineItemMetaData).then(function (res) {
console.log('estimate line items : ', res);
}).catch(function (err) {
console.log('Error while fetching estimate line items : ', err);
});
});
}
Events
ESTIMATE_SAVED
This event is triggered after the estimate record is successfully saved in your organization. You can use this event to perform post-save actions such as syncing data, triggering notifications, or updating external systems.
ZFAPPS.extension.init().then(function(App) {
App.instance.on('ON_ESTIMATE_SAVED').then(function(data) {
var recordId = data && data.record_id;
ZFAPPS.invoke('SHOW_NOTIFICATION', {
type: 'success',
message: 'Record saved successfully. Record ID: ' + recordId
});
console.log('Saved record ID:', recordId);
}).catch(function(err) {
console.error('Error:', err);
});
});
ON_ESTIMATE_CHANGE
This event is triggered whenever there is a change in the estimate record while you are creating or editing an estimate. It allows your widget to respond to changes in real time, enabling dynamic updates, validations, or calculations based on the modified estimate data.
ZFAPPS.extension.init().then(function(App) {
App.instance.on('ON_ESTIMATE_CHANGE').then(async function() {
try {
var moduleResponse = await ZFAPPS.get('module');
var moduleName = moduleResponse.module.api_name;
var recordResponse = await ZFAPPS.get(moduleName);
var record = recordResponse[moduleName];
// Check if vendor is selected
if (record.vendor_name && record.vendor_name.name === 'ABC Suppliers') {
// Apply 5% vendor discount at module level
await ZFAPPS.set(moduleName + '.discount_type', 'entity_level');
await ZFAPPS.set(moduleName + '.discount', '5%');
await ZFAPPS.invoke('SHOW_NOTIFICATION', {
type: 'info',
message: 'A 5% preferred vendor discount has been applied for ABC Suppliers.'
});
}
} catch (error) {
console.error('Error:', error);
}
});
});
ON_ESTIMATE_PREVIEW
This event is triggered when the preview of a estimate record is opened in your organization. It allows your widget to access record data and render contextual information during the preview phase.
ZFAPPS.extension.init().then(function(App) {
App.instance.on('ON_ESTIMATE_PREVIEW').then(async function() {
var record = await ZFAPPS.get('estimate');
record = record?.['custom_fields'];
if (record.cf_priority_level === 'High') {
ZFAPPS.invoke('SHOW_NOTIFICATION', {
type: 'error',
message: 'This record is marked as High Priority.'
});
}
}).catch(function(err) {
console.error('Error:', err);
});
});
ON_ESTIMATE_PRE_SAVE
This event is triggered just before the estimate record is saved in your organization. It allows your widget to validate data, modify field values, or perform custom checks before the save operation is completed.
ZFAPPS.extension.init().then(function(App) {
App.instance.on('ON_ESTIMATE_PRE_SAVE').then(async function() {
var record = await ZFAPPS.get('estimate');
record = record?.['custom_fields'];
if (record.cf_approval_required && !record.cf_approval_notes) {
await ZFAPPS.invoke('SHOW_NOTIFICATION', {
type: 'error',
message: 'Approval notes are required when Approval Required is selected.'
});
return {
prevent_save: true
};
}
}).catch(function(err) {
console.error('Error:', err);
});
});