How to do it...

To create a role, follow these steps:

  1. Choose to add a new item to the project.
  2. In the Add New Item dialog, select Data Model from the left-hand list and Query from the right.
  3. Enter ConVMSVehicleTruckPolicy in the Name field and click on Add.
  4. In our new query, drag the ConVMSVehicleTable table to the Data Sources node.
  5. Set the Dynamic Fields property to No and then add the VehicleType field to the Fields list by right-clicking on the Fields node and choosing New | Field.
  6. Drag the field onto the Ranges node.
  7. On the new VehicleType range, change the Value property to Truck.
When deployed, this will be updated for us. We can also use the enum's value as the type is not extensible.
  1. Save and close the query designer.
  2. In the Add New Item dialog, select Security from the left-hand list and Security Policy from the right.
  3. Enter ConVMSVehicleTruckPolicy in the Name field and click on Add.
  4. Set Label to Vehicle management clerk vehicle table truck access policy.
  5. Set Help Text to Restricts access to the vehicle table so that only trucks can be selected.
  6. Set Primary Table to ConVMSVehicleTable. This tells Operations the name of the primary table in the Query property.
  1. Enter ConVMSVehicleTruckPolicy into the Query property.
  2. Leave Use Not Exist Join as No. Otherwise, this would have the effect of making the policy allow inactive vehicles only.
  3. Set Constrained Table to Yes to state that this table's records will be constrained by the policy.
  4. Leave Operation as Select; we intend this policy to come into effect when selecting records.
  5. While implementing the Creating security roles recipe, create a role for a Truck service entry clerk called ConVMSVehicleTruckServiceClerk.
  6. Now, on the security policy, set Context Type to RoleName and enter ConVMSVehicleTruckServiceClerk in the Role Name property.
  7. Finally, set the Enabled property to Yes.