Summary

This article covers the count command. 


Description

This command returns the number of occurrences of forms for the “parent” specified. If the “type” attribute is specified, it will only count forms of that type. This command is useful if you need to assign a number or letter to a field on a dynamic form based on how many forms are already entered. This command could also be used to determine which type of form to insert if you are alternating forms that need to be inserted.

Attributes

  • none

Parameters

  • parent – provided as a form
  • type – provided as a string


Note: If you are counting dynamic forms and you are doing the count on a specified form, it will count the existing form. So if you are assigning a value to a field on dynamic forms, the count will be 1 when saving the first dynamic form. If you no dynamic forms are already present (you are not counting FROM the dynamic form) the count will be 0.


Example with “type” (Lines 15-22)

<script scriptId="set-mri-lesion-num">
  <body>
    <s:if>
      <s:not>
        <s:isSet>
          <s:question>
            <s:question path=".mrisnum" />
          </s:question>
        </s:isSet>
      </s:not>
      <s:assign>
        <s:question path=".mrisnum" />
        <s:toString>

            <s:count>
              <s:parent>
                <s:form path="/baseline/mri" />
              </s:parent>
              <s:type>
                <s:string value="mris" />
              </s:type>
            </s:count>

        </s:toString>
      </s:assign>
    </s:if>
  </body>
  <target typeId="mris" when="after" shouldReconcile='true' />
</script>

Example (Lines 19-23, 42-46, 59-63, 90-94, 107-11)

<script scriptId="AddAdditionalCycles">
    <body>
        <s:if>
            <s:and>
                <s:ne>
                    <s:numberPath path=":id"/>
                    <s:numberPath path="/cycle8/d15c8/restageSumd15c8/
                    restaged15c8.addCyclinf:id"/>
                </s:ne>
                <s:eq>
                    <s:numberPath path=":value"/>
                    <s:number value="1"/>
                </s:eq>
            </s:and>
            <s:if>
                <s:eq>
                    <s:mod operator="%">
                    
                        <s:count>
                            <s:parent>
                                <s:form path="/addCycleContainer"/>
                            </s:parent>
                        </s:count>
                        
                        <s:number value="2"/>
                    </s:mod>
                    <s:number value="0"/>
                </s:eq>
                <s:createForm>
                    <s:parent>
                        <s:form path="/addCycleContainer" type="form"/>
                    </s:parent>
                    <s:type>
                        <s:string value="cycleOdd"/>
                    </s:type>
                    <s:name>
                        <s:concat>
                            <s:string value="Cycle "/>
                            <s:toString>
                                <s:add operator="+">
                                
                                    <s:count>
                                        <s:parent>
                                            <s:form path="/addCycleContainer"/>
                                        </s:parent>
                                    </s:count>
                                    
                                    <s:number value="9"/>
                                </s:add>
                            </s:toString>
                        </s:concat>
                    </s:name>
                    <s:alias>
                        <s:concat>
                            <s:string value="cycle"/>
                            <s:toString>
                                <s:add operator="+">
                                
                                    <s:count>
                                        <s:parent>
                                            <s:form path="/addCycleContainer"/>
                                        </s:parent>
                                    </s:count>
                                    
                                    <s:number value="9"/>
                                </s:add>
                            </s:toString>
                        </s:concat>
                    </s:alias>
                    <s:allowDuplicates>
                        <s:eq>
                            <s:number value="1"/>
                            <s:number value="1"/>
                        </s:eq>
                    </s:allowDuplicates>
                </s:createForm>
                <s:createForm>
                    <s:parent>
                        <s:form path="/addCycleContainer" type="form"/>
                    </s:parent>
                    <s:type>
                        <s:string value="cycleEven"/>
                    </s:type>
                    <s:name>
                        <s:concat>
                            <s:string value="Cycle "/>
                            <s:toString>
                                <s:add operator="+">
                                
                                    <s:count>
                                        <s:parent>
                                            <s:form path="/addCycleContainer"/>
                                        </s:parent>
                                    </s:count>
                                    
                                    <s:number value="9"/>
                                </s:add>
                            </s:toString>
                        </s:concat>
                    </s:name>
                    <s:alias>
                        <s:concat>
                            <s:string value="cycle"/>
                            <s:toString>
                                <s:add operator="+">
                                
                                    <s:count>
                                        <s:parent>
                                            <s:form path="/addCycleContainer"/>
                                        </s:parent>
                                    </s:count>
                                    
                                    <s:number value="9"/>
                                </s:add>
                            </s:toString>
                        </s:concat>
                    </s:alias>
                    <s:allowDuplicates>
                        <s:eq>
                            <s:number value="1"/>
                            <s:number value="1"/>
                        </s:eq>
                    </s:allowDuplicates>
                </s:createForm>
            </s:if>
        </s:if>
    </body>
    <target action="update" typeId="addCyclinf" when="after" shouldReconcile='true' />
</script>



Need more help?

Please visit the Fountayn Contact Information page.