Easily transfer data from Rich Text field to Text field?

Does anyone have an easy to use strategy to copy data from a Fibery Rich Text (Document) field to a Fibery (plain) Text field?

I’m thinking of a one off operation in my case, and too much data to copy-paste manually from the Rich Text (Document) fields one by one.

E.g. I had a use case where I 200 records, each with 4 Rich Text fields of data of simple text like “ABC”, that I wanted available as (plain) Text fields instead.

I tried these approaches:

  • Copy paste from a table view Rich Text field into a new Text field - doesn’t work :sweat:
  • Copy field, then convert field type - not possible (AFAIK)
  • A new field with a formula that converts the Text (like ToText(TheRichText)) - but ToText doesn’t work with a Document
  • Create a Report based on the data and copy-paste back to table - but Rich Text (Document) is not available in Reports
  • Use an automation with simple commands - but found no simple commands are applicable to do this operation

There is always the API and the Automation Rule or Button -Script route, but I was looking for more straightforward solution.

I know you cannot convert between types in Fibery, but you can usually just create new fields and copy-paste in bulk - but that doesn’t apply for Rich Text fields, it seems.

I have run into this question how access data in Rich Text field in Fibery in many use cases, but this copy-paste into text or other fields in particular, I feel there should be some straightforward non-technical solution for.

Hence - do anyone have a good straightforward solution on how to easily transfer/copy-paste data from many Rich Text (Document) fields to (plain) Text fields?

Example (from Notion DB sync use case)

I ran into this issue at scale recently when I used the database integration feature for the first time in Fibery. I synced over data from 2 databases in Notion.

Activating the integration was a super smooth experience. :smile:

But I ran into the issue that the integration design had the Notion Database fields of “Text” synced to Fibery’s “Rich Text” (or Document) field, not Fibery’s (plain) Text field.

I.e. that this Notion database:

image

syncs into this Fibery database:

image

I kind of get why the integration does this - if the conversation would be to plain text, you could potentially lose information.

Probably though, most users will not have rich text in Notion Database Text field, by my experience, at least not that needs to be preserved in a one-way sync.

At the same time, as I synced ~200 records, 4 key Notion DB fields (order references, cost center references, account references, vendor references), I couldn’t really use the data in Fibery, because they were synced into Rich Text (Documents) fields in Fibery. :anger:

Side note
I will create a separate feature request to ask if database integration solution could
be enhanced so the customer using the integration can configure on Fibery’s end some simple data transformation on select problematic field types like incoming “rich text” content, so this hassle can be avoided. In the Notion use case specifically, the design might be changed perhaps, but generally, I feel there are some choices how one way data syncs should transform the data, that is best left to the user that installs the integration, that knows their data.

Edit: maybe next time, since I found a good workaround for my use case and want Fibery to fix other things first

Workaround to get Notion DB Text field into (plain) Text field in Fibery :bulb:
For other Fibery users syncing DB data from Notion, here is a workaround I found useful:

  • For each Text field in a Notion Database that you want to sync into Fibery as a (plain) Text field, add a corresponding Formula type field in Notion, that references that text field
  • Using a formula that directly reference another field will just copy the visible content
  • And Notion’s formula field will sync to (plain) Text field in Fibery! :pray:
  • Of course, you have the overhead of adding such formula fields in Notion, and you’ll get the original Rich Text fields in Notion, but both Fibery and Notion has good support for hiding fields (although it might be confusing for other admins or your future self)
  • Another benefit of this workaround is that it will work if you want to keep the Notion db integration active after the initial sync is complete, unlike manual copy-paste solutions
  • If you had rich text and newlines in the original field you referenced with a formula, some quick tests I did seems to indicate line breaks are preserved and formatting stripped (which was OK in my use case)

I also noted a bug in the Notion integration - it doesn’t work if there is a period (.) in the Notion field name (and maybe other special characters) - workaround just rename the field. I’ll file bug report directly to Fibery via Intercom about that particular issue.
Edit: reported at 2022-11-05

3 Likes

Related: Allow Rules/Formula Involving Rich-Text Fields - #2 by Matt_Blais

2 Likes

@Chr1sG had helped me before with a similar request. Here is a possible solution:

  1. Create all the simple text fields that you want the information inside.
  2. Create a button to execute the following script:
const fibery = context.getService('fibery');

for (const entity of args.currentEntities) {
    const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, ['RichTextFieldName2','RichTextFieldName3','RichTextFieldName4']);

    var doc1 = await fibery.getDocumentContent(entityWithExtraFields['RichTextFieldName1']['Secret']);
    if (doc1) {doc1 = doc1.replace(/\n\n/g,'\n')};
    var doc2 = await fibery.getDocumentContent(entityWithExtraFields['RichTextFieldName2']['Secret']);
    if (doc2) {doc2 = doc2.replace(/\n\n/g,'\n')};
    var doc3 = await fibery.getDocumentContent(entityWithExtraFields['RichTextFieldName3']['Secret']);
    if (doc3) {doc3 = doc3.replace(/\n\n/g,'\n')};
    var doc4 = await fibery.getDocumentContent(entityWithExtraFields['RichTextFieldName4']['Secret']);
    if (doc4) {doc4 = doc4.replace(/\n\n/g,'\n')};

    await fibery.updateEntity(entity.type, entity.id, {'SimpleTextFieldName1': doc1 , 'SimpleTextFieldName2': doc2 , 'SimpleTextFieldName3': doc3 , 'SimpleTextFieldName4': doc4 });

Just replace RichTextFieldname1-4 and SimpleTextFieldName1-4 in the code with the correct field names.

  1. Run the button on all needed entitites (try on individual entitites first)
1 Like

Here’s a simple Rule that will mirror a Rich Text field to a Regular text field once an hour.
That would let you test for IsEmpty() and you could pretty easily adapt the script to strip out the Markdown formatting if needed.

// Copy MD content from a Rich Text field to a plain text field
const RTF = 'RTF'               // Name of RichText field (source)
const PLAIN = 'RTF plaintext'   // Name of plaintext field (destination)
const fibery = context.getService('fibery');
for (const entity of args.currentEntities) {
    const secret = entity[RTF].Secret
    const content = await fibery.getDocumentContent(secret, 'md')   // Get markdown
    await fibery.updateEntity(entity.type, entity.id, {[PLAIN]: content})
}
1 Like

Those are 2 great tips for each use case of schedule sync and one-offs. Thanks @Eren_Turgut and @Matt_Blais ! :slightly_smiling_face:

1 Like

Thanks! That was super helpful @Matt_Blais :clap:

Gave me a solution to get to the Attendees Details from a Google Calendar Event - which I’d been searching for. Allows me to determine the customer I’m meeting with via the email address/es of attendees. I do this as a schedule sync - I guess there may a better way to do this - but this works for now. :+1: