Appending Text to a Field Value To Yield Final Result - InfoPath Dev
in

InfoPath Dev

Appending Text to a Field Value To Yield Final Result

Last post 12-22-2011 09:57 PM by cbrown00. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-21-2011 10:18 PM

    Appending Text to a Field Value To Yield Final Result

    I know it is possible to use a rule in a control to set its value by using concatenate function and pulling values from other different controls.

    I'm trying to find a solution where I don't have to set up a different data element just to make the concatenation happen.  So, my question is can you use a rule to set the value in a data element by taking the value entered, but then auto-append text to it so that whenever the field is used, it returns not just the value, but the appended text, too.   I'm wanting to create a field where a time value is entered, say 60, and using a rule to add "sec" to it so that when the data element is referenced later in a report, it will return "60 sec" versus just the "60" shown.   I have tried concat function in a rule for the field to make this happen, but it still only returns the value.. cannot get the text to show up in a report referencing the data element.

     I don't need the result to indicate 60 sec in the form....just for that to be the real value.  Hope this makes sense.

    Filed under:
  • 12-22-2011 11:12 AM In reply to

    Re: Appending Text to a Field Value To Yield Final Result

    It depends where you want to use this appended text in the end.  If the report you mention is simply a read-only InfoPath view, then you can use a Calculated Value control to display your formula.  This control doesn't have to be bound to any field, so you won't have to add an additional temp field in your data source.

    Otherwise, your other option is likely setting a field's value of some temp field.  Hope I understood your scenario correctly :)  If not, feel free to clarify and I'll be more than happy to help out!

    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 12-22-2011 11:30 AM In reply to

    Re: Appending Text to a Field Value To Yield Final Result

    You can accomplish this without a separate field if you add a condition to your rule:

    Condition: (the field) does not contain sec

    Action: Set (the field) to the formula: concat(., ' sec')

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-22-2011 09:41 PM In reply to

    Re: Appending Text to a Field Value To Yield Final Result

    Jimmy:

    After creating rule per your guidelines, I key in a value in the field, it appends the "sec" many times (e.g., 120 sec sec sec sec...) until I get the following error:

    "An error occurred in the form's rules or code. The number of rule actions or the number of calls to the OnAfterChange event for a single update in the data exceeded the maximum limit.

    The rules or code may be causing an infinite loop. To prevent this, ensure that the rule action or event handler does not update the data which causes the same rule action or event handler to execute."

    I checked the box in the rule to stop processing after the rule is run, but I get the same result.  Any guidance on what's going on and how to just get one cycle?

    Filed under:
  • 12-22-2011 09:57 PM In reply to

    Re: Appending Text to a Field Value To Yield Final Result

    Update:

    Not sure what I was doing wrong before;  but re-entered and it is working.  I must have entered different key strokes in condition section versus formula section.

    Thanks!

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