How to automatically set or update values on an incident

Version 9

    Verified Product Versions

    LANDESK Service Desk 7.7.xLANDESK Service Desk 7.8.xLANDESK Service Desk 2016.x

     

     

    Process actions are mostly used to create collection items on an incident such as notes, closures, etc.  However sometimes there is the need for a process to update values on the incident itself.  Examples are to select a checkbox or a pre-defined value for a drop-down list (Response Level, Urgency, Category, etc).  This can also allow collection data previously not available to add directly as a field to the incident window or an incident query to be added for ease of display

     

    There are two methods to achieve this depending on the level of control you need over the attribute(s) you're updating and type of source data.  The first is to use a calculation attribute, the second is using an automatic process action.  This document describes both.  In the examples, we are setting values on the Incident object but the same technique will work on Problems, Changes, Tasks, etc.

     

    Using a calculation attribute

     

    If you want the attribute to appear read-only on the incident window and only ever be updated automatically you can create a calculation on the attribute.  The following example will show how to set a String attribute on the incident containing the details of the incident resolution so it is readily available when viewing a closed incident (or a query showing closed incidents).

     

    1. Create the attribute

     

    Within Object Designer open the Incident object for modification and select the New Attribute action.  Name the attribute "Last Resolution Text", set the data type to String with a length of -1.  Lower down in the Properties panel is a section called Formula.  Within this section set the Calculation Type to BeforeSave.

     

    On setting the Calculation Type this will automatically launch the calculation editor.  The formula by default shows 4 lines of code which should not be changed.  From the Attributes tree on the left expand Resolutions and double-click on Description.  This will add the attribute to the calculation formula on the 3rd line to read Value = Incident.Resolutions.Description  Because we're working with a collection and there may be multiple resolutions, we have to add a function in the code to make sure we're getting the most recent (or only) resolution.  To do this we add the Latest() function after Resolutions.  This will make the final calculation look like:

     

    import System

    static def GetAttributeValue(Incident):

      Value = Incident.Resolutions.Latest().Description

      return Value

     

     

    The last step in creating the calculation is ensuring the Dependencies panel on the right of the editor contains the resolutions collection because it is when a resolution is added that we want the calculation to trigger.  If the panel is blank uncheck the Auto-detect dependencies option and type into the field the word Resolutions.

     

    Press OK to save the calculation then click on the Save button to save the new attribute.

     

    2. Add the attribute to the incident window

     

    Once the "Last Resolution Text" attribute has been created it can be added to an incident window as any other attribute would.  Drag the attribute to show multiple lines if required.  You will notice that the attribute is read only and this can't be changed - this is because the only way the attribute can be set or updated is via the calculation.

     

    3. Resolve an incident

     

    From now on when resolving an incident the calculation on the "Last Resolution Text" attribute will be triggered and populated with the resolution text.  If the field remains blank you may need to troubleshoot the calculation.  See this document for advice on this: Calculations Troubleshooting Guide

     

    4. Retrospectively setting the value on previously resolved incidents

     

    The attribute created will only get populated as an incident is resolved, so if you have existing incidents and want to populate the value on these this is possible by temporarily changing the Calculation Type on the attribute to Scheduled, then using Schedule Manager to perform a one-off update.  Note that this is limited though as a scheduled calculation cannot update an incident if it is at a read-only status such as Closed.

     

    Using an automatic process action

     

    To update an attribute at a specific point in the process but don't want the constraints a calculation brings you can use an automatic process action.  The following example will create an automatic action to set a checkbox on the incident called "Major Incident" after a "Declare Major Incident" action is used to create a child record.  The "Major Incident" attribute is a Boolean with a default value of False, and may already exist in your database depending on which version of Service Desk you were originally implemented with.

     

    1. Create the action

     

    You can either create one generic action for updating fields on the incident or one action for the specific job of updating the "Major Incident" attribute.  In this example, I am using a generic action but depending on the complexity of your process you may need to add comments to the process diagram to explain what the action is doing in each case.

     

    To create the action open Process Designer and select the Business Objects panel.  Expand the tree to select Incident Actions, right-click the branch and select New from the menu.  An action created in this way is normally a "windowless" action, ie. the action will move the process as soon as you click it, there is no window to fill in.  On the form that appears on the right name the action as desired, in my case "Update Incident Fields" and ensure the Allow Associate With Window property is set to True as shown below:

     

    creating the action.jpg

    figure 1. how to create the action.

     

    The purpose of this property is to allow you to display an incident window when the action is displayed if it were to be added to the process as a manual action.  This type of action is called (too much confusion!) a "windowed windowless" action.  In the case of an automatic action, it means we can view an incident window when we add the action to the process and values we set on that window are set when the action occurs at runtime.

     

    Depending on when you want to set the fields you may also need to create the action or object that will proceed the automatic action in the process.  In this example, we're using a windowless action called "Declare Major Incident" which already exists in the same way as above but with the property for allowing window association set to False.

     

    2. Create the action window

     

    Before we can add the action to the process diagram we must design a window specifically for it.  This will be an incident window with as few fields on it as possible, ideally only the field(s) the action is going to update.  We also must add the Title attribute because this is a mandatory attribute on the incident object.  Name the window "Update Incident Fields" or similar so we know what it's for.

     

    Once the window is created and saved you must set this as the default window using the Set Default action because when modifying any action in Process Designer the default window is always used.  This only needs to be set temporarily while we're doing the process design, and it's likely your current default window is needed at runtime so make sure you do this work when no user is in the system.  Also, make sure you take a note of which window was already the default (shown as a green tick in the icon next to the window in Windows Manager).

     

    3. Add the action to the process

     

    Within Process Designer open your incident process.  Add a manual action to the diagram and select the "Declare Major Incident" action.  Now add an automatic action and select our new "Update Incident Fields" action.  At this point, the default incident window will appear which should be our "Update Incident Fields" window.  On the window select the "Major Incident" checkbox.  This is the only field we want to set as part of the action but we have to populate the Title field too before we can save the process...

     

    4. Setting a runtime value to Title (Service Desk 7.3.2 and earlier only)

     

    On Service Desk versions prior to 7.4 when creating any automatic action you must set a value for all mandatory fields, however in the case of a windowed windowless action if we set a value for Title this would override the incident's real Title value whenever we perform the action.  We can work around the limitation by setting a runtime value of "Title" to Title.

     

    To do this right-click the Title field on the window and from the right-click menu select Value Type.  This will open the Control Value Selection window.  Select the Specify a runtime value for control option to enable to the tree below, then from the tree tick the box next to Title.  What this does is take the existing Title value and use this to populate the Title field on the action - effectively setting it to itself:

     

    setting runtime value.jpg

    figure 2. setting the runtime value for Title

     

    Press OK to set the runtime value and this will enter the text {Title} into the Title field on the window.  Then press OK to save the automatic action.  Finally link up a status to the manual action, the manual action to the automatic action, then the automatic action back to a status as below:

     

    finished process.jpg

    figure 3. the finished process diagram

     

    5. Expanding on the concept

     

    As well as setting an explicit value as above you could also use runtime values or calculations to set the values you wish.  You could replicate the example used above for a calculation attribute using this method instead by inserting an automatic action after the Resolve action and use a runtime value to populate a field with the text from the resolution window.  You could also use conditions either as decisions in the process diagram or as "if" logic within a calculation to set/not set/set a different value on the criteria of your choice.