2 Replies Latest reply on Feb 11, 2019 9:43 AM by rrmarlatt

    Number of characters in a string

    rrmarlatt Apprentice

      Drawing a blank.

      Trying to write a calculation to see if a users phone number is equal to 5 characters. If it is just return true.

       

      Thank you.

        • 1. Re: Number of characters in a string
          Jamie Cannon ITSMMVPGroup

          Hey Rob,

          Assuming it's formatted as a string, you could try this.  This will also take into account spaces and ( ) but if you are just mapping in like an extension, should be good to go.

           

          import System

          static def GetAttributeValue(Incident):

              Value = false

              Phone = null

              PhoneLen = 0

             

              if Incident.RaiseUser != null:

                  if Incident.RaiseUser.Phone != null:

                      Phone = Incident.RaiseUser.Phone

                      PhoneLen = Phone.Length

                     

              if PhoneLen == 5:

                  Value = true

                 

              return Value

          • 2. Re: Number of characters in a string
            rrmarlatt Apprentice

            Thanks Jamie!