4 Replies Latest reply on Nov 10, 2015 11:09 AM by Abingdon

    Setting the name of a related field into a variable

    Abingdon

       

      Hi All

      Is it possible to set the name of a related field from another file into a variable?

       

      I have tried using an OnObjectEnter script step, attached to the portalled record as follows:

       

      Set Variable  [$$FieldName ; Value: GetFieldName(Evaluate(Get(ActiveFieldName)))]

       

      But this returns a question mark.

       

      Any help would be appreciated as always.

       

      Abingdon

       

        • 1. Re: Setting the name of a related field into a variable
          JaredHague

          why not just use the field name itself?  GetFieldName is looking for an actual field like people::id not "people::id". This is also an advantage because if you change the name its automatically updated in the calculation.

          • 2. Re: Setting the name of a related field into a variable
            BruceRobertson

            Set Variable  [$$FieldName ; Get(ActiveFieldTableName & "::" & Get(ActiveFieldName)]


            But what's the application? Why do you want to do this?

            Note also that by referencing the active field, you are talking about the field with the cursor in it at the time the calc is performed, is that your intention?


            • 3. Re: Setting the name of a related field into a variable
              Abingdon

              Hi Jared,

               

              Thank you for your reply.  I am writing a script trigger that I want to apply to a large number of related fields so I can get the field contents of those related fields using the GetField function i.e., so I can attach a single script trigger to those fields rather than write a literal string for each field.

               

              Abingdon

              • 4. Re: Setting the name of a related field into a variable
                Abingdon

                Hi Bruce,

                 

                Sorry, I missed your reply.  Trust my reply to Jared part-explained my intention.

                I am comparing the existing contents of a related field (this I can do with an existing scripting by setting a $$FieldContent variable) with what may or not be a valid new entry in that field according to various criteria. Once this comparison is done, if it passes the test then the related field is left alone, otherwise the field is reverted back to its previous value using the data in the $$FieldContent variable.

                 

                It just seemed easier to do it this way rather than use literal field names.  Do you reckon this will work when I use the SetFieldByName function to reset the related field named by the $$FieldName variable to its original value?

                 

                Thank you so much for your solution - no more question marks!

                 

                Abingdon