3 Replies Latest reply on Sep 27, 2011 9:08 AM by DavidJondreau

    Script Problem



      Script Problem


      Hay guys I’m having a problem with a script.


      Part of it works, it’s only the If statement that are proving a problem.

      The script is preformed on a button click.


      Go to Field [Repairs::To]

      Copy [Select]

      Go to Field [Item 2::CurrentLocation]

      Paste [Select]

      If [Repairs::From = 1]              - have tried with If [Repairs::From = "1"]

         Set Field [Item 2::Status; "Client"]

      Else If [Repairs::To = 2]           - have tried with If [Repairs::To = "2"]

         Set Field [Item 2::Status; "Repair"]


         Set Field [Item 2::Status; "Client"]

      End If

      Commit Records/Requests [No Dialog]


      I have attached an image of the relationship and the layout, black arrow is the button, red arrows are the fields in the script.





        • 1. Re: Script Problem



          Sorry this is the only part of the database i need to get working, so please any help at all




          • 2. Re: Script Problem

            Does the layout shown list "Item 2" in "Show Records From" in layout setup?

            I would guess that this is the case but would like to confirm that detail.

            What field type was selected for Repairs::From and Repairs To? Number, Text, or ?

            I see to sets of From and To Fields, the pair pointed at by your arrows and those listed in the portal to repair. Are the upper two also inside a portal to Repair? (And I can see that the "from" and "to" in the lower portal are not the actual "from" and "to" identified in your script, but need to know the design details of your layout.

            I can see that To is formatted as a drop down list? Please describe the value list set up specified for that drop down list. (You may want to temporarily remove the arrow option so that you can see what values are actually stored in this field at the point when you perform this script. Perhaps a 2 isn't being stored in it at all and this might explain why the script doesn't work like you expected.

            What does happen when you perform this script?

            Final comment: While it's not an issue with why your script doesn't work as far as I can see, this code would be a better option than the copy and paste steps you are using:

            Set Field[ Repairs::To ; Item 2::CurrentLocation ]

            Copy and paste steps will silently fail if the referenced fields aren't present on the current layout and the copy step will replace any value the user may have copied to the clipboard previously with a new value and this can confuse and irritate the users when it happens.

            • 3. Re: Script Problem

              I think it's the copy and paste.You're not committing after the Paste[] so that field is still "empty".

              Better to use a Set Variable[] and Set Field[].