Here is the code with some comments I put in to help clarify.
// ================ CALL THE FIRST DIALOG TO OPEN A QADI
// CREATE THE BUTTONS FOR THE QADI (Questions, Actions, Issues, Decisions)
// Button one: Add a new QADI
const addQADI = {
icon: 'SunQuestionMark',
class: 'btn-outline-primary',
text: 'Add QADI',
visible: true,
click: function() {
const url = fd.webUrl + '/Lists/QADI/NewForm.aspx';
// BELOW IS A SAMPLE OF HOW WE SHOUILD FORMAT UP THE DIALOG OPEN CONTROL
Dialog.open(url,{ RequirementId: fd.field('RequirementID').value,
ProcessStepId: fd.field('ProcessStepID').value,
RICEId: fd.field('RICEID').value,
AssignedTo: fd.field("AssignedTo").value,
Module: fd.field("Module").value,
Project: fd.field("Project").value,
Pillar: fd.field("Pillar").value
},
function(){} ,
{ width: 1200, height: 800,
title: 'You are adding a Qestion, Action, Decision or Issue'
}
);
}
};
// Button Two: Edit the selected QADI
const editQADI = {
icon: 'SunQuestionMark',
class: 'btn-outline-primary',
text: 'Edit QADI',
visible: true,
click: function() {
const items = fd.control('ListQADI').selectedItems;
const url = fd.webUrl + "/Lists/QADI/EditForm.aspx?ID=" + items[0].ID;
Dialog.open(url,{}, function(){} ,{ width: 1200, height: 800, title: ''} );
}
};
// REPLACE THE KENDO BUTTONS WITH OUR BUTTONS
fd.control('ListQADI').ready(function(dt) {
dt.buttons[0].style = "display: none;";
dt.buttons[1].style = "display: none;";
dt.buttons[2].style = "display: none;";
dt.buttons.push(addQADI);
dt.buttons.push(editQADI);
});
// =============== WE ARE NOW IN THE EDIT QADI DIALOG which is calling the warning Dialog inside the QADI Dialog
function checkStartActualDate () {
if (fd.field('StartActual').value > new Date()) {
Dialog.open({
template: `<div class="Container">
<div class="image">
<img src="https://XXX.sharepoint.com/sites/PMO/Images1/chippy.png" alt="Chippy" style="width:50px;height:50px;>
</div>
<div class="text">
<br><br><div>Hey there, Chippy here. Looks like you set the Actual Start Date to some date in the distant future.<div><br>
<div>Unless you're a time traveller, that is impossible.<div><br>
<div>I'm resetting the Actual Start Date to today.<div><br>
</div>
</div>
<div class="d-flex mt-4 gap-3">
<button type="button" class="btn btn-outline-primary flex-fill" id="okButton">Thanks Chippy, my mistake</button>
</div>`
}, null, null, {
width: 600,
height: 350,
title: 'Chippy has something to say',
open: (e) => {
var dialogBody = e.sender.element;
var okButton = dialogBody.find('#okButton');
okButton.click(() => {
fd.field('StartActual').value = new Date();
// THIS IS THE CLOSE DIALOG OF THE SECONG DIALOG - THE PAGE FREEZES WHEN CLICKED
Dialog.close();
});
}
});
}
}