Temporary Solution for ZatcaEGS and ZatcaExtension Users
To prevent data loss in custom fields due to recent changes in Manager, please follow these steps to apply a temporary fix:
- Go to Settings β Custom Fields β Text Custom Fields
- Find and edit the custom field named Approval Status
- Replace the current script in the Description field with the following:
for ZatcaEGS
<div id="MainScriptContainer">
<script>
document.addEventListener('DOMContentLoaded', () => {
console.group('[Invoice Script Init]');
console.log('β
DOMContentLoaded triggered');
// === Config constants ===
const readonlyLabels = ['Approval Status', 'Zatca UUID', 'Base64 QRCode', 'Date Created'];
const guidsToClear = [
'a1b2c3d4-e5f6-4abc-8def-abcdef000016',
'a1b2c3d4-e5f6-4abc-8def-abcdef000017',
'a1b2c3d4-e5f6-4abc-8def-abcdef000018'
];
const dateCreatedGuid = 'a1b2c3d4-e5f6-4abc-8def-abcdef000020';
const allowedButtons = [
'button.btn.btn-success',
'button.btn.btn-primary',
'button.btn.btn-default'
];
// === Check main form ===
const vModelForm = document.getElementById('v-model-form');
if (!vModelForm) {
console.warn('β v-model-form not found. Script aborted.');
return;
}
// === Handle readonly fields ===
const labels = vModelForm.querySelectorAll('label');
let approvalStatusHasValue = false;
labels.forEach(label => {
const labelText = label.textContent.trim();
if (!readonlyLabels.includes(labelText)) return;
const formGroup = label.closest('.form-group');
if (!formGroup) return;
if (labelText === 'Base64 QRCode') {
const textarea = formGroup.querySelector('textarea');
if (textarea) {
textarea.readOnly = true;
console.log(`π Made readonly: ${labelText}`);
}
} else {
const inputs = formGroup.querySelectorAll('input');
inputs.forEach(input => {
input.readOnly = true;
if (labelText === 'Approval Status' && input.value.trim() !== '') {
approvalStatusHasValue = true;
console.log('β
Approval Status has value:', input.value);
}
});
}
});
// === Approval Status Handling ===
if (approvalStatusHasValue) {
console.log('β οΈ Approval Status present. Locking form...');
const updateButton = document.querySelector('button.btn.btn-success');
if (!updateButton) {
console.log('β Update button not found. Resetting approval-related fields...');
labels.forEach(label => {
if (label.textContent.trim() === 'Approval Status') {
const formGroup = label.closest('.form-group');
if (formGroup) {
formGroup.querySelectorAll('input').forEach(input => input.value = null);
console.log('π§Ή Cleared Approval Status input');
}
}
});
guidsToClear.forEach(guid => {
if (app?.CustomFields2?.Strings) {
app.CustomFields2.Strings[guid] = null;
console.log(`π§Ή Cleared GUID field: ${guid}`);
}
});
approvalStatusHasValue = false;
}
if (approvalStatusHasValue) {
console.log('π Locking all inputs and disabling UI...');
const allowedButtonElements = allowedButtons.flatMap(sel => [...document.querySelectorAll(sel)]);
vModelForm.querySelectorAll('input, select, textarea, button').forEach(control => {
const isAllowed =
(control.tagName === 'INPUT' && control.type === 'checkbox') ||
allowedButtonElements.includes(control);
control.disabled = !isAllowed;
});
vModelForm.querySelectorAll('.v-select').forEach(vs => {
vs.querySelector('input.vs__search')?.setAttribute('disabled', 'true');
vs.querySelector('.vs__clear')?.setAttribute('disabled', 'true');
vs.style.pointerEvents = 'none';
vs.style.opacity = '0.6';
});
vModelForm.querySelectorAll('.select2-container').forEach(s2 => {
s2.querySelector('input')?.setAttribute('disabled', 'true');
s2.style.pointerEvents = 'none';
s2.style.opacity = '0.6';
});
vModelForm.querySelectorAll('td.handle').forEach(td => {
td.style.pointerEvents = 'none';
td.style.opacity = '0.5';
});
vModelForm.querySelectorAll('a.btn.btn-danger').forEach(link => {
link.style.pointerEvents = 'none';
link.style.opacity = '0.6';
link.setAttribute('aria-disabled', 'true');
link.removeAttribute('href');
});
}
}
// === Disable date input ===
const dateInput = document.querySelector('.mx-input');
if (dateInput) {
dateInput.disabled = true;
document.querySelector('.mx-icon-calendar')?.style.setProperty('pointer-events', 'none');
console.log('π
Disabled date input');
}
// === Disable automatic reference checkbox ===
const checkbox = document.querySelector('.input-group-addon input[type="checkbox"]');
const inputText = document.querySelector('.input-group input[type="text"]');
if (checkbox && inputText) {
app.AutomaticReference = false;
checkbox.checked = false;
checkbox.disabled = true;
inputText.disabled = true;
console.log('π Disabled automatic reference checkbox and text input');
}
// === Handle Create button & date injection ===
const createButton = document.querySelector('button.btn.btn-primary');
if (createButton && app?.CustomFields2?.Strings) {
const now = new Date();
const localDatetime = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
const currentDateTime = localDatetime.toISOString().slice(0, 19).replace('T', ' ');
app.CustomFields2.Strings[dateCreatedGuid] = currentDateTime;
app.IssueDate = currentDateTime.slice(0, 10);
app.CustomFields2.Strings[dateCreatedGuid] = currentDateTime;
console.log('π Set DateCreated & IssueDate:', currentDateTime);
if (checkbox && inputText) {
app.AutomaticReference = true;
checkbox.checked = true;
checkbox.disabled = true;
inputText.disabled = true;
console.log('β
Re-enabled automatic reference on create');
}
}
// === Hide "Date Created" field ===
labels.forEach(label => {
if (label.textContent.trim() === 'Date Created') {
label.closest('.form-group').style.display = 'none';
console.log('π Hid "Date Created" field');
}
});
// === Self-clean script container ===
const selfDeletingContainer = document.getElementById('MainScriptContainer');
if (selfDeletingContainer) {
selfDeletingContainer.remove();
console.log('ποΈ Removed script container from DOM');
}
console.groupEnd();
});
</script>
</div>
For ZatcaExtension
<div id="MainScriptContainer">
<script>document.addEventListener('DOMContentLoaded', () => {
const readonlyLabels = ['Approval Status', 'Zatca UUID', 'Base64 QRCode'];
const hiddenLabels = ['Date Created', 'Zatca UUID', 'Base64 QRCode'];
const guidsToClear = [
'a1b2c3d4-e5f6-4abc-8def-abcdef000016',
'a1b2c3d4-e5f6-4abc-8def-abcdef000017',
'a1b2c3d4-e5f6-4abc-8def-abcdef000018'
];
const dateCreatedGuid = 'a1b2c3d4-e5f6-4abc-8def-abcdef000020';
const allowedButtons = [
'button.btn.btn-success',
'button.btn.btn-primary',
'button.btn.btn-default'
];
const vModelForm = document.getElementById('v-model-form');
if (!vModelForm) return;
const labels = vModelForm.querySelectorAll('label');
let approvalStatusHasValue = false;
const allowedButtonElements = allowedButtons
.map(selector => [...document.querySelectorAll(selector)])
.flat();
labels.forEach(label => {
const labelText = label.textContent.trim();
if (!readonlyLabels.includes(labelText)) return;
const formGroup = label.closest('.form-group');
if (!formGroup) return;
if (labelText === 'Base64 QRCode') {
const textarea = formGroup.querySelector('textarea');
if (textarea) textarea.readOnly = true;
} else {
const inputs = formGroup.querySelectorAll('input');
inputs.forEach(input => {
input.readOnly = true;
if (labelText === 'Approval Status' && input.value && input.value.trim() !== '') {
approvalStatusHasValue = true;
}
});
}
});
if (approvalStatusHasValue) {
const updateButton = document.querySelector('button.btn.btn-success');
if (!updateButton) {
labels.forEach(label => {
if (label.textContent.trim() === 'Approval Status') {
const formGroup = label.closest('.form-group');
if (formGroup) {
const inputs = formGroup.querySelectorAll('input');
inputs.forEach(input => input.value = null);
}
}
});
guidsToClear.forEach(guid => {
app.CustomFields2.Strings[guid] = null;
});
approvalStatusHasValue = false;
}
if (approvalStatusHasValue) {
const controls = vModelForm.querySelectorAll('input, select, textarea, button');
controls.forEach(control => {
const isAllowed =
(control.tagName === 'INPUT' && control.type === 'checkbox') ||
allowedButtonElements.includes(control);
control.disabled = !isAllowed;
});
vModelForm.querySelectorAll('.v-select').forEach(vs => {
const input = vs.querySelector('input.vs__search');
if (input) input.disabled = true;
const clearBtn = vs.querySelector('.vs__clear');
if (clearBtn) clearBtn.disabled = true;
vs.style.pointerEvents = 'none';
vs.style.opacity = '0.6';
});
vModelForm.querySelectorAll('.select2-container').forEach(s2 => {
const input = s2.querySelector('input');
if (input) input.disabled = true;
s2.style.pointerEvents = 'none';
s2.style.opacity = '0.6';
});
vModelForm.querySelectorAll('td.handle').forEach(td => {
td.style.pointerEvents = 'none';
td.style.opacity = '0.5';
});
vModelForm.querySelectorAll('a.btn.btn-danger').forEach(link => {
link.style.pointerEvents = 'none';
link.style.opacity = '0.6';
link.setAttribute('aria-disabled', 'true');
link.removeAttribute('href');
});
}
}
const dateInput = document.querySelector('.mx-input');
if (dateInput) {
dateInput.disabled = true;
const calendarIcon = document.querySelector('.mx-icon-calendar');
if (calendarIcon) {
calendarIcon.style.pointerEvents = 'none';
calendarIcon.style.opacity = '0.5';
}
}
const checkbox = document.querySelector('.input-group-addon input[type="checkbox"]');
const inputText = document.querySelector('.input-group input[type="text"]');
if (checkbox && inputText) {
app.AutomaticReference = false;
checkbox.checked = false;
checkbox.disabled = true;
inputText.disabled = true;
}
const createButton = document.querySelector('button.btn.btn-primary');
if (createButton && app?.CustomFields2?.Strings) {
const now = new Date();
const localDatetime = new Date(now.getTime() - (now.getTimezoneOffset() * 60000));
const currentDateTime = localDatetime.toISOString().slice(0, 19).replace('T', ' ');
app.CustomFields2.Strings[dateCreatedGuid] = currentDateTime;
app.IssueDate = currentDateTime.slice(0, 10);
if (checkbox && inputText) {
app.AutomaticReference = true;
checkbox.checked = true;
checkbox.disabled = false;
inputText.disabled = false;
}
app.CustomFields2.Strings[dateCreatedGuid] = currentDateTime;
}
labels.forEach(label => {
const labelText = label.textContent.trim();
if (!hiddenLabels.includes(labelText)) return;
const formGroup = label.closest('.form-group');
if (formGroup) {
formGroup.style.display = 'none';
}
});
const selfDeletingContainer = document.getElementById('MainScriptContainer');
if (selfDeletingContainer) {
selfDeletingContainer.remove();
}
});
</script>
</div>
This script should be adjusted to match the current HTML structure of the Edit Form. If youβre unsure about the correct version v25.10.6.2882 or later, please wait for the finalized update before applying changes.
This workaround is specifically for users of ZatcaEGS and ZatcaExtension. It helps preserve functionality while the full fix is being finalized.