7 Replies Latest reply on Oct 10, 2014 5:20 AM by gquincy

    looking for string replacement in incident title

    gquincy Apprentice

      We use a script within our email-server to append the e-mail alias into the title of an incident.

      example:

      e-mail alias:     software@servicedesk.de

      title before:     problem xyz

      title after:        problem xyz #software@servicedesk.de#

       

      This text between the ## is used to automaticaly set a category which the incident is forwarded to.

      This works well!

       

      But everytime a note is added to the incident, an e-mail is sent adding an additional "##" entry to the title.

      So I would like to delete the "##" entry from the title after it has been evaluated.

      I wrote a script which should replace the ## and the including text by an empty string.

       

      This is the script:

      import System

      static def GetAttributeValue(Incident):

          Value = null

          IncidentTitleLower = Incident.Title.ToLower()

          Value = IncidentTitleLower.Replace(/#.*#/,"")

          return Value

       

      It is the calculation of the title.

       

      The RegExp should be ok as this Check shows:

      RegExpCheck.jpg

       

      But the title has not been changed.

       

      Could you please help?

      Regards, George

        • 1. Re: looking for string replacement in incident title
          Stu McNeill Employee

          Hi George,

           

          I'm not sure why that calculation wouldn't work, but I'm more concerned your incident title keeps getting updated when an update email comes in.  In your mail mappings how many ticks do you have on the Subject mapping to Title?  Generally you should just have one green tick, but you can also configure it to show a red tick as well.  That means it will updated the title when an update email comes in.  Right-click on the mapping and you can change it to only "Creation" rather than "Both".

           

          Thanks

          Stu

          • 2. Re: looking for string replacement in incident title
            gquincy Apprentice

            Hi Stu,
            thank you for your quick answer.

            The incident title will only be changed for a very short time, if everything is working as it is supposed to.

            The mail server will append the "alias address" to the title, enclosed by "#".

            The ServiceDesk process will read this an accordingly will set a category to the incident and then remove the appendix enclosed by "#".

            After that the title has the same value than before.

             

            Im sorry but I cannot understand what you mean with "In your mail mappings how many ticks do you have on the Subject mapping to Title?"

            What do you mean with "ticks"?

            Here are some screenshots from our E-mail setup:

            E-Mail_Setup_140909.jpg   E-Mail_Mappings_140909.jpg

             

            And the action on the "Subject" is "Creation" only.

            E-Mail_Actions_140909.jpg

             

            Does this mean that the process will check the titel/subject only during creation of an incident?
            So it will not be checked when an e-mail comes in because notes added to the ticket or answers to notification mails?

             

            Friendly regards,

            George

            • 3. Re: looking for string replacement in incident title
              Stu McNeill Employee

              Hi George,

               

              Your mapping looks OK, the "Subject" mapping only has the green tick so it will only be set when a new incident is created.

               

              Where is your calculation in all of this?

              • 4. Re: looking for string replacement in incident title
                gquincy Apprentice

                Hi Stu,

                here is the beginning of our incident process.

                in the green box above red circle, where it says "setze Kategorie", we set the category from the alias of the e-mail.

                In the green box within the red circle I try to remove this entry from the title:

                LDSD_Process-Incident_-_Remove_Alias_from_Title.jpg

                 

                After dubble clicking on the green box (within the red circle), the incident windows opens:

                 

                LDSD_Process-Incident_Windows_-_Remove_Alias_from_Title.jpg

                And there in the control for the title I added the calculation (I posted above).

                 

                Thanks for keeping trying to help!

                Friendly regards,

                George

                • 5. Re: looking for string replacement in incident title
                  Stu McNeill Employee

                  Hi George,

                   

                  Thanks a lot for that information.  I completely misunderstood what you were doing but all is clear now

                   

                  Looking back at your original post the syntax for doing a regex replace doesn't look right and chances are the calculation is failing because of that.  Does it work if you use the "Test Calculation" button in the calculation editor?

                   

                  Here is a version I just tested successfully:

                   

                  OldValue = "text to keep#text to lose#"
                  NewValue = System.Text.RegularExpressions.Regex.Replace(OldValue, "#.*#", "")
                  return NewValue
                  

                   

                  Thanks

                  Stu

                  • 6. Re: looking for string replacement in incident title
                    gquincy Apprentice

                    Hi Stu,

                     

                    I have been on holidays. That's why I answer this late.

                     

                    I tried your formular, but I get this error message via e-mail:

                     

                         Die Prozess-ID 2 für den Prozess LOH Services Incident 3.1 war ungültig.

                     

                    english Translation:

                         The process-D 2 for process LOH Services Incident 3.1 was invalid.

                     

                    And yes, now I tested my formular and it did not work.

                    Your formular works in the test, but produces the e-mail message above.

                     

                    Any idea?

                     

                    Thanks,

                    George

                    • 7. Re: looking for string replacement in incident title
                      gquincy Apprentice

                      Sorry for confusion:

                       

                      my error e-mail: Die Prozess-ID 2 für den Prozess LOH Services Incident 3.1 war ungültig.

                       

                      had another reason.

                       

                      I use your formular now and it works fine!

                       

                      Thanks alot!!!!

                       

                      Regards,

                      George