Diagnose and remediate contracts where HubSpot or Salesforce (SFDC) integration incorrectly persisted hidden conditional field values at creation time, causing destructive mass-cleanup of metadata and activity log spam (70+ field changes) on subsequent UI edits. Use when: HubSpot/SFDC-initiated contracts show unexpected mass field deletions in activity log, metadata linked to questionnaire variables gets silently wiped when a user edits any field, contract shows 'X fields modified / Y metadata fields deleted' from a trivial single-field edit, or HubSpot-initiated contracts contain incorrect default values for fields that should be empty. Trigger phrases: 'incorrect data flowing into contract from HubSpot', 'metadata deleted after editing', 'activity log shows 70+ changes', 'conditional fields saved incorrectly', 'HubSpot contract data wrong', 'allValues vs allValuesExcludingHiddenQuestions', 'sfdc-questionnaire-container overpersisting', 'stale HubSpot deployment'.
When the SFDC/HubSpot integration app is running on a stale version of the code that does not include the fix to exclude hidden conditional fields from intermediate saves, every contract initiated from HubSpot or Salesforce is created with incorrect default values for fields whose visibility conditions were not met at creation time.
Two-stage failure pattern:
At creation (HubSpot/SFDC save): Hidden conditional fields (fields whose conditions aren't met at the time the HubSpot widget is filled) are saved to ContractData with their default values. The main UI flow uses allValuesExcludingHiddenQuestions$ and handles this correctly — only the SFDC/HubSpot flow has this bug (uses allValues$ instead).
On first UI edit: When the contract is later edited in the SpotDraft UI — even editing an unrelated field — the conditional cleanup logic runs correctly, strips out all the incorrectly-saved hidden field values, and syncs back. This generates 70+ field change entries in the Activity Log and silently deletes 10+ metadata fields.
This is the opposite pattern from
questionnaire-hidden-variable-data-loss. That skill covers integration values being wiped (platform clears correct values). This skill covers hidden values being incorrectly persisted (integration saves incorrect values, platform later cleans up correctly).
Affected code path:
SpotDraft/angular-frontendsfdc-questionnaire-container.component.ts, method: getDataUpdateRequest(), ~line 1701this.questionFormService.allValues$ instead of this.questionFormService.allValuesExcludingHiddenQuestions$cursor/prompt-therapy-conditional-logic-03ae⚠️ Run BQ queries one at a time — parallel
execute_sqlcalls return 500 errors.
Check ContractData entries for a contract (Prod US):
SELECT id, source, is_completed, critical_update, created, modified,
JSON_EXTRACT(data, '$') as data_snapshot
FROM `spotdraft-prod.prod_usa_db.public_contracts_v3_contractdata`
WHERE contract_id = {contract_id}
ORDER BY created ASC
LIMIT 20
Look for:
source: Info-Collection, is_completed: False, critical_update: True) — hidden fields incorrectly populated with defaultsCheck contract status and kind:
SELECT id, status, contract_kind, workflow_status, created, modified
FROM `spotdraft-prod.prod_usa_db.public_contracts_v3_contractv3`
WHERE id = {contract_id}
Identify HubSpot-initiated contracts for a workspace in a date range:
SELECT id, status, contract_kind, workflow_status, created, modified
FROM `spotdraft-prod.prod_usa_db.public_contracts_v3_contractv3`
WHERE workspace_id = {workspace_id}
AND created >= '{start_date}'
AND created <= '{end_date}'
ORDER BY created DESC
LIMIT 200
Cross-reference with the contract data source to confirm
Info-Collection(HubSpot) origin.
Check metadata linked to questionnaire variables (to see what was deleted):
SELECT id, key, value, source, created, modified, is_deleted
FROM `spotdraft-prod.prod_usa_db.public_metadata_v2_metadatafield`
WHERE contract_id = {contract_id}
ORDER BY modified DESC
LIMIT 50
| Environment | BQ Project | Dataset | Table Prefix |
|---|---|---|---|
| QA India | spotdraft-qa | qa_india_public | (none) |
| QA USA | spotdraft-qa | qa_usa_public | (none) |
| Prod India | spotdraft-prod | prod_india_db | public_ |
| Prod EU | spotdraft-prod | prod_eu_db | public_ |
| Prod USA | spotdraft-prod | prod_usa_db | public_ |
| Prod MEA | spotdraft-prod | prod_mea_db | (none) |
| Purpose | URL |
|---|---|
| Contract data history (US) | https://api.us.spotdraft.com/admin/contracts_v3/contractdata/?contract_id={contract_id} |
| Contract data detail (US) | https://api.us.spotdraft.com/admin/contracts_v3/contractdata/{contractdata_id}/change/?_changelist_filters=contract_id%3D{contract_id} |
| Workflow admin (US) | https://api.us.spotdraft.com/admin/workflow_v1/workflow/{workflow_id}/change/ |
| Contract detail (US) | https://api.us.spotdraft.com/admin/contracts_v3/contractv3/{contract_id}/change/ |
Use when:
Do NOT use for:
sd_show = false) → use questionnaire-hidden-variable-data-lossGet the contract ID, workspace ID, and cluster from support. Open the contract data in Django Admin: