2 Replies Latest reply on Sep 11, 2014 3:15 PM by StefanSaeys

    Moving data between fields in same record with script

    StefanSaeys

      Title

      Moving data between fields in same record with script

      Post

      I have the fields "street" and "postal_code" in the same record.
      If field "Street" is empty", I would like to move the content of field "Postal_code" into it. So far my script is working, but when I add Loop or end if I get stuck. Either it doesn't go the the next empty field or it simply gives a script error.

      I have no need for adding goto layout or goto first record since I am using this once in table view. Probably the first line in the script is also not needed.

      Go to Field [contacts::street]
      If [IsEmpty (contacts::street)]
      Cut [Select; contacts::postal_code]
      Paste [Select; contacts::street]
      Go to Record/Request/Page [Next; Exit after last]
      Else
      Go to Record/Request/Page [Next; Exit after last]
      End If

       

        • 1. Re: Moving data between fields in same record with script
          philmodjunk

          Copy and Cut replace any data that the user may have previously copied to the system clipboard with the contents of the specified field. And this is not a necessary side effect as you can easily avoid it:

          Loop
             If [ IsEmpty ( Contacts::Street ) ]
                  Set Field [Contacts::Street ; Contacts::Postal_code ]
                  Set FIeld [Contacts::Postal_code ; "" ]
             End If
             Go to Record/request/page [ next ; exit after last ]
          End Loop

          Note for those new to scripting: When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.