I wrote some Javascript that loops through xml nodes using the FormAPI for Teamsite and removes a value from one of the nodes. The removeID function only works properly when the alert is in it. I've tried separating actions into different functions and putting a setTimeout() on them but nothing works. The script only executes when the page is being saved and closed so the page has definitely already been loaded. Anyone have any other ideas?
This works:
function removeID(xPath) {
if(xPath.getChildByName('path') != undefined && xPath.getChildByName('id') != undefined){
if(xPath.getChildByName('path').getValue() == "" && xPath.getChildByName('id').getValue() != ""){
xPath.getChildByName('id').setValue('');
alert("replaced ");
}
}
return true;
}
This does not work (no alert):
function removeID(xPath) {
if(xPath.getChildByName('path') != undefined && xPath.getChildByName('id') != undefined){
if(xPath.getChildByName('path').getValue() == "" && xPath.getChildByName('id').getValue() != ""){
xPath.getChildByName('id').setValue('');
}
}
return true;
}