+ Start a Discussion
Devendra Hirulkar 3Devendra Hirulkar 3 

Didn't understand relationship 'Subscription__r' in FROM part of query call.

hello friends in the following trigger the error show
(Didn't understand relationship 'Subscription__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.)
the product field is lookup to the subscription but still it show the error 

trigger copyproductnametoaccount on Subscription__c (after insert,after update) //You want it on update too, right?
  Map<ID, Account> parentpname = new Map<ID, Account>(); //Making it a map instead of list for easier lookup
  List<Id> listIds = new List<Id>();

  for (Subscription__c childObj : Trigger.new)

  //Populate the map. Also make sure you select the field you want to update, Rollno
  //The child relationship is more likely called Classes__r (not Class__r) but check
  //You only need to select the child classes a if you are going to do something for example checking whether the Classes in the trigger is the latest
    parentpname = new Map<Id, Account>([SELECT id, Product_Name__c,(SELECT ID, membership_type_del__c FROM Subscription__r) FROM Account WHERE ID IN :listIds]);

  for (Subscription__c sub : Trigger.new)
     Account myParentpname = parentpname.get(sub.membership_type_del__c);
     myParentpname.Product_Name__c = Decimal.valueOf(sub.membership_type_del__c);
  update parentpname.values();
On Subscription__c, go to the account relationship filed. And check the child relationship name. it might be Subscriptions__r