6 Replies Latest reply on Mar 6, 2018 4:05 PM by CHRbfcu

    can't get expression to work within a task

    TLuis Rookie

      I am trying to have two fields show only if it's true in a Task within a Request Offering.  The field names are "chkPowerSupply"  and "qtyPowerSupply".  These fields are tied together so if someone checks the box to order a power supply the quantity will multiply the cost.  I only want these to show up in the Task if they are true.  So if the keyboardMouse field is true then put in a title of Keyboard/Mouse: then the word "true" then the title Quantity followed by the actual quantity.

       

      This is what I was given to use but it's not working.  It sends back a <null> in the task.  I have tried putting in "true" instead of 1.  I tried just putting the first part so it would just show the title "Keyboard/Mouse) but the same thing happens.

       

      $(if chkKeyboardMouse = 1 then 'Keyboard/Mouse:  ' + chkKeyboardMouse + ',  Quantity: '+ qtyKeyboardMouse else '')

       

       

      Works fine if I don't try to hide

       

        • 1. Re: can't get expression to work within a task
          rosscarins Employee

          Hi TLuis,

           

          If 'chkPowerSupply' and 'qtyPowerSypply' are request offering parameters, in your IF statement you need to use the following format: $(GetSRPValue(RecId,  "FIELDNAME")).

           

          So in your if statement it would be something like:

           

          $(if GetSRPValue(RecId, "chkKeyboardMouse") = 1 then 'Keyboard/Mouse:  ' + GetSRPValue(RecId, "chkKeyboardMouse") + ',  Quantity: '+ GetSRPValue(RecId, "qtyKeyboardMouse") else '')

           

          I've done something similar when I wanted to add certain parameters in email notifications.

           

          Cheers,

          Ross

          • 2. Re: can't get expression to work within a task
            TLuis Rookie

            Hi Ross,

             

            I copied over what you sent but it’s not working correctly. 

             

            This is what I put in the request offering task window:

            2018-01-10_8-27-35.png

            $(if GetSRPValue(RecId, "chkPowerSupply") = 1 then 'PowerSupply:  ' + GetSRPValue(RecId, "chkPowerSupply") + ',  Quantity: '+ GetSRPValue(RecId, "qtyPowerSupply") else '')

             

             

            Then I submit this request

            2018-01-10_8-02-49.png

             

             

            This is what comes up in the task.  It looks like it computes up to the =1 and then puts in  the rest of the expression as text.  Am I missing a ( or )  ?

             

            2018-01-10_8-00-55.png

             

             

            Ivanti User Community

             

            can't get expression to work within a task

            reply from rosscarins in Ivanti Service Manager (Formerly HEAT Service Management) - View the full discussion

             


            Hi TLuis,

             

            If 'chkPowerSupply' and 'qtyPowerSypply' are request offering parameters, in your IF statement you need to use the following format: $(GetSRPValue(RecId, "FIELDNAME")).

             

            So in your if statement it would be something like:

             

            $(if GetSRPValue(RecId, "chkKeyboardMouse") = 1 then 'Keyboard/Mouse:  ' + GetSRPValue(RecId, "chkKeyboardMouse") + ',  Quantity: '+ GetSRPValue(RecId, "qtyKeyboardMouse") else '')

             

            I've done something similar when I wanted to add certain parameters in email notifications.

             

            Cheers,

            Ross

            • 3. Re: can't get expression to work within a task
              SupportEmployee

              I think the problem is that the normal Task block doesn't like the use of Functions in the Details Field.  You may have to use the Extended Task Block in order for that to work.

              • 4. Re: can't get expression to work within a task
                DTurner Expert

                Hi Teresa,

                 

                The standard 'Task' workflow block does not support the use of functions or expressions, you instead need to use the 'Extended Task' block for this functionality.

                 

                The following appeared to work for me when testing:

                $(if Boolean(GetSRPValue(RecId, "chkKeyboardMouse"))

                  then "Keyboard/Mouse: " + GetSRPValue(RecId, "chkKeyboardMouse") + "\r\nQuantity: " + GetSRPValue(RecId, "qtyKeyboardMouse")

                  else "")

                 

                Hope this helps

                3 of 3 people found this helpful
                • 5. Re: can't get expression to work within a task
                  TLuis Rookie

                  That worked for me.  Now I need to have multiple checkboxes and quantities. I don't know how to tie these together so I just have one expression in the Details field.  All totaled I will have 5 checkboxes with corresponding quantities

                   

                   

                  Need one expression:

                   

                  $(if Boolean(GetSRPValue(RecId, "chkKeyboardMouse"))

                    then "Keyboard/Mouse: " + GetSRPValue(RecId, "chkKeyboardMouse") + "\r\nQuantity: " + GetSRPValue(RecId, "qtyKeyboardMouse")

                    else "")

                   

                  $(if Boolean(GetSRPValue(RecId, "chkPowerSupply"))

                    then "PowerSupply: " + GetSRPValue(RecId, "chkPowerSupply") + "\r\nQuantity: " + GetSRPValue(RecId, "txtQuantityPowerSupply")

                    else "") 

                  • 6. Re: can't get expression to work within a task
                    CHRbfcu Apprentice

                    If you didn't already get this working, it would be something like below. I have built this out up to 38 items successfully.

                     

                    $((if Boolean(GetSRPValue(RecId,  "chkKeyboardMouse"))

                      then "Keyboard/Mouse: " + GetSRPValue(RecId,  "chkKeyboardMouse") +

                           "\r\nQuantity: " + GetSRPValue(RecId,  "qtyKeyboardMouse")

                      else "") +

                      (if Boolean(GetSRPValue(RecId,  "chkPowerSupply"))

                      then "PowerSupply: " + GetSRPValue(RecId,  "chkPowerSupply") +

                           "\r\nQuantity: " + GetSRPValue(RecId,  "txtQuantityPowerSupply")

                      else ""))