5 Replies Latest reply on Mar 9, 2017 1:23 AM by lgtandi

    Notification Quick Action functions

    wynnb Apprentice

      OK, here's one for you Function wonks out there.

      I have a request offering that is basically an order form for several items. There is a text field parameter for each item that asks for a quantity. When a non-manager submits this, I need to send an approval to their manager - so far, so good.


      I want the approval notification to indicate each item and the quantity that the person ordered (so the manager knows what they are approving). I know how to add a given parameter to a notification, but the problem here is that there are many parameters in the offering, and I only want the email to list the ones that have a quantity (a list of what was actually ordered).


      I tried using:

      $(GetSRPValue([FRS_Approval#.][ServiceReq#.]RecId, "ServiceRequestParameters"))

      but that doesn't do anything - even if it did, I don't want ALL the parameters, just the ones with a qty value.


      So. Does anyone know how I could write the function to list all parameters that are not null in an email? Would I have to do a long If-Then-Else string? Is there a shorter/cleaner way?


      Thanks in advance-



        • 1. Re: Notification Quick Action functions
          florian1 Expert

          How many items do you have that may have a quantity amount?
          If it's only a few you might as well use a nested if-expression with every parameter in your mail.


          To get a list of all the Parameters you have to use the ForEachChild() function (see an example under kb 12854):
          $(ForEachChild("ServiceReq#", RecId, "ServiceReqParam#", "ParameterName + ': ' + ParameterValue + '\r\n'", "CreatedDateTime ASC"))


          Unfortunately you are not able filter out which child object(s) are to be shown.

          But you can use the ReplaceRegex() function afterwards to replace all Parameter Values without values.
          The Regex expression should be something like "/.*:\s\n/".

          1 of 1 people found this helpful
          • 2. Re: Notification Quick Action functions
            wynnb Apprentice

            Thanks Florian,


            There are quite a few items on this request form. I give your suggestion a try. My other option is to configure it where we add the manager as the alternate contact and allow them to see the request in their 'My Items' list.

            • 3. Re: Notification Quick Action functions
              AlasdairRobertson ITSMMVPGroup

              Add a new field to the Service Req object called ApprovalTxt - Text(max), as part of your RO workflow update this field using an update block and push in what ever data from the SRP's you need.  Then call this field to you approval email.  Gives fine control of the layout and the data.  You can use this method to write the HTML fro a nice table to insert in the email if needed.  With this solution I think you could even test the quantity values so only the positive ones get displayed.

              • 4. Re: Notification Quick Action functions
                wynnb Apprentice

                That's a good idea too. What I'm really looking for is the same data that shows in the Parameters tab on the layout. That is done through a plugin though...

                • 5. Re: Notification Quick Action functions
                  lgtandi Apprentice

                  We use a similar approach as proposed by florian and alasdair with the following extension:

                  By sticking to a naming convention for the "internal" parameter name (i.e. the "Unique ID" specified for a service request parameter), we are able to filter out parameters that shall not be included in the "ParameterList" text field.


                  For example, using the following expression, only parameters and their values will be included as row in a HTML table, if their Unique ID does not start with the prefix "Hidden":


                  $("<table width='700' border='1' cellspacing='2' cellpadding='2'><tbody><tr><td width='25%'><b>Parameter Name</b></td><td width='75%'><b>Parameter Value</b></td></tr>" +
                    "if Find('Hidden', ParameterName) == 0 then EmptyString() else '<tr><td>' + (if nvl([ServiceReqTemplateParam#.]DisplayName, '') != '' then [ServiceReqTemplateParam#.]DisplayName else ParameterName) + '</td><td>' + (case DisplayType when 'textarea' then Replace(ParameterValue, '\r\n', '<br>') when 'list' then Replace(ParameterValue, '~^', ', ') when 'datetime' then FormatDate(ToLocal(DateTime(ParameterValue), 'Etc/UTC'), 'yyyy-MM-dd HH:mm') when 'date' then FormatDate(ToLocal(DateTime(ParameterValue), 'Etc/Utc'), 'yyyy-MM-dd') when 'time' then FormatDate(DateTime(ParameterValue), 'HH:mm') else ParameterValue) + '</td></tr>'",
                    "ParameterName ASC") +


                  To include only parameters with a quantity, you could then extend the condition within the "ForEachChild" expression to check for example, if the parameter name starts with "Qty" and the parameter value is not equal zero (although I think that parameters that have not been set when submitting the service request will not be created at all).