Date - InfoPath Dev
in

InfoPath Dev

Date

Last post 05-05-2006 06:24 AM by Fast Flare. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 05-01-2006 08:37 AM

    Date

    Hello everybody,
    I have a date control in a repeating table. Each time a row is inserted, it needs to automatically populate the date control in that row to the next day. What is the best way to do this?
    Also, is there any way to limit the rows a user can insert into a repeating table? I would only like to allow the user to insert 3 rows max.
  • 05-01-2006 09:33 AM In reply to

    You need to set the Date value in the OnAfterChange event of the Row.

    You should set the Date value only when "e.Operation" == "Insert" and e.Source.NodeName == "ROWNODENAME"(the node on which you have the OnAfterChange Event.

    For the second question, yes you can limit the Max rows by editing the Schema. Open the Schema locate the node and set MaxOccurs="3".
  • 05-01-2006 11:07 AM In reply to

    Hellp Agni,
    I am having trouble reattaching the schema file to the form after editing it. I keep getting this message: "The namespacehttp://schemas.microsoft.com/office/infopath/2003/myXSD/2004-05-11T14:31:09 is reserved for nodes created by InfoPath". This schema was generated by InfoPath originally, do I have to change the namespace to be able to replace the current schema with the updated one? Or is there another way I can set the "minOccurs/maxOccurs" in the form itself? I've done this manytimes with an outside data source from a data base; does InfoPath create a different kind of xml file? Thanks in advance for any suggestions you might have!
  • 05-01-2006 10:25 PM In reply to

    Hi, You need to edit your existing schema, you need to extract you files and edit the Schema. You dont need to reattach your schema it will get automatically affected after you edit it.

    Open the schema and go to the line where your repeating node is referenced and set maxOccurs to '3'
    Before
    <xsd:element ref="my:YOURREPEATINGNODENAME" minOccurs="0" maxOccurs="unbounded"/>
    After
    <xsd:element ref="my:YOURREPEATINGNODENAME" minOccurs="0" maxOccurs="3"/>
  • 05-04-2006 06:47 AM In reply to

    Hi Agni,
    I can successfully edit the schema, but when I test the form I get an error message when the user tries to insert a fourth row in the repeating table that I have set the maxOccurs in. Is there any way to turn off or change the dialog box when this happens?
  • 05-04-2006 01:05 PM In reply to

    You could implement an OnBeforeChange event handler that counts the number of rows that are already in the form, and then if it is greater than 4, cancel the insert.

    I would think this would be a slightly easier way of doing it instead of modifying the schema. Although it does use code and Agni's solution doesn't.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-04-2006 02:48 PM In reply to

    Hello,

    of course you can use Matt´s suggestion for counting the number of rows in a repeating table. I have found another way of limit the number of rows. You can use the 'position' attribute of your repeating table as I will show you in the following example:

    var repeatingTable = XDocument.DOM.SelectSingleNode(//my:repeatingTable[position() = 3]);
    if (repeatingTable != null) // it s true when you try to add the 3th row
    {
    e.ReturnStatus = false;
    e.ReturnMessage = "Max three rows...";
    }
    BTW: You can use this even if you want to force the user to insert at least one row minimum in a repeating table with the following check:
    var repeatingTable = XDocument.DOM.SelectSingleNode(//my:repeatingTable[position() = 1]);
    if (repeatingTable == null) // it s true when you try to add the 3th row
    {
    e.ReturnStatus = false;
    e.ReturnMessage = "One row at least...";
    }
    All should be done in the OnBeforeChange event!

    Hope that helps...
    Karsten
  • 05-05-2006 12:40 AM In reply to

    In this case also "ReturnMessage" is thrown as an error message to the user. Instead I would suggest the Schema change.
  • 05-05-2006 06:24 AM In reply to

    Thanks for being so helpful everyone! It works!
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.