• adish2507
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

Dear All

 

Faced an Error ...while writing code to execute the trigger ..please advice

 

Error Message : ErrorError: Compile Error: Invalid field Units_Sold__c for SObject Line_Items__c at line 16 column 70

 

@isTest private class TestHandleProductPriceChange { static testMethod void testPriceChange() { Invoice_Statement__c invoice = new Invoice_Statement__c (Status__c = 'Negotiating'); insert invoice; Merchandise__c[] products = new Merchandise__c[]{ new Merchandise__c(Name = 'item 1', Description__c = 'test product 1', Price__c = 10, Total_Inventory__c = 10), new Merchandise__c(Name = 'item 2', Description__c = 'test product 2', Price__c = 11, Total_Inventory__c = 10) }; insert products; Line_Items__c[] lineItems = new Line_Items__c[] { new Line_Items__c(Invoice_Statement__c = invoice.id, Merchandise__c = products[0].id, Unit_Price__c = 10, Units_Sold__c = 3), new Line_Items__c(Invoice_Statement__c = invoice.id, Merchandise__c = products[1].id, Unit_Price__c = 11, Units_Sold__c = 6) }; insert lineItems; products[0].price__c = 20; Test.startTest(); update products; Test.stopTest(); lineItems = [SELECT id, unit_price__c FROM Line_Items__c WHERE id IN :lineItems]; system.assert(lineItems[0].unit_price__c == 10); } }

 

regards

 

Jerome John

Hi

 

Am getting the following error while creating APEX Trigger

 

Error: Compile Error: sObject type 'Line_Item__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 3 column 1

Apex Trigger Subject :

 

trigger HandleProductPriceChange on Merchandise__c (after update) {

List<Line_Item__c> openLineItems =

[SELECT j.Unit_Price__c, j.Merchandise__r.Price__c

FROM Line_Item__c j

WHERE j.Invoice_Statement__r.Status__c = 'Negotiating'

AND j.Merchandise__r.id IN :Trigger.new

FOR UPDATE];

for (Line_Item__c li: openLineItems) {

if ( li.Merchandise__r.Price__c < li.Unit_Price__c ){

li.Unit_Price__c = li.Merchandise__r.Price__c;

}

}

update openLineItems;

}

 

regards

 

Jerome John

 

Dear All

 

Faced an Error ...while writing code to execute the trigger ..please advice

 

Error Message : ErrorError: Compile Error: Invalid field Units_Sold__c for SObject Line_Items__c at line 16 column 70

 

@isTest private class TestHandleProductPriceChange { static testMethod void testPriceChange() { Invoice_Statement__c invoice = new Invoice_Statement__c (Status__c = 'Negotiating'); insert invoice; Merchandise__c[] products = new Merchandise__c[]{ new Merchandise__c(Name = 'item 1', Description__c = 'test product 1', Price__c = 10, Total_Inventory__c = 10), new Merchandise__c(Name = 'item 2', Description__c = 'test product 2', Price__c = 11, Total_Inventory__c = 10) }; insert products; Line_Items__c[] lineItems = new Line_Items__c[] { new Line_Items__c(Invoice_Statement__c = invoice.id, Merchandise__c = products[0].id, Unit_Price__c = 10, Units_Sold__c = 3), new Line_Items__c(Invoice_Statement__c = invoice.id, Merchandise__c = products[1].id, Unit_Price__c = 11, Units_Sold__c = 6) }; insert lineItems; products[0].price__c = 20; Test.startTest(); update products; Test.stopTest(); lineItems = [SELECT id, unit_price__c FROM Line_Items__c WHERE id IN :lineItems]; system.assert(lineItems[0].unit_price__c == 10); } }

 

regards

 

Jerome John

Hi

 

Am getting the following error while creating APEX Trigger

 

Error: Compile Error: sObject type 'Line_Item__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 3 column 1

Apex Trigger Subject :

 

trigger HandleProductPriceChange on Merchandise__c (after update) {

List<Line_Item__c> openLineItems =

[SELECT j.Unit_Price__c, j.Merchandise__r.Price__c

FROM Line_Item__c j

WHERE j.Invoice_Statement__r.Status__c = 'Negotiating'

AND j.Merchandise__r.id IN :Trigger.new

FOR UPDATE];

for (Line_Item__c li: openLineItems) {

if ( li.Merchandise__r.Price__c < li.Unit_Price__c ){

li.Unit_Price__c = li.Merchandise__r.Price__c;

}

}

update openLineItems;

}

 

regards

 

Jerome John