You need to sign in to do that
Don't have an account?

delete list of child records from Parent where Unit price=0 and sunsegment='Undefined'
Hi All I am trying to use the below code to delete the Billing Item.
Billing item is having a Master-detail with BillDoc.and also a rollup is there in Billing Doc.
I have written the following code.It is working where we have single Billing Item.but when there are Billing Item with valuesand
Subsegment!=Undefined .It is not working .
public class DeleteBillingItems
{
@InvocableMethod
public static void BIDelete(List<Id> BIIds)
{
List<BillingItem__c> BI =[select id,UnitPrice__c,Sub_Segment__c,Gross__c,NettoAmount2__c from BillingItem__c
where BillingItem__c.id in :BIIds
and UnitPrice__c=0 and Sub_Segment__c='Undefined' and Gross__c=0 and NettoAmount2__c =0 ];
delete BI;
}
}
Please suggest.
Thanks
Billing item is having a Master-detail with BillDoc.and also a rollup is there in Billing Doc.
I have written the following code.It is working where we have single Billing Item.but when there are Billing Item with valuesand
Subsegment!=Undefined .It is not working .
public class DeleteBillingItems
{
@InvocableMethod
public static void BIDelete(List<Id> BIIds)
{
List<BillingItem__c> BI =[select id,UnitPrice__c,Sub_Segment__c,Gross__c,NettoAmount2__c from BillingItem__c
where BillingItem__c.id in :BIIds
and UnitPrice__c=0 and Sub_Segment__c='Undefined' and Gross__c=0 and NettoAmount2__c =0 ];
delete BI;
}
}
Please suggest.
Thanks
Thanks for quick reply.
My scenario is to delete Billing Item(Child of Billing Doc) where Unit Price=0 and Sunsegment=Undefecords ined.
Billing Item and Billing doc has one to Many relation.so when I am creating any billing item with the mentioned criteria.it is getting deleted nut for existing records getting error.
What is List<Id> BIIds, is it list of Billing Item Ids or list of Billing Doc Ids? list of Billing Item
Sub_Segment__c='Undefined'. Are you sure you have records in the system with this criteria?yes
Gross__c and NettoAmount2__c , are these fields on Billing Doc or Billing Item?Fields in Billing Item and rollup is there in Billing doc