The following solution was thanks to Hilary Stoupa, Thank you!:
I had to to create a boolean field first that would assist in the operation. Then I created to event handlers. One for the dropdownlist, and onAfterChange event, and one for saving, onSaveRequest. Here is the code I used for the two of them:
public void ddlEngagementType_OnAfterChange(DataDOMEvent e)
//checks to see if the engagement type has changed from New to Extension. If so, it sets a boolean field to true
//which will later disable save forcing a submit only. This prevents saving new extensions over current new project announcements.
{
// Write your code here to restore the global state.if (e.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 your code here.if (e.OldValue != null)
{
//set variables to hold the old value and the new value of the fieldstring newValue = e.NewValue.ToString();
string oldValue = e.OldValue.ToString();
//if the field used to have the value of new and now has the value of extension, move into the next code blockif (oldValue.ToLower().Equals("new") && newValue.ToLower().Equals("extension"))
{
//set our helper field to "true"
thisXDocument.DOM.selectSingleNode(
"/my:myFields/my:ddlEngagementType/@my:bEngagementType").text = "true";
}
}
}
public void FormEvents_OnSaveRequest(SaveEvent e)
//This checks the value of the helper boolean to determine if any of the triggers went off to disable save
{
// Write your code that will run before a Save or Save As operation here.
//get the values of the drop down and the helper nodestring ddlValue = thisXDocument.DOM.selectSingleNode("/my:myFields/my:ddlEngagementType").text;
string helper = thisXDocument.DOM.selectSingleNode("/my:myFields/my:ddlEngagementType/@my:bEngagementType").text;
//check to see if our helper node is true -- if it is, and if the value of the drop down is "extension", don't allow savingif (Convert.ToBoolean(helper) && ddlValue.ToLower().Equals("extension"))
{
thisXDocument.UI.Alert("You can't save the form because you changed the status from new to extension");e.ReturnStatus = true;
}
else
{
e.IsCancelled = e.PerformSaveOperation();
// Write your code to be run after saving here.e.ReturnStatus = true;
}
}
Hope this helps. Thanks to all who contributed!
Eric