2012-08-03 24 views
0

我有一个InfoPath 2010表单来创建一个新的Sharepoint列表项。本质上,该表单具有一个输入字段和一个输出字段。如果在输入字段中输入了某些内容,则执行一些计算,我希望结果显示在输出字段中。由于计算有点复杂,我需要在代码中执行,而不是通过规则。在基于代码的计算后刷新InfoPath字段

private void CalculateOutput() 
{ 
    XPathNavigator main = MainDataSource.CreateNavigator(); 
    XPathNavigator service = main.SelectSingleNode("my:meineFelder/my:serviceValue", NamespaceManager); 
    double serviceValue = service.ValueAsDouble; 
    double output = 3*serviceValue; // much abbreviated version 

    // output now has the correct value 
    XPathNavigator outputNav = main.SelectSingleNode("my:meineFelder/my:output", NamespaceManager); 

    //Remove the "nil" attribute (otherwise we get an error when the field is a double instead of a string) 
    if (outputNav.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance")) outputNav.DeleteSelf(); 

    outputNav.SetValue(output.ToString()); 
} 

我的问题是,一切工作正常在InfoPath预览,但一旦我部署的形式,并在浏览器的输出字段没有更新运行它,也就是我看不到我的计算结果。

我试过了.ReplaceSelf(用OuterXML),结果为零。我也玩过将结果分配给另一个字段,从而发射“设置字段值”规则,也无济于事。

如果我提交表单,输出值保存确定,但我真的很希望用户在提交之前看到输出字段。

任何想法? Thx很多。

回答

0

在浏览器中启用形式的情况下,请确保您已设置的“回传设置”刷新“始终”

要做到在其上回发,则触发控制这一权利点击。 (在你的情况下服务价值)。转到浏览器表单选项卡并将传回设置设置为Always