Scripts and use of bold or italic

Viewing 11 reply threads
  • Author
    Posts
  • February 6, 2020 at 9:32 AM #39508

    Victor Warner
    Participant

    Would it be possible in a script to use formatting commands such as bold or italic. For example if if there is the following statement:

    result = "and that the annexed paper writing is a complete and exact copy of the " + record.getFieldValue(type_of_document_id) + " of XXXX " + record.getFieldValue(number_of_pages_for_certificate_id) + " that I had caused to be printed on " + record.getFieldValue(date_of_companies_house_inspection_as_text_id);

    and I wished to make the following text

    of XXXX

    bold would this be possible within the script?

    February 6, 2020 at 11:39 AM #39514

    Brendan
    Keymaster

    Hi Victor,

    I’m sorry but it won’t be possible. I don’t have support for specifying font attributes for text ranges from within a script. And only a Note field can support rich text like that.

    Thanks,

    Brendan

    February 6, 2020 at 11:41 AM #39515

    Victor Warner
    Participant

    Brendan,

    Thank you for letting me know.

    Victor

    August 19, 2020 at 9:41 AM #41700

    T.L. Ford
    Participant

    I was also looking for a script way to set bold/italic.

    My preference would be for:
    setNoteFieldValue() to take 3 arguments where the last one is true/false for “am I providing HTML” with a default of false.

    NSAttributedString ought to have a function for converting an HTML string. If it fails, it could just toss it in as plain text or throw the error with “dolt. format your html right” except said more politely.

    As a random side note, my forum search turned up a post titled:
    Feature request: markdown format support in notes field
    which appears to be on the private Beta Team Forum (and clicking on it did not go to the post, but went to the Membership page header).
    Which suggests you are already studying this puzzle, or have studied it, or have added it or decided it was more trouble than it was worth.

    August 19, 2020 at 2:15 PM #41701

    Daniel Leu
    Participant

    I would use Markdown which is supported with version 5.3.13 (Build 1837). It is a separate field type.

    August 19, 2020 at 4:25 PM #41703

    T.L. Ford
    Participant

    Ah, I overlooked that field type. I can’t seem to guess the correct format for the data. Apparently it doesn’t like my trials because I can crash Tap Forms with things like hello and then trying to save the changes.

    August 19, 2020 at 5:57 PM #41704

    Daniel Leu
    Participant

    I’m using plain text and that works for me:

    var mdId = 'fld-f88c028ed8004a7684287732ef97099d';
    var md = record.getFieldValue(mdId);
    
    console.log(md);
    
    record.setFieldValue(mdId, md + "\n\n" + "# My very own title");
    form.saveAllChanges();
    August 20, 2020 at 12:06 AM #41707

    T.L. Ford
    Participant

    It was crashing just trying to add data through the regular form; hadn’t gotten to code yet. I’m able to use/push to the Note field without a problem, just no bold/italic formatting. I’d need the right syntax for the Markdown field type.

    – T

    August 20, 2020 at 9:44 AM #41710

    Daniel Leu
    Participant

    _italic_ **bold**

    August 22, 2020 at 12:05 PM #41718

    T.L. Ford
    Participant

    Thank you!

    August 22, 2020 at 5:44 PM #41721

    Sam Moffatt
    Participant

    Here’s a syntax reference for Markdown, not sure 100% of it works with the TF implementation due to issues with how it needs to get printed but it should give you a good idea of what to try at least.

    August 24, 2020 at 9:42 AM #41732

    T.L. Ford
    Participant

    Thanks! I’ll give it a try.

Viewing 11 reply threads

You must be logged in to reply to this topic.