2 Replies Latest reply on May 3, 2009 5:55 AM by KIDO

    get(ScriptParameter) question...



      get(ScriptParameter) question...


      I wrote a script that formats telephone numbers.  Several of my tables have telephone numbers so in the interest of simplicity, I thought I would pass the name of each table's Phone field as a Parameter to the script. 


      I find it not possible to pass the parameter in these 2 instances:


      Go to field []   and Clear[] .   It appears that it is 'mandatory' to specify a field for these two functions?? If so, to implement these functions I would have to copy the phone format script and rename it for each table's phone field; which defeats the whole purpose of using parameters???


      Or, am I missing something?


      Parameter question

        • 1. Re: get(ScriptParameter) question...

          Presumably this is a script that is triggered say OnObjectSave? If that is the case, then the current field will be the field you want the script to operate on so there is no need to even specify a script parameter - you can use Get ( ActiveFieldContents ) in your initial If statement


          In your script, just use the Clear script step without specifying a field (as you have done with Set Field).

          The Go to Field script step is not required.


          So your script looks like:



          If [ Length ( Get ( ActiveFieldContents ) ) ≠ 10 and not IsEmpty ( Get ( ActiveFieldContents ) ) ] 

            Show Custom Dialog [ Title: "Error"; Message: "Enter ten digits, no spaces or symbols."; Buttons: “OK” ] 

            Clear [ Select ] 

            Exit Script [ Result: 0 ] 

          Else If [ IsEmpty ( Get ( ActiveFieldContents ) ) ] 

            #Do nothing 


            Set Field [ "(" & Left ( Get ( ActiveFieldContents ) ; 3 ) & ")" & Middle ( Get ( ActiveFieldContents ) ; 4 ; 3 ) & "-" & Middle ( Get ( ActiveFieldContents ) ; 7 ; 4 ) ] 

          End If 


          The Exit Script with a false result is added to negate the action (of exiting the field) so the user remains in the field.


          I am not sure that you should be clearing the field and making the user enter the whole number again - I would delete the Clear step. 

          • 2. Re: get(ScriptParameter) question...

            Try the following:

            - In layout mode select the field Vendors::Phone, then select Menu - View - Object Info.

            In the Object Info type a name for the field, ex: "phone_vendors".


            - In your script replace the Clear line with Set Field [Vendors::Phone; ""]

            - replace the Go to Field instruction with:- Go to Object [phone_vendors]


            This must sort you out.