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

I want to check if Unit price has Null value or Unit price = 0 then I want to delete the Billing Item.
Hi All,
I want to check if Unit price has Null value or Unit price = 0 then I want to delete the Billing Item.
For that I have written the below code but getting error
public class DeleteBillingItems
{
@InvocableMethod
public static void BIDelete(List<Id> BIIds)
{
List<BillingItem__c> BI =[select id,BillingDocumentId__c,UnitPrice__c,Sub_Segment__c,Gross__c,NettoAmount2__c from BillingItem__c
where BillingItem__c.id in :BIIds and BillingDocumentId__c!=Null
and UnitPrice__c=0 || IsNull(UnitPrice__c)=True and Sub_Segment__c='Undefined' and Gross__c=0 and NettoAmount2__c =0 ];
delete BI;
}
}
Error:Missing ']' at '||' at line 8 column 43
I want to check if Unit price has Null value or Unit price = 0 then I want to delete the Billing Item.
For that I have written the below code but getting error
public class DeleteBillingItems
{
@InvocableMethod
public static void BIDelete(List<Id> BIIds)
{
List<BillingItem__c> BI =[select id,BillingDocumentId__c,UnitPrice__c,Sub_Segment__c,Gross__c,NettoAmount2__c from BillingItem__c
where BillingItem__c.id in :BIIds and BillingDocumentId__c!=Null
and UnitPrice__c=0 || IsNull(UnitPrice__c)=True and Sub_Segment__c='Undefined' and Gross__c=0 and NettoAmount2__c =0 ];
delete BI;
}
}
Error:Missing ']' at '||' at line 8 column 43
Please try this. I have done some minor change in query
public class DeleteBillingItems
{
@InvocableMethod
public static void BIDelete(List<Id> BIIds)
{
List<BillingItem__c> BI =[select id,BillingDocumentId__c,UnitPrice__c,Sub_Segment__c,Gross__c,NettoAmount2__c from BillingItem__c
where BillingItem__c.id in :BIIds and BillingDocumentId__c!=Null
and UnitPrice__c=0 || UnitPrice__c=null and Sub_Segment__c='Undefined' and Gross__c=0 and NettoAmount2__c =0 ];
delete BI;
}
}
Tried with that also not working
Here is your code with small changes. Hope this will help for you.
Thank you
Ajay Dubedi
Try this,
public class DeleteBillingItems
{
@InvocableMethod
public static void BIDelete(List<Id> BIIds)
{
List<BillingItem__c> BI =[select id,BillingDocumentId__c,UnitPrice__c,Sub_Segment__c,Gross__c,NettoAmount2__c from BillingItem__c
where BillingItem__c.id in :BIIds and BillingDocumentId__c!=Null
and (UnitPrice__c=0 OR UnitPrice__c=null) and Sub_Segment__c='Undefined' and Gross__c=0 and NettoAmount2__c =0 ];
delete BI;
}
}