Find and Replace in List View

OBJECTIVE: Beginning from a found set in list view, I would like to write a script to open a card window and enter strings to find and replace (for a given field in the entire found set) via the “substitute” function.

DISCUSSION: This would be easy with a custom dialog and “get last message choice” but using a card window means I have to script a similar workflow. Namely, capture the strings and allow for “cancel” and “go” buttons. I have devised a convoluted set of scripts and sub-scripts that probably will work, but they are not very elegant.

This seems like a common use case, and I figured a solution already exists. That said, I searched Google and the Soup and didn’t anything similar.

Very quickly and roughly...

  1. Use FieldNames ( "" ; Get ( LayoutName ) ) to obtain a list of all the fields on the list view layout. Set these into a field in a record (e.g. in a 1 record table like preferences) that you can then use as the basis of a value list. This will get you a popup-menu of fields on the layout...

  2. Open a card window on your layout...

  3. Create a new table "Substitutions" , where each record will be information about a single find/replace you are trying to achieve. Fields you might want:
    • field_name - chosen from the drop-down of fields as per step 1.
    • find_value - the value you're searching for - remember substitute function is case sensitive
    • replace_value - the value you are replacing it with.

  4. You might want to clear out these records each time a replace is done, each time you open the card, or make the records user specific (by including account name as a field on the records). Again, how you choose to manage these records is up to your requirements...

  5. Add/remove records above as required, via portal or just on the found set in your card layout, up to you.

  6. Your replace script when run will gather up information about the records in your found set and use that information to loop through the fields doing replaces. How you gather records again is up to you. you might loop through each one, or create a calculation which is the field name, replace value, and find value all in a single line, or you might build a JSON structure to do this ....

  7. Looping through your information, you'll have field name, find value & replace value, then it's just a case of using Set Field by name script step to loop through your found set one record at a time. You might actually prefer to loop through each record and perform every substitute on that record at the same time. You could use Patterncount to identify whether the field even contains the find value to save you doing a substitute...

Maybe if I get more time I can do an example but hopefully the above is going to give you a starting point.

1 Like

Thank you for the quick reply. I’ll check your solution against what I’ve already scripted.

I’ve broken this workflow into two scripts. Starting from the found set (list view) the first script opens the card window. The user enters the find and replace strings.

The second script closes the card window and loops through the records to make the substitution.

Next, I’ll see if I can combine these into one script.

I found a Claris Community post addressing this question.

This post recommends a single script using “pause” and “resume”.

I like the simplicity of a single script; I may try this approach next.

Some bedtime reading for you :slight_smile:

https://teamdf.com/blogs/modal-magic/

3 Likes

@weetbicks Daniel, thank you for the great article. I’m looking forward to exploring your methodology.

1 Like

+1 It's a fantastic article. Great concept to understand, beautifully explained.