function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Zachary Alexander 30Zachary Alexander 30 

SOQL 101: Functional Question

I'm trying to understand why I had to deactivate a trigger (code below) in order to prevent a SOQL Queries 101 problem.

It doesn't utilize any SOQL queries (to the best of my knoweldge) and it never changed any field values that could cause other triggers to fire. This is verified beyond shadow of doubt.

Can somebody please help me to understand what is happening?
 
trigger Trig_SetClinicalSignOffUser on Inviscid__Session__c (before insert, before update) {
    
    //Retrieve metadata record
    Trigger_Switch__mdt[] switchList = [SELECT MasterLabel, Turn_Trigger_On__c FROM Trigger_Switch__mdt WHERE MasterLabel = 'Trig_SetClinicalSignOffUser'];
    If(switchList[0].Turn_Trigger_On__c == True) {
        
        If(Trigger.IsInsert) {
            For (Inviscid__Session__c x : Trigger.New) {
                If (x.Inviscid__Status__c == 'Reviewed / Ready for Billing') {
                    x.Inviscid__Clinical_Sign_Off_User__c = UserInfo.getUserId();
                    x.Inviscid__Clinical_Sign_Off_Date__c = System.Now();
                }
            }
        }

        If(Trigger.IsUpdate) {
            For (Inviscid__Session__c x : Trigger.New) {
                Inviscid__Session__c oldX = Trigger.oldMap.get(x.Id);
                If (x.Inviscid__Status__c == 'Reviewed / Ready for Billing' && oldX.Inviscid__Status__c != 'Reviewed / Ready for Billing') {
                    x.Inviscid__Clinical_Sign_Off_User__c = UserInfo.getUserId();
                    x.Inviscid__Clinical_Sign_Off_Date__c = System.Now();
                }
            }
        }
    }
}

 
Zachary Alexander 30Zachary Alexander 30
***Update: Querying the metadata can't be the problem. The record successfully updated when the "switchList[0].Turn_Trigger_On__c" = False. I am at a complete loss to explain what could be happening.