insert raw richtext into Note field

Viewing 2 reply threads
  • Author
    Posts
  • December 7, 2022 at 12:55 PM #48457

    Lane Robinson
    Participant

    brand new to javascript, but I’m reading a lot.

    so, I have this richtext

    {\rtf1\ansi\ansicpg1252\cocoartf2706
    \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 FiraSansCondensed-Regular;}
    {\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
    {\*\expandedcolortbl;;\csgenericrgb\c0\c0\c0;}
    \margl1440\margr1440\vieww11520\viewh8400\viewkind0
    \pard\tqr\tx7117\pardirnatural\partightenfactor0

    \f0\fs24 \cf2 <placeholder>}

    I don’t quite know how to convert that to an object variable that can be used with setNoteFieldValue.

    December 7, 2022 at 8:00 PM #48458

    Brendan
    Keymaster

    Hi Lane,

    record.setNoteFieldValue() requires either plain text or an NSAttributedString. However, that rich text can’t really be converted to an NSAttributedString in JavaScript as far as I know. So you’ll be better off just using plain text.

    December 8, 2022 at 7:15 AM #48462

    Lane Robinson
    Participant

    Thanks Brendan,

    I’ve found that once I’ve applied styles to a Note field I can no longer paste plain text into it. There is no error in the console about this. It just doesn’t happen.

    In the other sub forum you mentioned

    I suppose you could make a record that has the settings you want in your Note field and then duplicate that record whenever you want to make a new record? You would need a bit of text in there, even a space character for the attributed string to remember its settings.

    I’ve been trying that, but I can’t see a way to append text to it in your javascript API, and with the fact I can’t even replace it with plain text once it’s been styled is going to force me in the long run to figure out how to convert richtext into an NSAttributedString.

    I have another idea for this I’m going to explore.

Viewing 2 reply threads

You must be logged in to reply to this topic.