Jump to content

This topic is 4704 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi, i am using this script i found in the forum. Problem is that it only duplicates the first found record and not the complete set. Any help ??

Unsort Records

Go to Record/Request/Page[ First ]

Set Variable [ $recordPosn; Value:1 ]

Set Variable [ $foundCount; Value:Get(FoundCount) ]

Loop

Duplicate Record/Request

Set Variable [ $recordPosn; Value:$recordPosn + 1 ]

Exit Loop If [ $recordPosn > $foundCount ]

Go to Record/Request/Page [ $recordPosn; No dialog ]

End Loop

To leave only the duplicates, add these two lines at the end of the script.

Go to Record/Request/Page[ First ]

Omit Multiple Records[No dialog; $foundCount]

Posted (edited)

Hi Julio,

It is easier to take advantage of a sorted set because it holds the new duplicated record in position. I would suggest this script:

Sort [ by anything , no dialog ]

Set Variable [ $count ; Get ( FoundCount ) * 2 ]

Go To Record/Request/Page [ first ]

Loop

Exit Loop If [ Get ( RecordNumber ) ≥ $count ]

Duplicate Record

Go To Record/Request/Page [ next ]

End Loop

edited ... I changed >= to ≥ to avoid confusion although they will work the same.

Edited by LaRetta
Posted

Oh, if you need to end with only the new record set, add this outside the loop at the end:

Unsort

Go To Record/Request/Page [ First ]

Omit Multiple [ $count / 2 ]

This script produces less jumping around (back up to the top) and I believe it will be faster than the unsort method.

Posted

Thanx, here is what i am doing. First a run a report layout and find records from a specific date, then i run the script but i get only one record duplicated infinitely ??

Thanx again

Posted (edited)

Does the attached work? Both scripts should work fine. I suspect you have the wrong perspective for the layout or you have misnamed one of your variables somewhere along the line.

I don't know what this points to ... webkit-fake-url://CBA50139-ED61-43BE-8A1C-776022DF38CE/image.tiff ... because it doesn't work for me, sorry. :^)

dup.zip

Edited by LaRetta
Posted

Thanx, my mistake works well. Only one thing left is that I need the new set to have a different date. For ex. I do a find on a set for march 1, and I would like the new dup set to have april 1 as the date for all records found !!

thanx again

Posted

WHOA, my mistake! I knew unsorted sets are faster but I assumed that omitting the need of jumping from end to beginning would more than offset the sort slowdown but not so. I just tested it. So stick with the original script. My apology for almost steering you wrong.

You do not want to hard-code that date so use a global and enter the date before you begin, or ask for the date in custom dialog. Let's assume you used a global field called gDate. After your script isolates the new records, use Replace Field Contents [ your date ; gDate ] - only if not multi-user. If multi-user, include step

Set Field [ your date ; gDate ] ... immediately after you duplicate your record.

As an aside for anyone interested, a sorted set slows down exponentially as the record number increases. I had reported the issue when 7 first came out and I was sure they had fixed it - I know it was fast again in vs. 8.0v2. But here is my current test with 4,000 records, Windows XP Professional, FMPA 11.0v3:

Original script (unsorted) - 1:20

My script (sorted) - 5:14

Posted

If you will ALWAYS want one month after, you can skip the global and set the field with calculation one month older than your find criteria. I don't know how you are currently handling the find but consider this:

Enter Find Mode [ pause for user input of the date of March 1, 2012 ]

Set Variable [ $date ; Date ( Month ( yourdateField ) + 1 ; Day ( yourdateField ) ; Year ( yourDateField ) ) ]

... then continue your script and use this variable to set the new date.

This will always produce the same day but 'one month' later than the User enters into the find. To try it out, enter 3/1/2012 into the date field on the new revised file.

dup2.zip

Posted

Ok, i run the scipt. I entered the date 01/03/2012 (i am using the spanish calendar dates, first day/month/year. I does duplicate the records but still with the march date ?

Posted

How about export and import (then populate the date).

What does this represent in your system? Might be a data model issue.

Posted



LaRetta's script works fine on her table, but when i import an try on mine the date does not change. I changed the layout name and field name to match mine (in my database) but still not working
Posted

Hi Julio,

Well it should work regardless, since we are using the Date() function. Try removing the /* and */ from the Set Variable[] step and below fix the Set Field[] by re-pointing to the correct same date field and save your script. The /* are for commenting out a portion and FM thinks your field is invalid - they came over with the script import.

When you respecify your date in both locations, does it work then?

This topic is 4704 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.