Disable deafualt value formula of a text field with a condition. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Disable deafualt value formula of a text field with a condition.

Last post 05-15-2019 07:54 AM by Hilary Stoupa. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 05-10-2019 06:13 AM

    Disable deafualt value formula of a text field with a condition.

    Dear Brilliant minds,

    Save me from this problem please,

    I have a text field with default value set with a formula, And its value also dependent on a option button(option1 ) value.

    If option button chosen as 'Auto[1]' : Text box will be disabled and value 100 will be assigned.

    If option button chosen as 'Manual[2]' : Text box will be enabled and value 200 will be assigned. But here user will be able to enter a new value as they like.

    Problem: Assume that user chosen option button as 'Manual[2]' and changed the assigned value 200 to 300 then submitted the form.

    When we reopen the form the default value formula will run again and the actual saved value 300 will changed to 200. 

     Note: I already tried disabling 'Refresh when formula is recalculated' - but there are some calculation to be done in new form which needs re calculation.

    The solution I nearly succeeded with is - Giving an extra field(RunFormula) with Boolean values and setting it to TRUE when ever I needed to run default formula,

    But here the issue is - I expect to get the saved value in field when whole conditions are failed but I get empty field. (See below formula)

    concat(substring(SendAmount * (field353), 1, (currYear = sendValidYear and option1 = 1) * string-length(SendAmount * (field353))), substring(SendAmount * (1 / 12), 1, (currYear < sendValidYear and option1 = 1) * string-length(SendAmount * (1 / 12))), substring(0, 1, (option1 = 2 and monthsOfSap > 1 and currYear = sendValidYear and RunFormula = "1") * string-length(0)), substring(SendAmount, 1, (option1 = 2 and monthsOfSap = 1 and currYear = sendValidYear and RunFormula = "1") * string-length(SendAmount)), substring(SendAmount, 1, (option1 = 2 and currYear < sendValidYear and RunFormula = "1") * string-length(SendAmount)), substring(0, 1, (sendValidYear = "" and option1 = 1) * string-length(0)))

    So when I got empty in text field when all conditions fails, I added below condition to the default value.

    substring(., 1, (option1 = 2 and RunFormula = "0") * string-length(.)), [assigning the text field value itself when 'RunFormula' is 0] 

    This returned the error 'The number of calculations used for a single action exceeded the maximum limit' even I got the error some of the values came right and others are blank.(I have 12 fields with same setup)

     

    Sorry for the large content, But I really need your help.

     

    Cheers,

    Christy 

      

     

  • 05-10-2019 09:25 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Ok - so given that you want this set to a value but then also want to allow the user to overwrite that value in some circumstances, I would say you definitely do not want to use a default value here. Instead, you need to place rules on all the fields involved in the calculation that set this field. I'm confused, though, about several things. If the logic is as simple as "radio button = Auto, set to 100 : radio button = Manual, set to 200" what is the complex default value for? Or is that formula not for the same field you are currently concerned with? Sorry - I got a bit lost here. Any chance I can see your form, or a simplified example that shows the scenario? You can attach a template in a reply under the Options tab.
    Hilary Stoupa

  • 05-11-2019 11:50 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Hi Hilary, Thanks for the look on the issue, Clarifying your questions, No I cant write rules for this control because this field is in a repeated table. And logic is not that simple, Form have one repeated table with 13 fields. 1 amount field and others stands for months (Jan to December). Logic is that if user selected auto option then the amount user gives should be auto split to 12 months(split depend on some other field values in the form too) If option is manual user can manually split the amount. The same way this repeated table will have multiple rows, So this is the reason why I cant write rules for set field(Or can I?) I could give you a sample form on Monday if you want. Thanks again for your time.
  • 05-13-2019 06:45 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

     Hi Hilary,

    Please see a sample form which explains the scenario.

    Problem we faced: once user done manual splitting, when user reopen the form to edit, manual split will get cleared and value will stored with the default formula which I don't want.

    I'm kinda new to InfoPath so might be the logic done here can be done easier some other way which might resolve the issue.

    Hope you can help :)

     Cheers,

    Christy 

  • 05-13-2019 08:34 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Thanks for the sample - I'll try to take a look later today and let you know my thoughts.
    Hilary Stoupa

  • 05-13-2019 04:10 PM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Yick. Okay - so I understand the temptation to use substring formulas for conditional values, and sometimes they can be useful, but this seems awfully complicated. It appears that the split is based on the month to start as well as the option button, and then also depends on the year, right? If for "this" year, we pay attention to the month, if for a future year, we don't? And the user can change any of these options after entering data? She can change the Month to start split, the manual split option, the amount or the year? I can see why you wanted to use defaults instead of rules. But InfoPath is not Excel, and trying to create something that looks and works like a spreadsheet will usually lead to tears. I think if you must take this approach, you likely need even more helper fields - you need to track whether you should be setting the field or not based on the user's selection. Perhaps it would be acceptable to design it more like a wizard-style form? So they have to select Auto or Manual when they select the month and they can't change it later? That may make things a little simpler.
    Hilary Stoupa

  • 05-14-2019 06:48 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Yes all your assumptions on the scenario is right. And I know it is complicated, might be my less knowledge in InfoPath leads to this complexity. Do you have any suggestions? We cant do the wizard because the design cant be changed.

    Just repeating the problem we faced: once user done manual splitting, when user reopen the form to edit, manual split will get cleared and value will stored with the default formula which I don't want.  

    If I can add an extra condition like "if(split option = manual) then do nothing" in default value of split fields it might work.. But how to do that.

    I even tried - substring(. , 1, (SplitOption = 'manual') * string-length(.) - Assigning the split value itself in case of manula split. but this returned the error 'The number of calculations used for a single action exceeded the maximum limit' even I got the error, some of the split values came right and others were blank.

     Thanks for your time in this.. 


     

  • 05-14-2019 01:15 PM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    The issue is that the default in the case of manual assigns all the amount to the first month selected in the case of the current year. As long as you use a default, you are going to face the same issue of the value being updated when the user re-opens a saved form. Again, I'd recommend using a rules based approach. What if you had two different sets of fields - one for the "auto" and one for "manual"? Show / hide them based on the user's selection.... and then if they are using "manual" you could set the initial value with rules on all the various controls that may impact the value.
    Hilary Stoupa

  • 05-15-2019 06:33 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Hello Hillary, Thank you very much for this work around it did work.

    But how to set initial values to the field using rules in case of manual split, considering these fields are in repeated control and initial values are various for all rows.

    I though 'set field' in a repeated table can achievable only using default value. Can we use rules for the same?

     Thanks again,

    Christeen 

  • 05-15-2019 07:54 AM In reply to

    Re: Disable deafualt value formula of a text field with a condition.

    Add another helper field to your repeating table - and then you can use logic on it to act on each row individually. So - you have a helper field called "set" for example in your repeating table. You can have an action that sets that field to 1, outside of the repeating table. Then the rules on the "set" field can set the repeating nodes.
    Hilary Stoupa

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