Hi,
Add a filed to data source (ex: field1 and its xpath is like /my:myFields/my:field1). Before submitting the form, write the following code.
XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = XDocument.View.Name;
Add a switch view event and write the following code.
function XDocument::OnSwitchView(eventObj)
{
var viewName = XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text;
XDocument.View.SwitchView(viewName);
}