Clearing a form field - InfoPath Dev
in

InfoPath Dev

Clearing a form field

Last post 01-04-2010 01:23 PM by eddyblanco. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-04-2010 12:35 PM

    Clearing a form field

    Currently I have multiple sites under my main sharepoint site. These sites are for different customers and each site holds the same type of data/forms but different info in each as it pertains to that certain customer. One of the forms is a CSR form where we can type up a quick log of work we did for that particular customer. I have since added a "Travel" check box to these CSR forms for all customers and when the box is checked there is a field "Miles" that gets populated with the round trip milage for that particular customer. At the end of the month I open a local form through InfoPath and click "get miles". My form is then populated, using multiple "query using data connections". Each customer has their own field in this form and that field gets the total number of miles for that customer for that month. It then rounds the numbers and gives me a total at the bottom and then I print it and submit to the proper folks here at my office.

     Now, what I have not been able to figure out is how to "clear" the miles on ALL the CSR forms at the same time so that next month I dont get old milage mixed in with new. I have already submited December milage and this month will be doing more CSR's and at the end of the month I only want January miles.

     Any Ideas on how to do this? I have tried creating a button "clear miles" and having that set the "miles" field to 0 using various data connections but nothing happens to the CSR "miles" filed when button is pressed. I understand why it is not happening but do not understand how to make this happen.

     Thanks in advance

  • 01-04-2010 01:03 PM In reply to

    I would try something like.

    If you store on a node the previous month something like. that is just one field you could loop al nodes and do the same

    XPathNavigator navigator = this.MainDataSource.CreateNavigator();
    XPathNavigator PreviousMonth = navigator.SelectSingleNode("/my:Form/my:PreviousMonth", this.NamespaceManager);

    //Now you have the previous month in "PreviousMonth"

    now you could do something like

    string currentmonth = DateTime.Today.Month;

    // now you got current month

    if(currentmonth != PreviousMonth)
    {
    XPathNavigator somevalue =
    navigator.SelectSingleNode("/my:Form/my:Somefield", this.NamespaceManager);
    somevalue.SetValue("");


    }

  • 01-04-2010 01:10 PM In reply to

    OH Crap! Code!

     Not sure where to add the code, in the get miles button or the clear miles button.

     I am not very familiar with using code in InfoPath but I am also not against figuring it out.

  • 01-04-2010 01:23 PM In reply to

    :) InfoPath isn’t strong with Month, Dates. You would need to add a condition something like field1 is not equal to January. Then you would Add an action and set the field/'s to "". Not sure how you could get the current month on Infopath without code.

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