I was wondering if there is a way of doing search and replace of a particular string in Fibery. I discovered that in a few spots, I had made wrote a name wrong and would like to correct it for future reference. Right now, I am just searching for the items and changing them one by one. The search panel also resets everytime I go into an entity to make the change so the process is very tedious. I am hoping there is a better way.
It is easier to do this when things are entities because you can just update the instance. Which leads me to ask if this functionality is going to be implemented, that it also have the ability to replace text with a particular entity to make updating easier. This is somewhat related to my other suggestion of unlinked references:
is there any update on Search & Replace across fibery?
or maybe is that something that could be implemented with a script? (would your AI be capable of writing something for that?)
it would be amazing to have the option to search through all the rich text fields in a DB and change /n to new line for example. (this is related to markdown import through csv)
with the help of claude.ai i was able to write a button scipt that did at least the replacement of \n (or in this case [CR]) to real new lines in a rich text field:
const fibery = context.getService('fibery');
// Loop through selected entities
for (const entity of args.currentEntities) {
// Get the Content field
let content = entity.Content;
// Check if Content exists
if (content) {
// Get Content using secret
const secret = content.secret;
content = await fibery.getDocumentContent(secret);
// Replace "\[CR\]" with newline
content = content.replace(/\\\[CR\\]/g, '\n');
// Update Content field
await fibery.setDocumentContent(secret, content);
}
}
return 'Updated Content by replacing "\\[CR\\]" with newlines';
but i had to put it on a button and click each row to do itā¦ i am sure @Chr1sG you know a way i could have run that through all instances of a table with just one click?
would that be a start to also find text and replace it with a link-reference? eg: a button in my contact database that takes the name field of that entry and searches in the rich text of another DB to find the matching text-name and replaces it with a reference?
like:
Read name field of entry in ācontact-dbā (store contactName, itemID)
iterate through all entries in āmeeting-dbā
replace content string ācontactNameā with āitemId Linkā
Well, in table view, you can select all rows and then run the button from the action menu.
This was what i was meaning about flexible/scalable challenges.
Assuming that you might want to search and replace across multiple dbs, and assuming that youād want the search text and replace text to be anything chosen by the user, it starts to get rather complicated.
Certainly, if you limit it to one database, and one field to be searched, then it actually might not be too hard (especially if you use the option to ask the user for input values).
Let me have a think about a basic version tomorrow, and Iāll get back to you
Each entry in the Search database represents the wishes for a specific find/replace action. You define the database/space you wish to search, the name of the (text or rich text) field that you want to look in, and the terms to be searched/replaced.
Press āRun the searchā button, and let the magic happen!
I havenāt tried it on large datasets, so I fully expect that the script might time out when searching rich text for a large number of entities
But for some use cases, it might save you a bit of time.
I guess this could be adapted so that the script takes the name of the entity (for example from a contacts database āLastname, Firstnameā) as the āthis->ā field and searches for it with the [] markdown link brakets; then replaces it with the link to the entity?
will check your code later. currently I am working on a n8n.io workflow that checks for new files on github/drive and then pulls all the YAML from that file to put into a new entity. works great only the fibery API is still returning no permission errors I need to solve will post the workflow here if that could spark interest?
Indeed.
The easiest way to do this is probably to find an entity with a rich text field where the contact called Firstname Lastname is already #mentioned, and look at the markdown for that mention - it will be in the form [[#^DB_ID/ENTITY_ID]] (see here for details).
Then copy this into the Replace field of the search template (with āLastname, Firstnameā in the Find field) and run the search to find/replace every occurrence
Of course, you would need to do it for every contact, but it might not be too hard to create a table of search/replace pairs.