This blog will show you how to programmatically deploy SharePoint Premium Autofill columns in SharePoint document libraries. I will also show how to programmatically process existing documents with Autofill rules. This developer focused blog will provide the necessary PowerShell commands to create/manipulate the JSON required for the list properties where Autofill config settings are stored.

Previous Blog: Game Changer: Autofill columns Now Available in SharePoint Premium – Leon Armston’s Blog

I’m thrilled about Autofill columns and consider it SharePoint’s best work to date! While exploring the backend, I found that the settings for Autofill columns for each list are stored collectively in the “list” property bag field Vti_SyntexPoweredColumnPrompts, rather than within the individual field properties. This discovery was a bit surprising and, to be honest, somewhat disappointing. I hope that in the future, Autofill column configurations can be housed within the field properties. This change would enable them to be reused as site columns and distributed through the Content Type hub across the tenant. Centralized updates would then be possible, simplifying the management of prompt changes without the need to manually update each list.

Through the UI all calls to get the Autofill config is through the SPO REST API so my scripts below will focus on this approach.

However you could use the PowerShell Set-PnPPropertyBagValue to also update the Autofill column config for a list if you know the format of the JSON.

I will now demonstrate how you can programmatically add and edit existing Autofill columns using PowerShell, as well as request a file to be reprocessed. You can then incorporate these steps into your provisioning solutions or scripts to bulk add and manage Autofill columns.

Script Required

Activate or edit existing Autofill Column

The process through the UI for Autofill is explained in my previous blog on Autofill. It is simply: add a column (Text, Multiple lines of text, Number, Yes/No, Date and time, Choice, Hyperlink, Currency). Then, go into the column properties, activate Autofill, and create/test a prompt before saving the settings.

First create a field in your library using the PnP PowerShell command Add-PnPField or even through the UI – take a note of the field name.

Below is a script which is uses PnP PowerShell to add and edit existing Autofill columns. Change lines 1 to 5 to reflect the details of your environment.

This script connects to the specified site or list, retrieves information about the desired field, and fetches the Autofill configuration (JSON) using a GET request to the SPO REST API endpoint <your site url>/_api/machinelearning/getSyntexPoweredColumnPrompts(‘%7B<Your library ID>%7D’)

The script creates or edits the retrieved JSON for the SyntexPoweredColumnPrompts list property. The script can activate a column for Autofill, modify an existing Autofill column (e.g., changing the prompt), or disable it from being used with Autofill. It handles all necessary JSON manipulations before submitting the changes.

The script creates a JSON payload like below and sends it as a POST request to: the API endpoint <your site url>/_api/machinelearning/SetSyntexPoweredColumnPrompts to update the list property with the updated Autofill config.

Once the script completes you will get the following back from the API to confirm your changes have been applied.

You can now visit the Column properties in the UI for the column you just activated or edited for Autofill to view the applied changes. If you need to do this for multiple columns, you will have to run the script multiple times, editing the script variables for each required Autofill column each time.

You could also update the Autofill column configuration for a list using PnP PowerShell. Simply use the command:

Set-PnPPropertyBagValue -Key “Vti_SyntexPoweredColumnPrompts” -Folder “Your Library Url i.e. Autofill” -Value “Autofill columns JSON config here”

This method works if you know the format of the JSON and is just the syntexPoweredColumnPrompts part – no docLibId is required. See below for an example:

Request a file is re-processed with Autofill rules

When you add a new Autofill column or modify an existing one (e.g., change a prompt), the existing files in the library are not automatically processed. To re-process these files, you need to select them in the document library and then choose the Autofill option from the document library toolbar (see image below).

I however wanted to see if this could be automated and can see it is done through SPO REST API so I created a script to do this.

Change lines 1 to 3 to reflect the URL of your sites, the library name & the ID of the file to be processed.

The script generates obtains your site ID, web ID and the document unique ID then creates a JSON payload like below and sends it as a POST request to: the API endpoint <your site url>/_api/machinelearning/workItems

Once the script has completed you will recieve a retuned message like below with details of the file indicating it has been queued for processing for Autofill.

Summary

SharePoint Premium Autofill columns is awesome and I cannot wait to see more people becoming aware of it’s power and using it with their files.

I wanted to explore how the Autofill settings are configured behind the scenes, as I see significant benefits in incorporating this into provisioning solutions to programmatically add Autofill columns to libraries.

Some provisioning/prompt suggestions:

I hope the Autofill column configuration will soon be integrated into the field properties, which I’m confident will happen in due time! This change would allow Autofill columns to be reused as site columns and enable centralized updates. Although the current setup, with all Autofill settings in the list property bag, is less than ideal, it is manageable using the patterns and APIs demonstrated in the scripts above. However, for Autofill to advance to the next level, these properties need to be stored within the field itself.

See my other blogs for other methods/scripts to administrate other SharePoint Premium functionality through PowerShell/Power Automate. Add these to your Provisioning Solutions or code today!

Let me know if this blog is helpful and you are starting to deploy SharePoint Premium Autofill columns programmatically or whether you have any questions or feedback. Happy to help!

This Post Has 3 Comments

  1. Phil Harfield

    great post thanks Leon.

  2. Tony Wu

    Hi Leon,

    I want to share my testing for deploy autofill columns with powershell.
    First this is a great article which explore the black box. But it seems many things have been changed.

    I tested on my syntex site which has enabled the autofill column on document library.
    I found that
    1. I cannot find the related property bag (“Vti_SyntexPoweredColumnPrompts”) on my document library.
    2. I got empty result when I call “/_api/machinelearning/getSyntexPoweredColumnPrompts” api ( So I don’t try /_api/machinelearning/SetSyntexPoweredColumnPrompts )
    3. I can find the autofill property in pnp template file when I use PnP Powershell (Export-PnPListToSiteTemplate) to export the list as template
    4. If you just deploy this list template to a site which never enable autofill feature before, you will get an error saying the site column doesn’t exist because autofill requires 4~5 site columns. So I need first manually create an autofill column prompt on this site to trigger the site column, then I can run “Invoke-PnPSiteTemplate”
    5. It will deploy the autofill in the columns but you still cannot see “autofill” command for your items. You have to manually save the prompt text (this step may trigger something), then you can see the “autofill” command in the command bar.

    Here is my experience to deploy autofill document library to another site

    1. Leon Armston

      Hi Tony

      Thanks for reading my blog and thanks for bringing this to my attention! It looks like the backend APIs have changed! Will edeavour to have a look and try and fix this page/script!

      Thanks

      Leon

Leave a Reply