Hello World for Markdown with data

I was there for the Markdown webinar and I’ve watched it twice again but it’s just too much to follow. What is the simplest way to have data automatically filled in to a Markdown widget? I must have missed something easy…?!?

Hey Bruce!

Not much in that webinar that I’d describe as easy :face_with_spiral_eyes: it’s quite tedious, honestly! I do have a step-by-step example here if that’s easier to follow than the video: Proposals & contracts - Grist Help Center

If you’d like, share your document with support@getgrist.com as OWNER and I can take a closer look to see the structure of your setup and offer some guidance.

Thanks,
Natalie

I made a super simplified project that works. I took the contract and proposal example and whittled it down to what I thing is the bare minimum. Here is the code for it:

import grist
from functions import *       # global uppercase functions
import datetime, math, re     # modules commonly needed in formulas


@grist.UserTable
class Table1:
  Name = grist.Text()
  Birth = grist.Date()
  Mobile = grist.Text()


@grist.UserTable
class Templates:
  Version = grist.Text()
  Format = grist.Text()


@grist.UserTable
class Information:
  People = grist.Reference('Table1')
  stuff = grist.Text()
  phone = grist.Text()

  def fixit(rec, table):
    # Finds all data associated with this record
    class Find_Data(dict):
      def __missing__(self, key):
        return getattr(rec, key)

    # Finds the "Proposal" template in the Templates table
    template = Templates.lookupOne(Version="List").Format

    # Formats the template with fields from this table as well as fields from the referenced table
    return template.format_map(Find_Data(
      Name = rec.People.Name,
      Birth = rec.People.Birth,
      Phone = rec.People.Mobile
    ))

“fix it” was named that because I kept getting errors. a few things had the same name so I made each field have a very unique name.

Here is an additional thing I did. In addition to the markdown widget I added an html viewer next to it pointing at the “fix it” column. Both widgets work, but the layout looks different on each. I added an html table and the differences are considerable, while both work just fine.

Here is the link for my little markdown/html playground - https://docs.getgrist.com/qBhMZjAGucbE/Markdown-Simplified?utm_id=share-doc

And thanks so much for the reply! Looking forward to learning from you some more!!