9 Replies Latest reply on May 11, 2016 6:20 AM by Tomas.v

    Dynamic Window help tick box to shwo new free text field

    GarethReeves Apprentice

      Can anyone help, i am trying to add a tick box to our incident window that when ticked displays and additional text box, the idea is that where the Analyst needs to add a translation of the user logged incident to another language they can tick the box and enter the transalation. When any other Analyst views that incident the additional field needs to show by default so they can see the translation;

       

      So far I have created;

       

      1. a tick box called add translation default value is false and added it to the default window
      2. Created an attribute called Dynamicwindowtranslation set to string -1 calculation type window calculation
      3. Setup calculation on for 2) as; (ignore the formatting below tabs don't work in this window)
        import System

       

      static def GetAttributeValue(Incident):

       

      Value = ":SetHidden(_Translation, false);"

       

      return Value

       

      Set the dependencies to _AddTranslation

       

      4) create a new field called Translation string -1 and added to the default window and set show in window to false

       

      The above does nothing at all tick the box nothing happens, Can any one advise where i have gone wrong please? i read the design guide made no sense at all.

       

      Thanks G

        • 1. Re: Dynamic Window help tick box to shwo new free text field
          Tomas.v Apprentice

          Hello Gareth.

           

          I had few issues with Dynamic Windows too when I started using them for the first time. Right now we use exact same thing in our Service Desk. So i think i can help you.

           

          1. You need to change your step 4. Set that Translation atribute back to show on window = true. We will change that in the calculation.
          2. Open the window with a tick box in a Window Designer. Then select the tick box (not the label), go to properties and set is calculate on change = true. This will then trigger the calculation that shows the translation field.
          3. Go to your Dynamicwindowtranslation atribute and open the window calculation editor. And you need to create something like this:

           

          import System

          static def GetAttributeValue(Incident):

            Hide = true

            Mandatory = false

            if Incident._SIEM == true:

            Hide = false

            Mandatory = true

            if Incident._SIEM == false:

            Hide = true

            Mandatory = false

            return String.Format(":SetHidden(_SIEMurl,{0});:SetMandatory(_SIEMurl,{1});", Hide, Mandatory)

           

           

          So, let's break it down.

           

          import System

          static def GetAttributeValue(Incident):

            Hide = true

            Mandatory = false

           

          This states that by default, the atribute will be hidden and NOT mandatory.

          ----

           

            if Incident._SIEM == true:

            Hide = false

            Mandatory = true

           

          _SIEM is a tick box in my LDSD. So if its true (checked), it will change the Hide to false, and Mandatory to true.

          -----

           

            if Incident._SIEM == false:

            Hide = true

            Mandatory = false


          This is here because sometimes people just check the box (to check what it does for example) and then they want to hide it. So this is just exact opposite of the previous example. If its false(unchecked), it will change back to hidden and not mandatory.

          ---

           

            return String.Format(":SetHidden(_SIEMurl,{0});:SetMandatory(_SIEMurl,{1});", Hide, Mandatory)


          This returns the value that was calculated. I don't understand this enough to really explain it to you. But I'm sure you will understand how this line works.

          ---

           

          If you want, you don't have to use Mandatory. But usually if I want something to show after user ticks the box, I usually want them to type something into it. So I recommend to make it Mandatory too, but it's up to you.

           

               4. Go to your window in Window Designer and place somewhere the atribute Dynamicwindowtranslation. And then set it to show on window = false.

           

           

           

          I hope this explanation is good enough for you. And i think i covered everything, but if you come across a problem just reply to this and I will do my best to help you.

          • 2. Re: Dynamic Window help tick box to shwo new free text field
            GarethReeves Apprentice

            That looks brilliant, I will try this tomorrow and let you know.

             

            Thank you

            • 3. Re: Dynamic Window help tick box to shwo new free text field
              GarethReeves Apprentice

              Ok just tried this i think i have missed something. I have the tick box "Add Transalation" set to calculate on change in the window. The dynamicwindowtransalation object has the calculation set to check if add translation is true false etc. But what actually tells the system to set the third field "Transalation" to hidden? this field is not referenced anywhere only the tick box and the dynamicwindowtranslation.

               

              All i get is the translation field showing as soon as i open the window, the tick box true\false does nothing. So i have mis understood something i think.

              Calculation is below addtranslation is the tick box but does not state to set the field translation to hidden not hidden etc. Let me know where i have gone wrong.

               

              import System

               

              static def GetAttributeValue(Incident):

               

              Hide = true

               

              Mandatory = false

               

              if Incident._AddTranslation == true:

               

              Hide = false

               

              Mandatory = true

               

              if Incident._AddTranslation == false:

               

              Hide = true

               

              Mandatory = false

               

              return String.Format(":SetHidden(_AddTranslationurl,{0});:SetMandatory(_AddTranslationurl,{1});", Hide, Mandatory)

              • 4. Re: Dynamic Window help tick box to shwo new free text field
                GarethReeves Apprentice

                fixed it!

                 

                return String.Format(":SetHidden(_AddTranslationurl,{0});:SetMandatory(_AddTranslationurl,{1});", Hide, Mandatory)

                 

                changed to

                 

                return String.Format(":SetHidden(_Translation,{0});:SetMandatory(_Translationl,{1});", Hide, Mandatory)

                 

                Works perfectly

                • 5. Re: Dynamic Window help tick box to shwo new free text field
                  GarethReeves Apprentice

                  So next question is can i make two fields appear when the tick box is true??

                  • 6. Re: Dynamic Window help tick box to shwo new free text field
                    Tomas.v Apprentice

                    Glad to hear you managed to get it working. By the looks of it, you just used wrong atribute.

                     

                    And for your second question. Yes, you can. I actually created a form for HR process few weeks ago. And in the default state you can only see like 10 attributes. But most of them are tick boxes and as soon as you check them, more fields appear. One of them even shows 5 or 6 more tick boxes.

                     

                    Here is the example calculation I use in the HR form:

                     

                    import System

                    static def GetAttributeValue(Activity):

                      Hide = true

                      Mandatory = true

                      if Activity._Dalsisitovedisky == true:

                      Hide = false

                      Mandatory = true

                      if Activity._Dalsisitovedisky == false:

                      Hide = true

                      Mandatory = false

                      return String.Format(":SetHidden(_DiskP,{0});:SetMandatory(_DiskP,{1});", Hide,Mandatory) + String.Format(":SetHidden(_DiskO,{0});:SetMandatory(_DiskO,{1});", Hide,Mandatory) + String.Format(":SetHidden(_DiskS,{0});:SetMandatory(_DiskS,{1});", Hide,Mandatory) + String.Format(":SetHidden(_DiskG,{0});:SetMandatory(_DiskG,{1});", Hide,Mandatory) + String.Format(":SetHidden(_DiskR,{0});:SetMandatory(_DiskR,{1});", Hide,Mandatory) + String.Format(":SetHidden(_DiskQ,{0});:SetMandatory(_DiskQ,{1});", Hide,Mandatory) + String.Format(":SetHidden(_DiskU,{0});:SetMandatory(_DiskU,{1});", Hide,Mandatory)

                     

                    Only thing that's different is the last line. It is basically same like in the last example i send you. You can just add more atributes to it. And if you, you can even make two or more tick boxes to show one atribute. You just have to create a new atribute DynamicwindowX.

                     

                    Hope it helps.

                    • 7. Re: Dynamic Window help tick box to shwo new free text field
                      GarethReeves Apprentice

                      Thanks again.

                       

                      Wonder if you have any experience of dynamic windows set against category? I tried modifying the examples you gave, i set the category field to calculation on change, set the category as the dependency for the calculation in my hidden dynamic windows field. I get odd results.

                       

                      The window i want hidden when the form is open is not hidden but is not mandatory, when i set the category to the desired option the field changes to mandatory, so the calculation is running i am just confused why this version of the calculation is showing the hidden field all the time. Clearing the category does not revert it back to hidden also in fact the result of the calculation is blank so suggests its failing somehow.

                       

                      Amy Ideas?

                       

                       

                      import System

                       

                      static def GetAttributeValue(Incident):

                       

                      Hide = true

                       

                      Mandatory = false

                       

                      if Incident.Category.Title == null:                 also tried "if Incident.Category.Title != "SAP"" same issue.

                       

                      Hide = true

                       

                      Mandatory = false

                       

                      if Incident.Category.Title == "SAP":

                       

                      Hide = false

                       

                      Mandatory = true

                       

                      return String.Format(":SetHidden(_Translation,{0});:SetMandatory(_Translation,{1});", Hide, Mandatory)

                      • 8. Re: Dynamic Window help tick box to shwo new free text field
                        GarethReeves Apprentice

                        every time i type a query i solve it minutes later!!! had to add additional IF for if category is null as unlike the previous example for true false. The category can be null, SAP and not SAP!

                         

                        dangerous if i had a brain

                         

                        G

                        • 9. Re: Dynamic Window help tick box to shwo new free text field
                          Tomas.v Apprentice

                          Great . Same thing happens to me too. I can spend an hour trying to solve something and after i give up and go ask my colleague, i somehow manage to answer my own question while im asking.

                           

                          Also, thanks for trying it for me. I had no experience with dynamic windows set against category. I think i once saw it in one of our customer's Servuce Desk. But i never tried creating calculation for it. So i learned something new too.