Tuesday, 4 September 2012

Change View in InfoPath 2010 on Form load event using code

Following code is using infopath 2010 code behind.

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
    try
    {
        string view = "";
        if (e.InputParameters.ContainsKey("View"))
        {
            view = e.InputParameters["View"];
            e.SetDefaultView(view);
        }
    }
    catch (Exception ex)
    {
        SetValue("/my:myFields/my:FormSettings/my:ErrorLog", ex.Message + ex.StackTrace);
    }
}

No comments:

Post a Comment