我为每个分配给用户的角色创建任务。每个角色都有几个资源。我需要为每个资源向Workflow自定义任务表单添加动态组合框。组合框将包含所有帐户。这可以通过自定义的infopath任务表单来实现吗?
甚至可以在infopath任务表单中添加代码(是否需要管理员批准)?
答案 0 :(得分:0)
可以将代码添加到自定义InfoPath任务表单。应该确保将dll与表单一起部署。
还可以在重复表中添加组合框(所有组合框都具有相同的数据源)。重复表的行在PageLoad上创建,其数据由Workflow提供,方法是将其作为XML嵌入到表单字段中。
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
string myNamespace = NamespaceManager.LookupNamespace("my");
XPathNavigator repTable = MainDataSource.CreateNavigator().SelectSingleNode("/my:RoleAssigmentExecution/my:Resources", NamespaceManager);
if (repTable == null)
{
XPathNavigator node = MainDataSource.CreateNavigator().SelectSingleNode("/my:RoleAssigmentExecution", NamespaceManager);
using (XmlWriter writer = node.AppendChild())
{
writer.WriteStartElement("Resources", myNamespace);
writer.WriteEndElement();
writer.Close();
}
}
repTable = MainDataSource.CreateNavigator().SelectSingleNode("/my:RoleAssigmentExecution/my:Resources", NamespaceManager);
if (repTable != null)
{
using (XmlWriter writer = repTable.AppendChild())
{
XPathNavigator inst = MainDataSource.CreateNavigator().SelectSingleNode("/my:RoleAssigmentExecution/my:Instructions", NamespaceManager);
writer.WriteStartElement("ResorceAccounts", myNamespace);
writer.WriteElementString("resource", myNamespace, inst.Value);
writer.WriteElementString("accountCombo", myNamespace, "");
writer.WriteEndElement();
writer.Close();
}
}
else
{
string path = "/my:RoleAssigmentExecution/my:Remarks";
XPathNavigator node = MainDataSource.CreateNavigator().SelectSingleNode(path, NamespaceManager);
node.SetValue("can not access Repeating Table");
}
}