Allow the users to insert a row in repeating table based on condition evaluation.
- Select the repeating table, right click on it to open up context menu.
- Click on “Repeating Table Properties…” > “Display Tab” > “Conditional Formatting…” button. It will open up “Conditional Formatting” dialog.
- Click on “Add…” to open up “Conditional Format” dialog.
- Select the condition and check “Don’t allow user to insert or delete this control” as shown in the image below.
- Click OK button on every open dialog.
- Now preview the form. Based on evaluated condition, clicking on “Add Employee” will either allow or don’t allow you to insert a new row.
Above mentioned solution does not hide the command text “Add Employee” so user may try to click on it but nothing happens. The problem is to hide a command text.
Solution requires manual xsl file editing. Follow the steps to manually change xsl to show/hide command text based on the condition.
- Open the form into design mode. Click on File > “Save As Source Files…” (InfoPath 2007) which will save individual source files.
- Open the appropriate view file in text editor. The file extension will be “.xsl”.
- Locate the code which shows command text. For me, it is
<div xd:xmlToEdit="group2_1" xd:action="xCollection::insert">Add Employee</div>
- Now add a conditional “style” attribute to it. so the resultant code will look like
<div xd:xmlToEdit="group2_1" tabIndex="0" xd:action="xCollection::insert"> <xsl:attribute name="style"> <xsl:if test="my:AllowInsertion = string(false())">DISPLAY:None;</xsl:if> </xsl:attribute> Add Employee</div>
- In the above code you have to change the <xsl:if> test attribute to your condition
- Save the file, open the form in design mode by right clicking on “manifest.xsf” file and click on “Design”.
Now when you preview the form, it will look like this
Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1’s and 0’s from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.