Bad rightOperand type: got SObjectScriptRow

I just want to know what is SObjectScriptRow! All I can find about it is this question.

I’m building an invocable method to be used from a process, where I have one input parameter: a list of an sObject type.

Here is the code:

@InvocableMethod(label='Update fees' description='It takes a list of parent fees and updates the related child fees')
global static void ParentFeeUpdateChildFees(List<Parent_Fee__c> parentFees) {

    List<Child_Fee__c> childFees = [SELECT Parent_Fee__c, Fee_Percentage__c, Charge__c FROM Child_Fee__c WHERE Parent_Fee__c IN :parentFees];
    Map<Id,Parent_Fee__c> parentFeeMap = new Map<Id,Parent_Fee__c>(parentFees);

    Parent_Fee__c parentFee;
    for (Child_Fee__c childFee : childFees){                
        parentFee = parentFeeMap.get(childFee.Parent_Fee__c);
        childFee.Fee_Percentage__c = parentFee.Fee_Percentage__c;
        childFee.Charge__c = parentFee.Charge__c;
    }
    update childFees;
}

And I’m getting the following error

FLOW_ELEMENT_ERROR An Apex error occurred: System.UnexpectedException: Bad rightOperand type: got SObjectScriptRow: operator e dataType 1

So, I think the error is being thrown at the :parentFees meaning I can’t query by the parameter because I’m actually getting a list of SObjectScriptRow instead of a list of sObject.

I can simply change the method to receive a list of Ids and this will work, but It will add an extra query to get the Parent Fees which I want to avoid.

I would appreciate any input in this, or maybe I’m mistaken. Thanks!

Answer

Ran into the same issue and resolved by changing my method parameter from List<SObject> to List<Id>, worked like a charm

Attribution
Source : Link , Question Author : Jose , Answer Author : Tony Kirumba

Leave a Comment