AnsweredAssumed Answered

Bad Scripting or Bug in FMPA 13

Question asked by MEC on Aug 8, 2014
Latest reply on Aug 11, 2014 by ch0c0halic

I currently have a script with problems that causes me to think there “may” be a bug in FileMaker 13 Advanced.

 

Client is a retailer with multiple shipping/warehouse locations. A Customer Order(CO) can be built by the sales staff with items shipping from multiple locations on a single CO. The Purpose of the script is to first check if the CO includes lines from multi locations, and if so, build new CO’s with single location. i.e. A single CO has different locations on several lines.

Line 1 is location 2

Line 1 is location 1

Line 1 is location 5

Line 1 is location 1

Line 1 is location 3

Line 1 is location 2

Line 1 is location 1

 

3 additional CO’s need to be created, for a total of 4 CO’s

Order # 12345 (location 1…. 3 line items)

Order # 12345A (location 2…. 2 line items)

Order # 12345B (location 3…. 1 line item)

Order # 12345C (location 5…. 1 line item)

 

Note: Primary Key in CO is UUID ….. auto enter text field, get (UUID)

 

The Bug: In the part Noted below, some of the Line Items, CO UUID field don’t get end up empty (they were originally populated with the original CO UUID), and some get two UUID’s in the same field with the last character of the first ID missing.

 

Example:

I have the following CO UUID’s

Location Parent UUID

Location 1 95D6DB75-4CD3-4EBA-A325-FE0F526ED3D0

Location 2 7A7C9876-4D81-4396-8458-0BFCA1C2205C

Location 6 B8A3F46B-F2A2-4A69-92A4-DB5EAAF7AC36

Location 8 29C835E6-0229-4DE4-B595-423F6AD223CB

 

What I end up with

Location Parent UUID

Location 1 95D6DB75-4CD3-4EBA-A325-FE0F526ED3D0

Location 2

Location 6 B8A3F46B-F2A2-4A69-92A4-DB5EAAF7AC37A7C9876-4D81-4396-8458-0BFCA1C2205C

Location 8 29C835E6-0229-4DE4-B595-423F6AD223CB

 

I’ve found, If I use Flush Cache to Disk at the beginning of the script, it works fine. I don’t feel good about having to use Flush Cache. Does anyone have thoughts as to what may be causing this?


MacBookPro i7 processor

16 gigs of RAM

OWC SSD

512 MB of RAM allocated to FMP Advanced 13

 

 

Method used:

  1. ) UUID of original CO is placed in global variable $$OriginalUUID
  2. ) Set a variable to the Count of unique locations $$LocationCount
  3. ) Let the user select a location to start Pulling (gathering the items for shipping at a single location) the order. User selects their location (a global text field with a number/location ID in it) g_location.
  4. ) Perform a find for the original CO using $$OriginalUUID
  5. ) Set variable $Count to 1
  6. f) Start a loop
    • (1) Duplicate the original CO and setting some some fields (Order Number, Shipping status, etc)
    • (2) If $Count = 1
      1. Set a variable, $COIDs to the CO’s UUID
      2. (3) Else
        1. Set the Variable, $COIDs to $COIDs and the CO’s UUID ( $COIDs ends up with a carriage return list of all the new duplicated CO’s
        2. ii) End If
          • (1) Increment $Count to $Count + 1
          • (2) Exit Loop if $Count = $LocationCount
  7. g) End Loop
  8. ) Perform another find to find the Original CO
  9. ) Go To Related Records (line items)
  10. ) Go to first record
  11. Start Loop (to omit the line items with the location the user chose to pull the items from)
    • (1) If user selected location to pull items from, g_location = line item location
      1. Omit record
      2. End If
      3. (2) Go to next record
  12. l) End Loop
  13. Set the list of new CO UUID’s, $COIDs to $COIDs & ¶
    • (1) Note: I’ve tried the script with this line disabled as well
  14. ) Set the location list variable to remove the location the items that will be pulled from, Set Variable $$LocationList ; Substitute ( $$LocationList ; g_location & ¶ ; “” )
  • o) Reset the $Count variable to 1
  1. ) Replace OR walk the lines to set the new CO UUID’s in the CO Lines with the new CO UUID’s, thus re assigning the lines to the newly duplicated CO’s. NOTE: I’ve tried both Replace and walking the lines with the same results
  2. ) Find the Original CO
  3. ) Go To Related Records (CO Line items)
  4. ) Go to first record
  5. ) Omit all of the pulled location items from the found set
    1. i) Loop
      • (a) If g_Location (user selected location to start pulling items) = CO line location
        1. Omit Record
        2. (b) End If
        3. (c) Go to Next Record, exit after last
        4. End Loop
        5. ) Reset Variables to remove the User selected location they chose (to pull items)
          1. ) Set Variable [$COIDs ; Value:Substitute ( $COIDs ; g_location & ¶ ; “” )]
          2. ) Set Variable [ $$LocationList ; Value:Substitute ( $$LocationList ; g_location & ¶ ; “” )]
          3. ) Set Variable $Count back to 1
          4. ) Find line items from original CO and specified location in variable location list and set the child ID to the new associated (duplicated) CO UUID
            1. i) Loop
              • (a) Enter find mode
              • (b) Set child ID field to $$OriginalUUID
              • (c) Set location to to selected location from Location list GetValue ( $$LocationList ; $Count )
              • (d) Perform Find
              • (e) Go to first record
              • (f) Loop
                1. Set Field line item Parent ID to selected value from list of UUID’s in variable GetValue ( $COIDs ; $Count )
                2. Go to next record, exit after last
                3. (g) End Loop
                4. Exit Loop [( $Count + 1 ≥ $$LocationCount )
                5. Set Variable [ $Count ; Value:$Count + 1]
                6. 5) End Loop
                7. ) Finally, clean up, null the Global Variables.

Outcomes