I have a checkbox inside a repeating section. When the checkbox is checked or unchecked I would like a confirmation box to be displayed. Based on the result other fields within the repeating section will be populated or cleared.
I have everything working with one problem. The OnBeforeChange event is fired not only when the checkbox is changed but also when a new repeating section is added. How do I differentiate between a checkbox change and a repeating section insertion? An code example is shown below. Thanks for all the assistance.
function msoxd_my_checkall::OnBeforeChange(eventObj)
{
// Write your code here
// Warning: ensure that the constraint you are enforcing is compatible with the default value you set for this XML node.
if (eventObj.Operation == "Insert"){
var mychoice = XDocument.UI.Confirm("Update Fields?", 1);
if (mychoice == 2){
eventObj.ReturnMessage = "Update Canceled";
eventObj.ReturnStatus = false;
}
}
}
function msoxd_my_checkall::OnAfterChange(eventObj)
{
// Write code here to restore the global state.
if (eventObj.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}
// A field change has occurred and the DOM is writable. Write code here to respond to the changes.
if (eventObj.Operation == "Insert"){
var myzero = "0";
var myblank = "";
eventObj.Site.selectSingleNode("../my:dataone").removeAttribute("xsi:nil");
eventObj.Site.selectSingleNode("../my:datatwo").removeAttribute("xsi:nil");
if (eventObj.Site.selectSingleNode("../my:checkall").text == "true"){
//Checkbox Unchecked
eventObj.Site.selectSingleNode("../my:dataone").text = myzero;
eventObj.Site.selectSingleNode("../my:datatwo").text = myzero;
}else{
//Checkbox Unchecked
eventObj.Site.selectSingleNode("../my:dataone").text = myblank;
eventObj.Site.selectSingleNode("../my:datatwo").text = myblank;
}
}
}
Richard T. Henry
Lewisberry, PA, USA
[email protected]