You need to sign in to do that
Don't have an account?
Devendra Hirulkar 3
error Didn't understand relationship 'Subscriptions__r' in FROM part of query call.
hello friends
here i have write a trigger that copy data from parent obj to child when name is match
but in my trigger the following error shows (Didn't understand relationship 'Subscriptions__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.) i dont undestand the problem
so plese help me
here is my trigger
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)
{
listIds.add(childObj.membership_type__c);
}
//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__c FROM Subscriptions__r) FROM Account WHERE ID IN :listIds]);
for (Subscription__c sub : Trigger.new)
{
Account myParentpname = parentpname.get(sub.membership_type__c);
myParentpname.Product_Name__c = Decimal.valueOf(sub.membership_type__c);
}
update parentpname.values();
}
here i have write a trigger that copy data from parent obj to child when name is match
but in my trigger the following error shows (Didn't understand relationship 'Subscriptions__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.) i dont undestand the problem
so plese help me
here is my trigger
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)
{
listIds.add(childObj.membership_type__c);
}
//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__c FROM Subscriptions__r) FROM Account WHERE ID IN :listIds]);
for (Subscription__c sub : Trigger.new)
{
Account myParentpname = parentpname.get(sub.membership_type__c);
myParentpname.Product_Name__c = Decimal.valueOf(sub.membership_type__c);
}
update parentpname.values();
}
For Example :- On Contact we have a lookup field on account. click on Field Account Name. Then below screen will open
from below screen you can check "Child Relationship Name".
Same thing you can check on your custom object.
Sample query with account and contact
select id,name ,( select id,firstname,last from Contacts ) from account
Hope this helps. If yes, mark it as solution so that it can help other's too who have same problem.
Thanks,
Amit Chaudhary
Sumitkumar and amit
in the above trigger the product field (membership_type__c ) is lookup to the subscription but still same error show
(Didn't understand relationship 'Subscriptions__r' in FROM part of query call) i think when we lookup the releationship is created so what is problem
thanks,
devendra
Please check your Subscriptions__c object. On that object hope you have one Account lookup.
Click on that field and then check "Child Relationship Name".
Thanks,
Amit Chaudhary