2 Replies Latest reply on Jul 1, 2011 8:30 AM by philmodjunk

    Get Field name of button when clicked

    GFS

      Title

      Get Field name of button when clicked

      Post

      Hi,

      I have a field formatted as a button.  How can I get the field name for a script, when the button is clicked?

      (The reason for doing this, is that I have 24 similar fields on a layout and would like to create a single script that can be applied to all of these fields.  When clicked the script should get the field's name, so that the rest of the script is applied to the correct field)

        • 1. Re: Get Field name of button when clicked
          Abhaya

          Hi

          You have to write a script and attached with each field and the field must have browse mode off.

          IF(script parameter=Name)

          go to field (Name)

          elseIF(script parameter=sal)

          go to field (sal)

          else

          exit script

          end if

          set variable($x;Value:Get(ActivefieldName))

          set field(Name;value:$x)

          Commit record request

          just  attached this script where you want t0 all the fields Name and give corresponding script parameter as field name.

          what happens when u click on Name field the script excutes and check the parameter and goes to the related if block means the corresponding field.

          then $x set the field name and place the field name in that field which is going to be  display after the script is over.(field Browse mode should be off)

          then it comes out of the loop and excutes the other steps.

          if any of the scriptparameter doesnot map then it goes to the else section and exits the script.

          • 2. Re: Get Field name of button when clicked
            philmodjunk

            The safest way to pass a field name as a script parameter is to use this expression: GetFieldName ( YourTable::YourField )

            Where you select your table and field names to put in the parenthesis. With this expression, if you later change the name of your field or it's table occurrence, the new table and field name will be passed as the parameter and you won't have to update your parameter expression.

            Once you have the field name passed as a parameter you can use set field by name to change the value in that field:

            set Field by Name [ Get ( ScriptParameter ) ; //your value or expression goes here ]

            And you can use the value of this field in an expression by using GetField:

            Set Field [Yourtable::some other field ; GetField ( Get ( ScriptParameter ) ) ]