4 Replies Latest reply on Jun 1, 2015 10:35 AM by willrollo

    replace field contents issue

      Title

      replace field contents issue

      Post

      I have this script (below) which is deisgned to replace a field's contents in all the records - the records are selected by a find script. I am pretty sure it used to work bit now the script onlt replaces the contents of the first record.. Any ideas? 

             
      • Set Error Capture [ On ]
      •      
      • Perform Find [ Specified Find Requests: Find Records; Criteria: PRODUCTS::Update: “"yes"” AND PRODUCTS::Type: “"AF"” ] [ Restore ]
      •      
      • If [ Get(LayoutName) ≠ "Products" ]
      •      
      • Show Custom Dialog [ Title: "Error"; Message: "You need to be on the Price list Page"; Default Button: “OK”, Commit: “Yes” ]
      •      
      • Exit Script [ ]
      •      
      • End If
      •      
      • If [ Get(FoundCount)=0 ]
      •      
      • Show Custom Dialog [ Title: "error"; Message: "Please tick some products to update"; Default Button: “OK”, Commit: “Yes” ]
      •      
      • If [ Get(LastMessageChoice) = 1 ]
      •      
      • Perform Find [ Specified Find Requests: Find Records; Criteria: PRODUCTS::Type: “"af"” ] [ Restore ]
      •      
      • Exit Script [ ]
      •      
      • End If
      •      
      • End If
      •      
      • Show Custom Dialog [ Title: "Update"; Message: "Would you like to update the price of the items that you have checked below?"; Default Button: “Yes”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
      •      
      • If [ Get(LastMessageChoice) = 1 ]
      •      
      • Export Records [ File Name: “file:../../Desktop/Prices Back Up.fmp12”; Character Set: “Unicode (UTF-16)”; Field Order: PRODUCTS::Category PRODUCTS::Creation_Account PRODUCTS::Creation_Timestamp PRODUCTS::Description PRODUCTS::Description_Toggle PRODUCTS::Description_Trade PRODUCTS::Discountable PRODUCTS::Hide PRODUCTS::ID_Item_pk PRODUCTS::Image PRODUCTS::Image_code PRODUCTS::Modification_Account PRODUCTS::Modification_Timestamp PRODUCTS::Nominal Ledger Code PRODUCTS::Price PRODUCTS::Price increase PRODUCTS::Update PRODUCTS::Updated PRODUCTS::Description Short PRODUCTS::FL c_InStock PRODUCTS::FL c_ToBeOrdered PRODUCTS::FL Description_Toggle PRODUCTS::FL Discount Code PRODUCTS::FL Image PRODUCTS::FL Net Retail Price PRODUCTS::FL Received PRODUCTS::FL ReorderAmount PRODUCTS::FL Retail Price PRODUCTS::FL Stock Remaining PRODUCTS::FL Trade Price PRODUCTS::Painted PRODUCTS::Type PRODUCTS::Wood ] [ No dialog; Format output using current layout ]
      •      
      • Show Custom Dialog [ Title: "Warning"; Message: "What percentage do you want to increase the prices by?"; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No”; Input #1: PRODUCTS::Price increase, "Price Increase (%)" ]
      •      
      • Show Custom Dialog [ Title: "WARNING"; Message: "Are you sure you want to increase the price of the items below by " & PRODUCTS::Price increase & "%. ¶Remember to uncheck the boxes afterwards!"; Default Button: “Yes”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
      •      
      • If [ Get(LastMessageChoice)=2 ]
      •      
      • Exit Script [ ]
      •      
      • End If
      •      
      • Extend Found Set [ Specified Find Requests: Find Records; Criteria: PRODUCTS::Type: “"AF"” ] [ Restore ]
      •      
      • Replace Field Contents [ PRODUCTS::Price; Replace with calculation: (PRODUCTS::Price* PRODUCTS::Price increase/100) +PRODUCTS::Price ] [ No dialog ]
      •      
      • End If
      •      
      • Show Custom Dialog [ Title: "CHECK"; Message: "Check the new prices!"; Default Button: “OK”, Commit: “Yes” ]
      •      
      • Sort Records [ Keep records in sorted order; Specified Sort Order: PRODUCTS::Update; descending PRODUCTS::ID_Item_pk; ascending ] [ Restore; No dialog ]
      •      
      • Go to Record/Request/Page [ First ]

        • 1. Re: replace field contents issue
          philmodjunk

          You might insert a pause/resume script or show custom dialog just before Replace Field Contents and check to see what found set is actually present at the time the script step executes.

          • 2. Re: replace field contents issue

            It turns out that the script is selecting the correct records - however, the replace field step isn't calculating the required results.

            The script is supposed to ask the user to enter a percentage into the dialogue box - it then increases all the records selected by that percentage. I am not sure what part of the calc is incorrect, so would appreciate any help. The first record works out fine - the subsequent ones dont.  (see record 2 below)

            Example (10% increase)

            Record 1 Original price - 1000 . Updated price =  1100

            Record 2 Original price -  2000 Updated price = 12000

            • 3. Re: replace field contents issue
              philmodjunk

              What kind of field is Products::price increase? Is it defined as a field of type number?

              Is it defined to have global storage?

              If it is not defined as a global field, the user will need to specify this percentage on every products record prior to the replace--which would seem to defeat the purpose of your script.

              • 4. Re: replace field contents issue

                That was it -thank you . I have changed the properties of the update price increase field to be of a global type...

                Now works!