Kirby Builder - how to set fields programmatically?

I have a builder field that allows people to set up a list of credits like:

label: Credits
type: builder
fieldsets:
  credit:
    name: Credit
    label: Credit
fields:
      heading:
        label: Heading
        type: text
      items:
        label: People
        type: tags
        icon: users
        options: query
        query:
          fetch: kirby.collection("people")
          text: "{{ page.title }}"
          value: "{{ page.autoid }}"
        accept: options

The problem is that the query wasn’t set to save the autoid value originally, and thus what I have in a number of entries is the page slug/uri.

I am easily able to loop through all my items, grab the slug and fetch the corresponding autoid but I’m struggling to understand how I can update the field accordingly with this value (except perhaps some kind of hacky regex on the field string).

Is there a way to programmatically set this field to replace the uri with the autoid?

You can do that with $page->update(), see the documentation for this method.

Thanks @texnixe I think I’m a bit confused though because of the structure of the ‘builder’ field, like how to create an object I can pass back in to update the page.