10 Replies Latest reply on May 26, 2016 7:54 AM by AdamWilden

    Calculation: deliberately do not return any value

    Expert

      Hi Guys,

       

      We have a boolean called "Has this ever been assigned to the Service Desk?" which we want to update after each assignment, and to be sticky if it has been (i.e. don't overwrite if already set to True)...

       

      In other languages I use I can simply use "return" with no following value,  to basically return nothing, but this is still returning false - and I can't find any syntax for Boo to force exit functions.

       

      Any idea how I can get past this?

       

      Basically I have a function on a boolean, that I want to be written to only if the existing value is either null or false.  I initially thought the following would work:

       

      import System

      static def GetAttributeValue(Incident):

        if Incident._CurrentAssignedGroup == 'Service Desk':

          return true

       

      but it seems to be automatically returning false when the If-condition is not met.

       

      So I tried:

       

      import System

      static def GetAttributeValue(Incident):

        if Incident._CurrentAssignedGroup == 'Service Desk':

          return true

        else:

          return

       

      but same thing.  Ive tried a number of variations based on .net or Python but no joy.

       

      I've also a self-checking condition, but of course this suffers from the same issue...

      e.g.

       

      import System

      static def GetAttributeValue(Incident):

        if Incident._HaveServiceDeskworkedonthis != true:

           if Incident._CurrentAssignedGroup == 'Service Desk':

               return true

           else:

               return

        else:

          return

       

      On the plus side, I can be lazy and deliberately return a value that I know will fail the calculation:

       

      import System

      static def GetAttributeValue(Incident):

        if Incident._CurrentAssignedGroup == 'Service Desk':

          return true

        else:

          return "VoidyMcVoidVoid"

       

      And this actually works fine for my purposes - but it is poor programming and, I imagine,  may have some overhead?

       

       

      Any ideas or comments on the best way forward?

       

      (BTW - As you've probably spotted this example is to show if a ticket has ever been assigned to the Service Desk.  I know I can simply loop through all existing assignments to see if any of them are "service desk", but I'm trying to minimise performance impact, and we also want to do this for other attributes that aren't collections).

       

      Thanks.