Question

I create task per role assigned to user. Every role has several resources. I need to add dynamically comboboxes to Workflow custom task form for every resource. Comboboxes will contain all accounts. Is this possible with custom infopath task forms?

Is it even possible to add code behind to infopath task form (does it need administrator approval)?

Était-ce utile?

La solution

is possible to add code to custom InfoPath task form. One should just ensure that dll is deployed together with form.

Also it is possible to add comboboxes inside repeating table (all comboboxes have same data source). Rows for repeating table are created on PageLoad and data for it is provided from Workflow by embding it in Form field as 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");
        }
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top