7 Replies Latest reply on Sep 12, 2018 3:19 PM by ChadL

    How can I set a Category "FullName" with a string via a calculation?

    ChadL Apprentice

      I'm looking to set the Category.FullName with a text string via a calculation, as I'm getting the equivalent of the FullName from another source.

       

      import System

      static def GetAttributeValue(Request):

           CAT = Request._DOC5600Category

           Value = ????????

           return Value

       

      CAT is a string.

      Value calculation using CAT is what I'm looking for.

       

      The GetNamedObject will return the Named attribute, but I need the FullName.

        • 1. Re: How can I set a Category "FullName" with a string via a calculation?
          Julian Wigman ITSMMVPGroup

          ChadL

           

          Value = CAT._Fullname

           

          Julian

          MarXtar Ltd

          • 2. Re: How can I set a Category "FullName" with a string via a calculation?
            ChadL Apprentice

            Maybe I need to better explain what I'm after:

             

            I'm getting a string value from another source, which is the same string value as Request.Category.FullName.

            For example, if my the other source string value is Hardware - Printer, how can I use that value and set the Category field on the Request window?  This string value will change, so I thought a calculation on the window in my Request process was the best way to set it.

             

            Example of the Category Hierarchy:

            >Hardware

            -->Printer

            -->Montitor

            -->Workstation

             

            Each of these are a 'Title' on their own within the Category Object, but the FullName of each is: 

            Hardware - Printer

            Hardware - Monitor

            Hardware - Workstation

            • 3. Re: How can I set a Category "FullName" with a string via a calculation?
              Julian Wigman ITSMMVPGroup

              You just need to user the function GetObjectByAttribute with this attribute being “_fullname” and the lookup value being the fullname from the other category.  This will give you an object reference and you can simply return this.

               

              Julian

              MarXtar Ltd

              • 4. Re: How can I set a Category "FullName" with a string via a calculation?
                ChadL Apprentice

                When I use the following, the Value is always null.  The value of CAT is either "Hardware - Printer" or "Hardware - Mobile Phone" on the two Requests I'm running the calculation against for testing.

                 

                import System

                static def GetAttributeValue(Request):

                   CAT = Request._DOC5600Category

                   return Request.GetObjectByAttribute("RequestManagement.Category","FullName",CAT)

                 

                 

                In the SQL database:  (thought this my be useful to know)

                SELECT TOP 1000 [rm_guid]

                      ,[rm_parent_guid]

                      ,[rm_title]

                      ,[rm_full_name]

                  FROM [LDSD].[dbo].[rm_request_category]

                  where rm_guid = '59F8CBDD-2E65-48BE-B3CD-5224F05E5A68' or rm_parent_guid = '59F8CBDD-2E65-48BE-B3CD-5224F05E5A68'

                  order by rm_title

                 

                 

                Resulting table values:

                 

                What's strange is if I use the following, it appears to be validating against "Hardware - Printer", but will only return "Printer".  If I misspell Hardware, it will fail to a null value.

                return Request.GetObjectByAttribute("RequestManagement.Category","FullName", ("Hardware - Printer")

                • 5. Re: How can I set a Category "FullName" with a string via a calculation?
                  Jamie Cannon ITSMMVPGroup

                  Try this.  You want to make sure you get down to the string level of your category.  The way you had it seemed to be pulling the guid since you were stopping at Request._DOC5600Category.

                   

                   

                  import System

                  static def GetAttributeValue(Request):

                     CAT = Request._DOC5600Category.Full_Name

                     return Request.GetObjectByAttribute("RequestManagement.Category","FullName",CAT)

                   

                  See what this code returns for you.

                  • 6. Re: How can I set a Category "FullName" with a string via a calculation?
                    ChadL Apprentice

                    DOC5600Category is a string attribute on the Request BO, so there can't be a Request._DOC5600Category.Full_Name.

                    • 7. Re: How can I set a Category "FullName" with a string via a calculation?
                      ChadL Apprentice

                      I knew Categories was a different animal and I discovered you have to use Title to get the FullName of a Category to populate the field.  Here's an example of what I'm using in the Request process to populate the Category on the Request Window:

                       

                      import System

                      static def GetAttributeValue(Request):

                         Value = null

                         CAT = Request._DOC5600FulfillmentSubType2

                         NewCategory = Request.GetObjectByAttribute("RequestManagement.Category","Title", CAT)

                         if Request._DOC5600FulfillmentSubType2 != null:

                             Value = NewCategory

                         return Value