5 Replies Latest reply on Mar 5, 2019 1:43 PM by TheBlueNova

    Service Request trigger not firing on Save

    TheBlueNova Apprentice

      Attempting to Create a notification email when a service request's parameters have been modified.

      First attempt was to fire OnLink, however that sent an email for every parameter as they are all dropped and recreated on save.

      Second attempt is to fire OnUpdate of the service request with the following Conditional Expression

       

      $(IsTrueForAllChildren("ServiceReq#", 
        RecId, 
        "ServiceReqParam#", 
        "$(DateDiffSQL('second', CreatedDateTime,  ToString(CurrentDateTime())) < 60)"))
      

       

      This doesn't fire if i only change 1 or more parameters and click save.

      However if i change some other field of the service request, e.g. Description or Fulfillment Comments, then the event fires as expected.

      If i save changes to the parameters, then (within the 60 seconds obviously) make a change to the request and save the event also fires as expected.

      I also tried OnFieldChange Last Mod date time, this also doesn't fire when only changing parameters and saving.

      My Last idea is to have the Request Parameters module change a field on the parent request after save, however i suspect this will fire for each parameter and result in multiple emails, similar to attempt 1.

       

      any ideas?

        • 1. Re: Service Request trigger not firing on Save
          Jonathan.Schmidt SupportEmployee

          Hi TheBlueNova,

           

          I think you could have something push a value up into the Parent object such as marking a boolean true, then your subsequent action would fire your email out and also mark that boolean back to false.  If you do it this way, a single save with multiple Param edits (I think) would all commit at the same time and therefore only fire the trigger on the parent SR boolean once.

           

          Can you try that and let us know?  If that doesn't work, it might be feasible to have some kind of workflow searching for these every hour (I wouldn't go more fequently than that without deep assessment of the performance costs in your environment) and reading the boolean on the SR level via a Run for Search workflow block.

           

          Jon

          • 2. Re: Service Request trigger not firing on Save
            IJU Expert

            Try changin the relationships type from "Associates with" to "Contains". From experience this way every single saved change on the child would always trigger a save on the parent. But if you do this this also deletes all the ServiceReqParam when you delete the Service Request itself.

             

             

            Kind regards

             

            Immanuel Jungheim

            Senior Consultant

             

            ITSM Group – Be Better.

            www.itsmgroup.com

            • 3. Re: Service Request trigger not firing on Save
              TheBlueNova Apprentice

              Hi Jonathan

               

              Ok I've given your idea a go

              1. In ServiceReq created a Boolean field ParamsChanged
              2. In ServiceReqParam Created 2 Triggers
                OnLink to ServiceReqContainsServiceReqParam, RunForChild ServiceReqContainsServiceReqParam "Set ParamsChanged to True"
                OnDelete, RunForChild ServiceReqContainsServiceReqParam "Set ParamsChanged to False"
              3. in ServiceReq created a trigger: OnUpdateField ParamsChanged is changed to True, Send Email notification

              So far it seems to be working, it isn't sending an email when I create a new service request, and it's not sending duplicate emails.

              I'll do some more testing and mark the question as answered.

               

              Thanks

              Jim

              • 4. Re: Service Request trigger not firing on Save
                AlasdairRobertson ITSMMVPGroup

                i have not tested Immanuel's solution of changing the relationship but will do this week. 

                 

                The SRP object does not run business rules correctly from my experience so you cant use them to trigger updates in he SR object.  I did raise this with support a few years ago when we first hit the problem if parameters being updated and notifications required.

                • 5. Re: Service Request trigger not firing on Save
                  TheBlueNova Apprentice

                  Hi AlasdairRobertson
                  I am seeing mixed results with Jonathan's option. will see if I can debug what's going on, but looks like I'll be moving onto Immanuel Jungheim's idea.