Draw a Territory and Save It to the Record
Let a sales manager draw a territory on an Avonni Map in a screen flow, save it as a file on the account, and reopen it later to edit.
A sales manager gives a distributor the exclusive zone south of Market Street. From the distributor's account, she opens a flow, traces the zone around the accounts it should cover, and clicks Save territory. The shape is saved as a file on the account, and the flow shows it again the next time she opens it.

Before you start
The map uses Type Leaflet: drawing does not exist on Google Maps. See Map.
On Account, a text field to remember the saved file, for example Territory File Id (
Territory_File_Id__c, Text, 18 characters).The users who draw can create Files on the account.
Steps
Add the map
Add a Screen element after Get_Account and drag an Avonni Map onto it. Name it map.
In the Properties tab, set Type to Leaflet.
Set Data Source to Query on Account, for example where Billing City equals
San Francisco, so the manager sees the accounts she is enclosing.In Data Mappings, map Title to Account Name, and under Location map Latitude to Billing Latitude and Longitude to Billing Longitude.
Save the drawing as a file on the account
Still in Draw, turn on Save as Content Document. Its settings appear below it.
Content Document Id
{!Get_Account.Territory_File_Id__c}
Empty the first time, so a new file is created. Filled later, so the saved shape opens again and Save updates that same file
Content Document Title
{!TerritoryTitle}
The file reads "Territory - " and the account name
Content Document Linked Entity Id
{!recordId}
The file is attached to the account
Save Button Label
Save territory
The button under the map

Store the file Id on the account
After the screen, the Map's Content Document Id output holds the saved file.
Add a Decision after the screen: continue only when
{!map.contentDocumentId}Is Null isFalse. A manager who closes the screen without saving changes nothing.On that path, add an Update Records element: Account where Account ID equals
{!recordId}, set Territory File Id to{!map.contentDocumentId}.
Save and test
Open an account, pick the polygon tool and click around a few accounts on the map. Click the first point again to close the shape.
Click Save territory. A message confirms "Your content document has been created." The file appears in the account's Files.
Click Next. The account's Territory File Id is filled.
Open the flow again from the same account. The territory is back on the map. Move a corner with Edit and click Save territory: the message now reads "Your content document has been updated."
Troubleshooting
Related tutorials
Drag a Pin to Update a Location: the other way to save a change made on the map.
Add Search and Filters to a Map: show only the accounts that matter while drawing.
Plan a Route from the Map: visit the accounts inside the territory.
Was this helpful?
