SetControlAttribute example

In this example an agency has added a view action to its Record Inspection Result view. In this case the agency wants to hide the Record Result button, and show Pass and Fail buttons, for its roadway and sidewalk inspection types. The agency also wants to show an In Progress button for certain inspection types.

In each SetControlAttribute node, the ControlId attribute specifies the ID of the button. To show or hide buttons, the Visible attribute is set to true or false. This example uses ConditionExpression attributes to list the inspection types. The view model in this case is CDR_Building_Inspection, so the condition expressions are evaluating the InspectionType property of that model.

<ViewActions>
  <ViewAction Description="Render" Id="Render">
    <Commands>

      <SetControlAttribute ordinal="m" ControlId="btnRecord" 
       Attribute="Visible" AttributeValue="False" Id="HideResultAllButton" 
       ConditionExpression="$.In(ViewModel[&quot;InspectionType&quot;], 
       &quot;Roadway,Sidewalk,EMER_Road,EMER_Side,90DayInsp,90DaySide,
       EMER_90Day&quot;)" />

      <SetControlAttribute ControlId="btnPass"
       Attribute="Visible" AttributeValue="True" Id="ShowPassButton"
       ConditionExpression="$.In(ViewModel[&quot;InspectionType&quot;], 
       &quot;Roadway,Sidewalk,EMER_Road,EMER_Side,90DayInsp,90DaySide,
       EMER_90Day&quot;)" />
      
      <SetControlAttribute ControlId="btnFail" 
       Attribute="Visible" AttributeValue="True" Id="ShowFailButton"
       ConditionExpression="$.In(ViewModel[&quot;InspectionType&quot;], 
       &quot;Roadway,Sidewalk,EMER_Road,EMER_Side,90DayInsp,90DaySide,
       EMER_90Day&quot;)" />
     
      <SetControlAttribute ControlId="btnInProgress"
       Attribute="Visible" AttributeValue="True" Id="ShowInProgressButton" 
       ConditionExpression="$.In(ViewModel[&quot;InspectionType&quot;], 
       &quot;Roadway,Sidewalk,EMER_Road,EMER_Side&quot;)" />
 
   </Commands>
  </ViewAction>
</ViewActions>

The Pass, Fail, and In Progress buttons are also defined by the agency. The XML for the In Progress button is shown below. Note that the OnClick attribute is set to ResultByButtonTag. This method will add the result code specified by the Tag attribute to the inspection. The Tag attribute must match an existing result code in Infor Operations and Regulations.

<Button OnClick="ResultByButtonTag" Visible="False" 
Title="IN PROGRESS" Id="btnInProgress" Tag="In Progress" />