Loading

Consumer Goods Cloud: Flow update on Event linked to a Visit fails with "This event refers to a visit. Due to visit validation, it cannot be changed."

Publish Date: May 24, 2026
Description

This article explains why a record-triggered Flow fails with "FIELD_CUSTOM_VALIDATION_EXCEPTION: This event refers to a visit. Due to visit validation, it cannot be changed." when it tries to update an Event [Event] record linked to a Visit [cgcloud__Visit__c] in Consumer Goods Cloud, and how to redesign the automation so the update succeeds.

Customers describe this as: "Flow fails when trying to update the Event record — error element: updateVisit (FlowRecordUpdate), error type: FIELD_CUSTOM_VALIDATION_EXCEPTION" and "After-create Flow updates an Event linked to a Visit but the update is blocked by hidden Consumer Goods Cloud managed logic, most likely the managed cgcloud EventTrigger".

Trigger conditions:
- A record-triggered Flow on the Event object runs after create or update.
- The Event has its WhatId field set to a Visit [cgcloud__Visit__c] record.
- The Flow (or a subflow) executes a Record Update element against that Event.
- The managed trigger [cgcloud.EventTrigger] (namespace cgcloud, package: Consumer Goods Cloud) raises the validation error during the AfterUpdate phase.

There is no custom Validation Rule on the Event object that produces this message; the restriction is enforced inside the managed package code and is intentional — once an Event is associated with a Visit, the package treats the Event as part of the Visit's locked record set so that Visit validation, scheduling, and signature integrity are preserved (consistent with the Visit lock behaviour documented for Consumer Goods Cloud and the analogous VisitLockHandler / VisitValidationHandler pattern in the Salesforce field execution model).

A related failure mode is "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: cgcloud.EventTrigger: execution of AfterUpdate caused by: System.NullPointerException" when the Flow updates the WhatId of an Event from null to a Visit Id in the same transaction; the managed trigger references the prior (null) WhatId and the update fails.

Affected editions: Lightning Experience in Professional, Enterprise, and Unlimited editions with Consumer Goods Cloud enabled and the cgcloud managed package installed.

Resolution

Do not attempt to update an Event record after its WhatId points to a Visit. The managed [cgcloud.EventTrigger] enforces visit validation and will reject the DML. Redesign the automation using one of the two patterns below.

Cause 1: Record-triggered Flow updates an Event that is already linked to a Visit

Use a before-save flow that sets Event field values in the same transaction that creates the Event, so no second DML against the linked Event is needed.

  1. From Setup, enter Flows in the Quick Find box, then select Process Automation > Flows.
  2. Open the failing Flow.
  3. Change the Flow trigger from "A record is created" with "Actions and Related Records" to "A record is created" with "Fast Field Updates" (before-save).
  4. In the before-save Flow, use a Get Records element to load the Visit [cgcloud__Visit__c] referenced by the Event's WhatId [WhatId], retrieving Visit Template [cgcloud__Visit_Template__c] and the related Visit Template Name [cgcloud__Visit_Template__r.Name].
  5. Use an Assignment element to set Type [Type] on the in-memory $Record to the Visit Template Name value.
  6. Remove the Record Update element ("updateVisit") and the subflow that performs DML on the Event. Before-save Flows commit the field change with the original insert and do not call the [cgcloud.EventTrigger] AfterUpdate path that raises the visit-validation error.
  7. Activate the Flow.

 

Cause 2: Flow must run after create and cannot be converted to before-save (for example, it depends on the Event Id or runs additional logic)


Move the field value to a custom field on the Event that the managed trigger does not protect, or perform the update before WhatId is set to a Visit.

  1. From Setup, go to Object Manager > Event > Fields & Relationships and confirm whether you can store the value on a custom Event field [Custom_Type__c] instead of the standard Type [Type] picklist. Standard Event picklist values for Consumer Goods Cloud are documented under "Add Values to Event Type Picklist" (Training, Vacation, Sickness, Outlook Call).
  2. If the Event must be linked to a Visit and you also need Type [Type] populated, split the work into two separate transactions:
    1. Create the Event without WhatId, set Type [Type] in a before-save Flow.
    2. In a separate after-save Flow or asynchronous path (Run Asynchronously path on a record-triggered Flow), set WhatId [WhatId] to the Visit Id. Once WhatId points to the Visit, do not update the Event again.
  3. Do not chain a subflow that updates the Event after WhatId is set — the managed trigger blocks it.

 

Cause 3: Flow updates the WhatId of an Event from null to a Visit Id and the trigger throws a NullPointerException


This surfaces as "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: cgcloud.EventTrigger: execution of AfterUpdate caused by: System.NullPointerException". The managed trigger reads Trigger.old.WhatId and the prior value is null.

  1. Change the Flow so the Event is created with WhatId [WhatId] already populated with the Visit Id, instead of creating the Event first and updating WhatId in a second step.
  2. If the Visit Id is not known at Event creation, create the Visit first, then create the Event with WhatId set to the Visit Id in a single Create Records element.
  3. Re-run the scenario.

 

Verification


Confirm the issue is resolved by reproducing the original failure: create a new Event whose WhatId references a Visit and trigger the redesigned automation. The Event must be created (or its field set) without raising "FIELD_CUSTOM_VALIDATION_EXCEPTION: This event refers to a visit. Due to visit validation, it cannot be changed." and the Flow interview must complete with status Finished.

Knowledge Article Number

005385137

 
Loading
Salesforce Help | Article