locked
SetValue is updating only once after submitting the request (InfoPath 2007) RRS feed

  • Question

  • I am working on leave request infopath form.First user creating the leave request  and mail sent to manager for approval.once manager approve the request the FormStatus is not updating from "Approval" to "Accepted".

     

    Default value of FormStatus is "Request".FormStatus is changed its value once when they requested From Request to Approval,when mangaer updated the request FormStatus is not updating from

    Approval to Accepted.I am not getting the error ,I can see value is changed in debugging but once the form runs to browser its notupdatin.

     

    here is code.

             public void FormEvents_Submit(object sender, SubmitEventArgs e)
            {
                    CreateID();

                   CalculateDaysRequested();

                    XPathNavigator Main = MainDataSource.CreateNavigator();

                    XPathNavigator FormStatus = Main.SelectSingleNode("/my:myFields/my:FormStatus", NamespaceManager);

                     if (FormStatus.Value == "Request")
                    {
                        FormStatus.SetValue("Approval"); //Works fine first time
          EmailSubmitConnection emailConn =
                        (EmailSubmitConnection)DataConnections["Request Email"];
                        emailConn.EmailAttachmentType = EmailAttachmentType.None;
                        emailConn.Execute();

                       
                        FormStatus.SetValue("Manager");

                        //send mail and submit the data to sharepoint library

                        DataConnection spConn = DataConnections["SharePoint Library Submit"];
                      
                        spConn.Execute();
                    }
                    else if (FormStatus.Value == "Approval")
                    {

                        //Remove the "nil" attribute.
                        if (FormStatus.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
                            FormStatus.DeleteSelf();

                        //Set the value of the myDate field.
                        FormStatus.SetValue("Accepted");//Not updatin the second time...

                              //update the data to sharepoint library                   
                      

                        FormStatus.SetValue("Accepted");
                    }

                    // If the submit operation is successful, set
                    e.CancelableArgs.Cancel = false;
                    // Write your code here.
               
            }

     Any heps ..


    Friday, March 25, 2011 2:20 PM

Answers

  • Looks like you are setting the status to "Manager" after you do the "Approval" so the else if condition won't be executed. Remove the "FormStatus.SetValue("Manager");" line and see what happens...

    -=Steve

    • Marked as answer by Peng Lei Friday, April 1, 2011 8:11 AM
    Wednesday, March 30, 2011 6:27 PM