Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

is there a way to set up a script to duplicate a record if the value of field 1 is true, then another copy if field 2 is true, another if field 3 is true, etc for 3 fields.

I have 1969 records, many have multiple groups they need to be sorted into and exported. so say record one wants to be in categories

1) home builders

2) industrial construction

3) lumber supply

4) general contractors

EDIT---

I have created a script that creats the number of duplicate records I need, BUT it does not move on to the next record. It moves to the last duplicate it just created (if it made 12 duplicates for the first record it moves to recorddup #12) then stops.

So say record 99 needed 5 records, it duplicates record 5 times then needs to move to record 100 and make the correct number of records. Currently it wont do that...

THANKS

THANKS!

  • Newbies
Posted

Add a step to the end of your script, from Scriptmaker, under "Navigation" category, "Go to Record/Request/Page", and select "Next". This will get it to the next record. Then, you would have to trigger the script again.

If what you want is to go to next record, repeat the script automatically, then continue without any input from the user as it goes through all of the records in the file, I am not sure how you would accomplish that. In the past, I worked with FMP files in which I wanted to automatically repeat a series of actions from record to record. I used QuicKeys to automate that kind of activity. Perhaps that would help you.

Posted

Madapple, you can't have your data-set sorted or you will be unable to depend upon where the duplicated record ends up in your list (as it will pop into sort order) and it will also get duplicated. I suggest you leave it unsorted, by which you can reliably predict omitting the newly duplicated records as you go.

One such script might look like:

Allow User Abort [ On ] ... turn OFF after you are sure it's right ...

Go to Record/Request/Page [ Last ]

Loop

Exit Loop If [ not Status(CurrentFoundCount) ]

If [ Field1 = your criteria ]

Duplicate Record/Request

Omit Record

End If

... repeat for the tests on your next 10 fields - from If [] through End If then the last one ...

If [ Field12 = your criteria ]

Duplicate Record/Request

Omit Record

End If

Omit Record

End Loop

You could trap the IDs in a global, mark your records or utilize a counter but I find this omit method works quite well. You might also want to add a Show All Records [ ] at the end or provide your Users with a message that it worked; or they may be alarmed when all their records get gobbled up! smirk.gif

Posted

I usually prefer to have them sorted, then Go to Record/Request/Page [Next] after the duplication occurs. Moon's method does save time though, as no sorting need occur. I would add an Unsort step at the beginning of the script, just in case.

Posted

Hi Queue,

"I usually prefer to have them sorted, then Go to Record/Request/Page [Next] after the duplication occurs."

Am I missing something here? If you duplicate a record, it will jump to the newly created record - no matter where it ends up in the found set (after sorted). This would jump the cursor out of sequence.

Can you explain more specifically how this could work in a sorted set? It makes no sense to me. crazy.gif

Posted

Hi Moon, if the found set is sorted uniquely (I use a 'sort' field that is initialized at the beginning of the script) then a duplicated record appears directly underneath its original. So going to the next record after duplicating takes you to the next original record consecutively.

Posted

Gotcha! That makes sense, thank you ...

My concern is that this rarely works right for a regular sort! Because, if there are several records that match the sort criteria, it will still jump the newly created record to the bottom of the sort sequence (which matches the current record).

I hope it is clear that, using a unique sort field as Queue indicates would work - but WILL NOT work for grouped sorts, ie, if more than one record matches the sort sequence. I have attached a very silly small demo to show how this looks but, because of its simplicity it is powerful.

test.zip

Posted

Yes, it must be a unique sort in order to work properly. I think I'll try out your reverse loop idea though. It may be much more efficient.

Posted

wow ok thanks, make sperfect sense!

BUT i found away to do it with out dupliating the record it's self...

I set up 12 concatination fields that collect the info for me like this:

full listing 1 = If(t category 1 (is not equal to symbol) 0, t category 1 & "

Posted

ok while my solution worked very well I did hot another snag with the process.

exporting the fields is turning to be anightmare - heres why

say

Client 1 wants to be in

category1 Doctors, Pediatricians

category2 Doctors, Family

category3 Doctors, General

Client 2

Category1 Doctors, General

Category2 Doctors, Pediatricians

category3 Doctors, Family

Client 3

Category1 Doctors, Pediatricians

Category2 Doctors, General

category3 Doctors, Family

Since Each category is a different field how can I export

all the category Doctors, Pediatricians no matter if they are in cat1, cat2, or cat3?

Posted

One way would be to make a series of text fields to hold the client's category (I'm assuming a doctor can be both general AND family. If a client can only be one thing, it's much easier). Make a global field to use in a search script, call it g_search. Now make a script something like:

Enter Find Mode (restore OFF)

Set Field [Category1, g_search]

New Find Request

Set Field [Category2, g_search]

New Find Request

Set Field [Category3, g_search]

New Find Request

Perform Find (restore OFF)

Now you enter the type of doctor in your global, click a button that runs this script, and you have a found set of all pediatricians, whether this info is in any of the three categories. While you have that set, click a button that runs a script with one line, replace with calculation where the calc is simply g_search. You can run this as a subscript of the find script, if you're sure it's working okay (replaces cannot be undone!) Do this for all possibilities. Now you can export the new text fields, without worrying about which of three fields the needed info exists in.

Steve Brown

Posted

Since you have 3 'like' fields, you will run into this kind of thing again, believe me. I suggest instead that you create a calculation (text) which turns those Category fields into a multiline as:

i category 1 & "

This topic is 7435 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.