Forms Expert - Setting a Colour Code Field

Often you may wish to have a Colour Code in a View maintained automatically by
Commence. This can be useful to help you prioritise data and activities, or alert you to
information that need to be acted on.
In the previous section "Technical Desk - Colour Coding
your Views" we explained how the Commence RM: Australian Edition uses Colour
Coding to display the status of Help Desk incidents. This is done through a combination of
Agents and Scripting in Forms.
Agent - Escallated Incidents
Although Agents do not strictly come within the scope of our "Forms Expert",
it does make sense to explain how this works with the scripting that sets the other colour
codes.
Before automatically setting the colour codes, it is important to understand the logic
of what you are trying to do. In this case, when ever the incident is more than a given
number of days old and still open, we always want to show it as escallated (regardless of
engineer assigned, follow up calls, etc). We want this to happen automatically, say on a
daily basis, so an Agent is a good solution.
The Agent is configured as follows:
Trigger - Timer - daily at 6am
Condition - Item Count on Incident Category
for more than 0 Items, filtered on Escalate Date
before tomorrow and Date Closed is Blank.
This agent would normally not be shared and would only run on the Commence Server. The
changed incident will then be synchronised to all Commence clients.
VBScript - Setting the Colour Code
We could have a series of Agents to set the Colour Code to other values - but it
quickly becomes confusing, and in some cases there may be conflicts leading to
unpredictable results. It turns out to be more efficient to set the colour code using
VBscript.
Again, the first step is to determine the logic of what you want to do:
If no engineer is assigned to the incident
- set the Colour Code to "No Engineer"
If there has not been any follow up
- set the colour code to "No Follow Up"
If the incident has been closed
- set the colour code to "Closed"
If none of the above conditions are met, and the incident is not closed
- set the Colour Code to Open.
A good time to run this is when the Incident is saved, so we put this in the
Form_OnSave event:
Sub Form_OnSave()
If Form.Connection("employee","Employee").ConnectedItemCount = 0 Then
Form.Field("Colour Code").Value = "No Engineer"
Exit Sub
End
If
If Form.Connection("has","Follow Up").ConnectedItemCount = 0 Then
Form.Field("Colour Code").Value = "No Follow Up"
Exit Sub
End
If
If Form.Field("Date Closed").Value
<> "" Then
Form.Field("Colour Code").Value = "Closed"
Exit Sub
End
If
If Form.Field("Date Closed").Value
= "" Then
Form.Field("Colour Code").Value = "Open"
Exit Sub
End
If
End Sub
As you can see this is a very easy solution to automatically set the Colour Code. For
added control you could choose to disable manual editing of the Colour Code by using the
"CantGoHere" function, described in a previous issue of CRMtimes. |