5 Replies Latest reply on Feb 22, 2009 2:27 AM by Sorbsbuster

    custom function with generic field parameter ?

    synergy46

      Title

      custom function with generic field parameter ?

      Post

      :smileysurprised:

      I have a SINGLE TABLE with two fields:

       

      City1:  Is a lookup that  returns the value of the City in a related table.  It works.

      City2:  Has an auto-enter value of :  City2=City1   It works

       

      However, if the user changes City2 and does not capitalize the entry properly I want to return City2=proper(city2).  I tried this in the VALIDATION calculation section but got nothing but errors. 

       

      So, I wrote a script that was called from the City2 field scriptTrigger.  It works.

       That script is:  INSERT CACULATED RESULT [SELECT; PROPER(VISITORS::CITY2)]

       

      THIS SCRIPT DOES THE JOB.  However....

       

      I would like to generalize the script so that it can  receive the name of the field as a parameter.  (This would avoid having to duplicate this cript for each field ugh...)

       

      I can setup the parameter but can't figure out how to refer generically to a field.

       

      All help is appreciated.

       

      Thanks fo reading

       

       

        • 1. Re: custom function with generic field parameter ?
          raybaudi
            

          Hi synergy46

           

          > I tried this in the VALIDATION calculation section but got nothing but errors.

           

          Not into the validation option, but into the auto-enter option for the field City2:

           

          Proper ( City2 )

          • 2. Re: custom function with generic field parameter ?
            synergy46
              

            I can't use Auto-Enter for City2 because it is set to:  City2=City1 .

             

            In the event that the user types over City2, I want to be able to put into proper format

            and would like to modify my 'specific', script that references City2 to be more 'general' and to be useable by other fields as well.  

             

            (I know I can just duplicate the script designating a different field but it seems, intuitively that I should be able to pass a parameter specifying the field name and then have Proper(field) act on the passed (field) parameter.

             

            I hope I am being clear.  Thanks for reading.

             

             

            • 3. Re: custom function with generic field parameter ?
              Sorbsbuster
                

              I don't mean to act like a stalker, but you posted this query before, and (purely in the spirit of trying to be helpful), I have re-tested my original response and it still works for me to do what you asked:

               

              Enter into the *auto-enter* tab, as Daniele says, the following:

              This works for me:

               

              Case (

              CityC= "" ; CityV ;
              Proper (CityC )

              )

               

              I have tried this again, and it works for me that:

              - if someone types in a City1 it automatically inserts it in City2

              - if they overtype a different City2 it will accept that, and also replace it with proper case.

              - in fact it can be extended so that it someone enters City1 wrongly it will convert it to proper case as well:

               

              Case (

              NameSecond = "" ; Proper (NameFirst) ;
              Proper (NameSecond )

              )

               

              HTH,

              Alan.

               





              • 4. Re: custom function with generic field parameter ?
                synergy46
                  

                Thanks for the reply.  You are right, I misunderstood and was working the problem from the perspective of Validation instead of Auto-Enter.  

                 

                I see your solution's logic and appreciate your contribution.

                 

                BTW, in my 'journey' to more FM understanding I went down the rocky road of writing my first custom application and linked it to a script trigger.  It worked and I learned a lot.  But, I like your 'simpler' and equally effective solution more.:smileyvery-happy:

                 

                Thanks

                 

                 

                • 5. Re: custom function with generic field parameter ?
                  Sorbsbuster
                    

                  Pleased to have helped.

                   

                  Alan.