You need to sign in to do that
Don't have an account?
Dritter
Handled nested records from a query
I have the following method that finds an order along with it's order items (child object).
Error: A non-foreign key field cannot be referenced in a path expression: ccrz__E_OrderItems__r
public static ccrz__e_Order__c getOrderDetails (String orderId){ ccrz__e_Order__c order = [SELECT id, name, ccrz__OriginatedCart__c, ccrz__Storefront__c, ccrz__OrderDate__c, Pay_In_Deposit__c, Do_not_send_confirmation_email__c, Activate_w_Balance_Due_c__c, SubTotalAmount2__c, ccrz__ShipAmount__c, ccrz__TotalAmount__c, ccrz__TotalSurcharge__c, Tuition_Fee__c, UpfrontCost__c, Amount_Charged__c, ccrz__Account__c, CreatedById, ccrz__BillTo__c, ccrz__ShipTo__c, (SELECT id, ccrz__Product__c, ccrz__Category__c, Transaction_Code__c, ccrz__StoreId__c, ccrz__Subscription_Start_Date__c, Flex_End_Date__c, ccrz__ItemTotal__c, ccrz__Price__c, AmountPaid__c, ccrz__SubAmount__c FROM ccrz__e_orderitems__r) FROM ccrz__e_Order__c WHERE id =: orderId LIMIT 1]; return order; }I'm trying to loop through the orderItems and call another method, but I'm getting the following error in the compiler.
Error: A non-foreign key field cannot be referenced in a path expression: ccrz__E_OrderItems__r
} else if (order != NULL){ for (ccrz__E_Orderitem__c orderItemProducts: order.ccrz__e_orderitems__r) { cc_kapmp_order_ProductDAO.getSpecForProductId (order.ccrz__e_orderitems__r.ccrz__Product__c, 'Free Trial Product Id'); } }Any thoughts on why is doesn't like ccrz__E_OrderItems__r?
Please mark the thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.