1 Reply Latest reply on Aug 10, 2010 8:36 AM by philmodjunk

    Perform Find / Replace in a Script Not Working

    TSADesign

      Title

      Perform Find / Replace in a Script Not Working

      Post

      Question 1:

      I have a script that is being triggered by a check box / button in a table that is to add data into matching records in another table. The check box is matching records from Table 1 to Table 2 through a field that shares the same data, i.e. Part Number. The issue I'm having is that there are multiple instances of Part Number in Table 2. My script update the first instance, but ignores the other instances.

      My current script is as follows:

      If [GetAsNumber(RFQ::Field_1C) = 1]

         Set Field [Table1::Field_1C: ""]
         Set Field [Table2::Field_2C: ""]

      Else

         Set Field [Table1::Field_1C: 1]
         Set Field [Table2::Field_2C: Table2::Field_2A]

      End If

      Questions 2:

      In trying to use Perform Find / Replace I obviously did something wrong, and one of the records I was using to test will not display the portal data any longer. All other records are fine, but I can't figure out how to get this record to display the portal data again.

      Thank you for your help on this.

        • 1. Re: Perform Find / Replace in a Script Not Working
          philmodjunk

          I recognize the script above from another thread and I recall that I didn't recommend using perform find/replace but rather replace field contents which is a different tool.

          Frankly, I assumed a one for one relationship as the script example you've posted will only update the first related record in table1 and in table2.

          If you can't get records to appear in the portal for a given record, either that record and/or the set of related records have had the value in their match field(s) modified so that the parent record no longer matches those of the records in the portal's table. You'll need to search them out via some finds and check the values in these fields to see what happened.

          You may also recall that I suggested making a back up copy before trying this so that you can toss the file and try again if things didn't work as expected...

          The safest way to update groups of related records is to use a find or Go To Related Records to pull up those records on a layout based on the related table (table1, from your example), use Replace Field Contents or a loop to update them and then switch back to the original layout to repeat the process with the next record in the RFQ table. Since I see two related tables, table1 and table2, you'd need to do this for both related tables.