Introducing Salesforce to new Westminster constituencies

Boundary map of the Westminster constituency of Beaconsfield

Following this year’s review by the Boundary Commissions for England, Wales, Scotland, and Northern Ireland, the next General Election will be fought on new constituencies for the first time since 2010.

Full data isn’t published by the ONS yet. But the Lib Dems use our well-loved online interface to Salesforce, Lighthouse, to manage selection processes for election candidates and need to have the new constituency data to plan for the next GE, in addition to the existing constituencies on which any by-elections before the next GE will still be fought.

In order to import the new data into Salesforce, they naturally turned to Prater Raines for our expertise in political geography and API and database design.

If you work with political geography data and Salesforce, need your own organisation structure mapped, or your online campaign would benefit from enabling supporters to email MPs based on their geographic location, get in touch.

Background to the changes

The boundary commissions review constituencies every eight to twelve years to try to guarantee a fair number of electors across each of the seats in parliament. Although reviews took place between 2011 and 2013, and again between 2016 and 2018, both tasked with reducing the number of constituencies from 650 to 600, neither review was implemented by the government, making the 2023 review the first change to boundaries since before the 2010 election. There are also local authority ward boundary changes from May which needed importing into Lighthouse at the same time.

Cleaning up the data

Data released by the Office for National Statistics has improved over the years. It’s easier to find and the format hasn’t changed too much in recent years. It always used to be an issue that every time you went back to revise your database, the format of everything was different.

But it’s still littered with errors. There are duplicate rows where sometimes the correct entry is first and the old one second, sometimes the other way round. Entries have the wrong parent records, sometimes because they weren’t updated when the parent changed, sometimes just for fun. Data for Scotland and Wales is sometimes bundled with England and sometimes separate. Dates prior to 1900 (and, for good measure, some other dates completely at random) are entered in a different format, because date handling in Excel is stupid. There are typos galore. Some areas are just missing.

At some point someone global search and replaced “ONS” with “LGBC” in the Parliamentary Constituencies report. It now includes the Parliamentary CLGBCtituency of BeacLGBCfield.

Once we’ve dealt with all this we import all the area information, the location of every postcode in the country and which areas it is in. We fetch shapefiles for each area and import them into MySQL so we can render pretty maps in Lighthouse and the Lib Dems’ portfolio of websites. For the new constituencies, the mapping to postcodes isn’t available yet, so we calculated this from the area definitions and the postcode locations.

Feeding it into Salesforce

We provide the Lib Dems with an API which, given a postcode, returns area information. We also maintain the Apex required to update area links from the API whenever a contact’s address is changed in Salesforce. The party’s federated structure breaks the UK up into local parties on artibrary area boundaries so we maintain a definitive list of their bespoke areas which the API can also use to assign new members to the correct organisation. And, every time boundaries change, we automate bulk updates of the entire membership database so everyone remains assigned to the correct electoral areas.

Supporting the system behind the scenes

The whole thing needs routine updates on a regular basis. New postcodes are released monthly, ward boundaries change each year, and the organisation’s structure can be altered each year at local party AGMs. The ONS introduces new and interesting mistakes every time. We’re always on hand to answer questions, fix problems and keep stuff ticking over. You can count on us.