Custom coding not apply for inserted new row from browser enable form. - InfoPath Dev
in

InfoPath Dev

Custom coding not apply for inserted new row from browser enable form.

Last post 08-20-2010 06:23 AM by mgarant. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-17-2010 11:51 PM

    Custom coding not apply for inserted new row from browser enable form.

    Hello ,

    First thanks to all, It have been always helpful for me to get my problem's solution from Infopath Dev. 

    Now i have issue regarding to custom codding in browser enable form.

    I have created on browser enable form and done some custom coding on field Age. I get this age from SharePoint  List by passing argument first name and last name. Store this age into int type variable and calculation done based on age and grade displayed to infopath control Grade(TextBox). 

    When i insert new row from browser enable infopath then this calculation not done for new row.(Repeating section). Please any help highly appreciate.

     

    Thank you in advance.

    Bhavin A Sankhat
    Filed under:
  • 08-18-2010 05:53 AM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

    Try to set your changed event on the repeating section instead of on the control.

  • 08-18-2010 06:08 AM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

     Thanks for your reply, Could you please tell me repeating control event for insert new repeating section?

    Bhavin A Sankhat
    Filed under: ,
  • 08-18-2010 06:16 AM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

    What I meant is put your calculation code in the changed event of your repeating section instead of putting it in the changed event of your name dropdown box.

    You will probably have to set conditions in your code so the code will trigger only if there are values in your drop down boxes.

    It will look like this:

    if(yourdropdown is not blank)
    {
         Do your calculations
    }

  • 08-18-2010 10:07 PM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

     I have done the same thing. But when i insert new row from infopath form it take old value.(e.g. if i select first name and last name different then first row then the age value will be given old one(first row)). i have debug my code. all the function working fine but only value not get updated.

    Take a look of my drop down function.

    public void ddlCostCenter_Changed(object sender, XmlEventArgs e)
            {
                ExpenseCode = "";
                CostCode = "";
                FundCode = "";
                Milage = 0;
                // Write your code here to change the main data source.
                XPathNavigator elementddlCostCenter = this.MainDataSource.CreateNavigator().SelectSingleNode("//my:myFields/my:group1/my:group2/my:ddlCostCenter", this.NamespaceManager);

                ddlCostCenter = elementddlCostCenter.Value;

                if (ddlDepartmentToCharge != null && ddlDepartmentToCharge != "" && ddlDepartmentToCharge != "Select department to charge...." && ddlCostCenter != null && ddlCostCenter != "" && ddlCostCenter != "Select cost center..")
                {
                    //assignValue(ddlDepartedFrom, ddlArrivalAt);
                    //getMileage(ddlDepartmentToCharge);
                    string DeptCode = getDepartmentCode(ddlDepartmentToCharge);
                    string CostCodeLocal = getCostCenterFundCode(ddlCostCenter);
                    string FundCodeLocal = getCostCenterFund(ddlCostCenter);
                    string ExpenseCodeLocal = "6410";
                    string AccountCode = FundCodeLocal + DeptCode + CostCodeLocal + ExpenseCodeLocal;
                    DataRow _row = PayoutAccountSummary.NewRow();
                    _row[0] = AccountCode;
                    PayoutAccountSummary.Rows.Add(_row);
                }
            }

     

    Please suggest i am stuck here and nothing find that can help me. 

     

    Bhavin A Sankhat
    Filed under:
  • 08-19-2010 05:59 AM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

    Ok, put this code on the OnChanged event of the repeating section and delete it from the event of your drop down.

  • 08-19-2010 11:15 PM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

     But i have some calculation based on the dropdown and fill into text box. e.g. Total and code fill based on selected value from drop down.

    If i write this code into repeating section Change event then the problem is: Any changes in first row after insert new repeating section will not effect. Please suggest.

    Thank you.

    Bhavin A Sankhat
    Filed under:
  • 08-20-2010 06:23 AM In reply to

    Re: Custom coding not apply for inserted new row from browser enable form.

    In fact, the onChanged event of a repeating section (or table) will be triggered when ANY of the fields inside it is changed. So if you change your selection in the first row of your repeating section, the calculation will trigger. But you need to put a relative XPath instead of the full XPath (eg : \my:dropdown instead of \my:myFields\my:ReapeatingSection\my:dropdown)

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