-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
4Questions
-
1Replies
How to write Genaric Trigger on Parent Object to show error if child Objects fields having null.
How to write Genaric Trigger on Parent Object to show error if child Objects fields having null.
Parent Object is Opp
Child Objects are opp.lineitems [Field1__c,Field__2] and GD_Val__c[FieldJ__c,FieldZ__c]
If child Objects field are blank and child objects having attachments then have to show error msg[Update Fields & Remove Attmt] while updating User__c Field on Parent[Opp]
Parent Object is Opp
Child Objects are opp.lineitems [Field1__c,Field__2] and GD_Val__c[FieldJ__c,FieldZ__c]
If child Objects field are blank and child objects having attachments then have to show error msg[Update Fields & Remove Attmt] while updating User__c Field on Parent[Opp]
-
- anil Anil5
- May 07, 2019
- Like
- 0
- Continue reading or reply
How to write trigger.bellow requirement,any forward link or code
trigger act as Rollupsumary functionality(sum,count,min,max) for lookup Relationship between two object with bestpractices
-
- anil Anil5
- July 12, 2015
- Like
- 0
- Continue reading or reply
Error: Compile Error: Arithmetic expressions must use numeric arguments at line 15 column 13
trigger RollUpSummaryUpdate on Company__c(after insert,after update){
double totalSum = 0;
Set<Id> Parentids = New Set<Id>();
for(integer i=0;i<Trigger.new.Size();i++){
Parentids.add(Trigger.new[i].Clients__c);
}
List<Client__c> AP = [SELECT ID,(SELECT ID FROM Company__r) FROM Client__c WHERE ID=:Parentids];
for(Client__c apUpdates:AP){
totalSum += Company__c.Amount__c;
apUpdates.Sum__c =totalSum;
}
Update AP;
}
-
- anil Anil5
- July 11, 2015
- Like
- 0
- Continue reading or reply
Error: Compile Error: Identifier name is reserved: object at line 9 column 28
I am perform trigger operation on Company obj, trigger acts like rollup summary functionallity--->sum
Company is chlid
client is parent R.S:Lookup
How to slove this error and any forward link for trigger rollup summary functionallity
trigger rollupTrigger on Company__c (after insert, after update, after delete) {
double totalSum = 0;
Company__c myObjects = trigger.new;
if(Trigger.isUpdate || Trigger.isInsert)
{
for(Company__c object : myObjects) //assume more than 1 record in trigger.new
{
for(Client__c parent : [select Id, Name from Client__c where Id = :object.Clients__c]) //get the parent object
{
for(Company__c childObject : [select Id, Name, Amount__c from Company__c where Clients__c = :parent.Id]) //get all the objects that belong to the parent object
{
totalSum += childObject.Amount__c; //sum the field of choice
}
parent.Sum__c = totalSum; //set the total in the parent
update parent // update the parent
}
}
}
else if(Trigger.isDelete)
{
Company__c [] oldObjects = Trigger.old;
for(Company__c oldObject :oldObjects) //assume deletion of more than 1 record
{
for (Client__c parentObject : [select id, Name, Sum__c where Id = :oldObject.Clients__c]) //get the parent object(s)
{
for (Company__c childObject : [select id, Name, Amount__c from Company__c where Clients__c = :parentObject.id]) //get the records that belong to the parent
{
totalSum += childObject.Amount__c; //sum the fields after a record has been deleted
}
parentObject.Sum__c = totalSum; //set new total in parent
update parentObject; //update parent
}
} //end oldObject for loop
} //end else if
} //end trigger
Company is chlid
client is parent R.S:Lookup
How to slove this error and any forward link for trigger rollup summary functionallity
trigger rollupTrigger on Company__c (after insert, after update, after delete) {
double totalSum = 0;
Company__c myObjects = trigger.new;
if(Trigger.isUpdate || Trigger.isInsert)
{
for(Company__c object : myObjects) //assume more than 1 record in trigger.new
{
for(Client__c parent : [select Id, Name from Client__c where Id = :object.Clients__c]) //get the parent object
{
for(Company__c childObject : [select Id, Name, Amount__c from Company__c where Clients__c = :parent.Id]) //get all the objects that belong to the parent object
{
totalSum += childObject.Amount__c; //sum the field of choice
}
parent.Sum__c = totalSum; //set the total in the parent
update parent // update the parent
}
}
}
else if(Trigger.isDelete)
{
Company__c [] oldObjects = Trigger.old;
for(Company__c oldObject :oldObjects) //assume deletion of more than 1 record
{
for (Client__c parentObject : [select id, Name, Sum__c where Id = :oldObject.Clients__c]) //get the parent object(s)
{
for (Company__c childObject : [select id, Name, Amount__c from Company__c where Clients__c = :parentObject.id]) //get the records that belong to the parent
{
totalSum += childObject.Amount__c; //sum the fields after a record has been deleted
}
parentObject.Sum__c = totalSum; //set new total in parent
update parentObject; //update parent
}
} //end oldObject for loop
} //end else if
} //end trigger
-
- anil Anil5
- July 11, 2015
- Like
- 0
- Continue reading or reply
How to write Genaric Trigger on Parent Object to show error if child Objects fields having null.
How to write Genaric Trigger on Parent Object to show error if child Objects fields having null.
Parent Object is Opp
Child Objects are opp.lineitems [Field1__c,Field__2] and GD_Val__c[FieldJ__c,FieldZ__c]
If child Objects field are blank and child objects having attachments then have to show error msg[Update Fields & Remove Attmt] while updating User__c Field on Parent[Opp]
Parent Object is Opp
Child Objects are opp.lineitems [Field1__c,Field__2] and GD_Val__c[FieldJ__c,FieldZ__c]
If child Objects field are blank and child objects having attachments then have to show error msg[Update Fields & Remove Attmt] while updating User__c Field on Parent[Opp]
- anil Anil5
- May 07, 2019
- Like
- 0
- Continue reading or reply