SetValue is updating only once after submitting the request (InfoPath 2007) - InfoPath Dev
in

InfoPath Dev

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

Last post 03-25-2011 11:16 AM by BMARU. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 03-25-2011 09:32 AM

    • BMARU
    • Not Ranked
    • Joined on 03-25-2011
    • Posts 24

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

    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();

                        
                       //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 helps ..

  • 03-25-2011 09:41 AM In reply to

    Re: SetValue is updating only once after submitting the request (InfoPath 2007)

    Hey there:

    Looks like you are setting the field, but not saving the changed XML. I see a comment that says "update the data to sharepoint library" but I do not see your SharePoint Library data connection being executed. Add that to your "else" block.

    Hilary Stoupa

  • 03-25-2011 10:12 AM In reply to

    • BMARU
    • Not Ranked
    • Joined on 03-25-2011
    • Posts 24

    Re: SetValue is updating only once after submitting the request (InfoPath 2007)

    Hi Hilary,

    I am using the FormStatus as hidden field.by default FormStatus is "Request" value.If user submit request then its change the value to FormStatus="Approval" and request send to manager by email.

    if mangaer approve the request then FormStatus="Accepted" which is not updating here....

    I am not storing FormStatus anywhere.....

    Please let me know if my approch is wrong?

  • 03-25-2011 10:31 AM In reply to

    • BMARU
    • Not Ranked
    • Joined on 03-25-2011
    • Posts 24

    Re: SetValue is updating only once after submitting the request (InfoPath 2007)

    I have tried call sharepoint library then its updatin the value ......

    but still there is prob with sharepoint library,like how i can i update existing data with same id in sharepoint library with connection.......

  • 03-25-2011 10:31 AM In reply to

    Re: SetValue is updating only once after submitting the request (InfoPath 2007)

    FormStatus, as a variable, appears to be a field in your main data source. At least based on your form code.

    In your if statement, you check if it is equal to request, and you set the field to "Approval", and you send an email and submit to your form library (which saves the XML).

    In your else statement, you check if it is equal to "Approval", and you set the field to "Accepted" -- and then you don't do anything. So, needless to say, you think nothing is happening, because you are not saving the XML.

    I think you want this in your else statement:

                    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 form status field.
                        FormStatus.SetValue("Accepted");
                        DataConnection spConn = DataConnections["SharePoint Library Submit"];
                        spConn.Execute();
                    }

    You'll see that I only added an Execute call to your data connection named "SharePoint Library Submit" -- I'm making the assumption that submits the form to the SharePoint library (thus, saving the XML and the changed "FormStatus" field.

    Hilary Stoupa

  • 03-25-2011 10:47 AM In reply to

    Re: SetValue is updating only once after submitting the request (InfoPath 2007)

    Walk through your submit connection again in the Data Connection Wizard. Make sure you've selected the box that allows you to overwrite existing files. Make sure you are using something unique for the file name (a date in the formula always helps with that ... now() is a good date to use).

    Hilary Stoupa

  • 03-25-2011 11:16 AM In reply to

    • BMARU
    • Not Ranked
    • Joined on 03-25-2011
    • Posts 24

    Re: SetValue is updating only once after submitting the request (InfoPath 2007)

    Thanks Hillary , solved  my all issue.

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.