• The Walrus
  • NEWBIE
  • 75 Points
  • Member since 2011

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

I have the following query and debug statements:

 

Invoice_Balance__c[] b = [SELECT Invoice_Balance_Date__c, Invoice_Balance_Amount__c, Invoice__r.Name 
FROM Invoice_Balance__c WHERE Invoice__r.Name LIKE :xxx
ORDER BY Invoice_Balance_Date__c DESC NULLS LAST LIMIT 1];
//
System.debug('b: '+b);
System.debug('b: '+Invoice_Balance__c.Invoice_Balance_Amount__c[b]);

 The first system.debug statement works, but the second generates this error:

 

Error: Compile Error: Expression must be a list type: Schema.SObjectField at line 18 column 20

 

What do I need to change in the second statement?  Thanks

 

I built a very simple apex class, based on a test class, to add a row of data to a database table:

 

Private class Invoice_Balance_Record_Inserter {
static void validateInvoice_Payment() {
Invoice_Balance__c i = new
Invoice_Balance__c(Name='I110811EP3-1', 
Invoice__c = 'a00U00000020IgSIAU',
Invoice_Balance_Amount__c=300);
insert i;
 }
}

 The code will run, either in system log or in force ide, but I don't end up with a record in Invoice_Balace__c.   Is there a way I can run this code that will result in a record being added?  thanks

Hello,

 

I have a Master-Detail relationship between an Invoice custom object and a set of Invoice Balance records.  I've written

a select statement that allows me to look up the latest balance record - but uses a literal to identify the master record - and would can run it from a trigger when before a new entry for this master is inserted.  Here is the class code:

public class InvoicePayment {
public static void calculatePayment(InvoiceBalance__c[] invoicepayments) {
invoice__c[] a = [SELECT Name, (SELECT Invoice__c, InvoiceBalanceDate__c, Invoice_Balance_Amount__c 
FROM Invoice_Balances__r) FROM Invoice__c];
System.debug('a: '+a);

Invoicebalance__c[] b = [SELECT InvoiceBalanceDate__c, Invoice__r.Name 
FROM InvoiceBalance__c WHERE Invoice__r.Name LIKE 'xxx'
ORDER BY InvoiceBalanceDate__c DESC NULLS LAST LIMIT 1];

System.debug('b: '+b);
for (InvoiceBalance__c i :invoicepayments) { 
i.Paid_Since_Last_Report__c = i.Invoice_Balance_Amount__c * 0.9;
}
}
}

 The class runs fine, but I can't figure out how to substitute 'xxx' with the invoice value from the form.  Is there a pointer to

the field value of the record you are trying to insert?  Or do i i have to access visualforce in some way?   Any assistance is appreciated.

Hello,

 

I have a simple trigger that I am building which somewhat mimics the example in the apex code manual introductory chapters.   For simplicity in building it, I am starting by doing exactly what the example does - reducing a value by 10%.  However, instead of putting the result back into the field used as input to the calculation, I am putting the result in a different field.  Here is the class code:

 

public class InvoicePayment {
      public static void calculatePayment(InvoiceBalance__c[] invoicepayments) {
           for (InvoiceBalance__c i :invoicepayments) {
                                 i.Paid_Since_Last_Report__c = i.Invoice_Balance_Amount__c * 0.9;
                                }
                  }
}

 

Here is the trigger:

 

trigger InvoicePaymentTrigger on InvoiceBalance__c (before insert) {
                            InvoiceBalance__c[] invoicepayments = Trigger.new;
                            InvoicePayment.calculatePayment(invoicepayments);
}



 

And here is the test method:

 

@isTest
Private Class InvoicePaymentTestClass {

static testMethod void validateInvoicePayment() {

InvoiceBalance__c i = new
InvoiceBalance__c(Name='I110811EP3-3', 
Invoice__c = 'a01U000000180Wy',
Invoice_Balance_Amount__c=300);
System.debug('Paid Since Last Report before inserting new balance record:' + i.Paid_Since_Last_Report__c);
//Insert Balance Record
insert i;
//display the payment after the insert
System.debug('Invoice_Balance_Amount__c after inserting new balance record:' + i.Invoice_Balance_Amount__c); 
System.debug('Paid Since Last Report after inserting new balance record:' + i.Paid_Since_Last_Report__c);
//Test that the trigger correctly fired
System.assertEquals(270, i.Paid_Since_Last_Report__c);
}
}

When I run the trigger manually, it works.  But when I run the trigger, the value in Paid_Since_Last_Report__c is null.

 

What am I doing wrong in my test method?  Thanks

 

Hello,

 

I am getting started with the IDE after doing some development in the online environment.  I have force IDE installed and I can sync my schema so that if I make a change to the schema on the online side, the change to the schema shows up in the IDE when I refresh the schema. 

 

I made a couple of classes in the online environment, but I dont know how to get them into the force IDE environment.  I tried the Force.com options accessed by right clicking on the src folder or subfolders in the Project Explorer, but these all generate a variety of errors. 

 

Is there something else I need to do to set up the syncronization?    All my project properties seem to be in order.  Thanks

 

I'm sure it's me, but...

 

On pages 27-29 of the Apex language reference manual, there is an example that creates a custom object (Book_c and a custom field within the object Price_c).   Then,  a sample for loop within an apex class is demonstrated with the code below:

 

public class MyHelloWorld {  

    public static void applyDiscount(Book_c[] books) {

 for (Book_c  b  :books) 

 {  

   b.Price_c *= 0.9;

    }

  }

}

 

However, when I try to build this code , I get the following error:

 

Error:Compile Error: Invalid type: Book_c at line 3 column 6

 

Like I said, I'm sure it's me but...why is this not working?

 

Thanks for any assistance

I'm sure it's me, but...

 

On pages 27-29 of the Apex language reference manual, there is an example that creates a custom object (book_c and a custom field within the object Price_c).   Then,  a sample for loop within an apex class is demonstrated with the code below:

 

public class MyHelloWorld {
  public static void applyDiscount(Book_c[] books){
for (Book_c  b  :books) {
    b.Price_c *= 0.9; 
   }
  }   
}

 

However, when I try to build this code , I get the following error:

 

Error:Compile Error: Invalid type: Book_c at line 3 column 6

 

Like I said, I'm sure it's me but...why is this not working?

 

Thanks for any assistance

I have the following query and debug statements:

 

Invoice_Balance__c[] b = [SELECT Invoice_Balance_Date__c, Invoice_Balance_Amount__c, Invoice__r.Name 
FROM Invoice_Balance__c WHERE Invoice__r.Name LIKE :xxx
ORDER BY Invoice_Balance_Date__c DESC NULLS LAST LIMIT 1];
//
System.debug('b: '+b);
System.debug('b: '+Invoice_Balance__c.Invoice_Balance_Amount__c[b]);

 The first system.debug statement works, but the second generates this error:

 

Error: Compile Error: Expression must be a list type: Schema.SObjectField at line 18 column 20

 

What do I need to change in the second statement?  Thanks

 

I built a very simple apex class, based on a test class, to add a row of data to a database table:

 

Private class Invoice_Balance_Record_Inserter {
static void validateInvoice_Payment() {
Invoice_Balance__c i = new
Invoice_Balance__c(Name='I110811EP3-1', 
Invoice__c = 'a00U00000020IgSIAU',
Invoice_Balance_Amount__c=300);
insert i;
 }
}

 The code will run, either in system log or in force ide, but I don't end up with a record in Invoice_Balace__c.   Is there a way I can run this code that will result in a record being added?  thanks

Hello,

 

I have a simple trigger that I am building which somewhat mimics the example in the apex code manual introductory chapters.   For simplicity in building it, I am starting by doing exactly what the example does - reducing a value by 10%.  However, instead of putting the result back into the field used as input to the calculation, I am putting the result in a different field.  Here is the class code:

 

public class InvoicePayment {
      public static void calculatePayment(InvoiceBalance__c[] invoicepayments) {
           for (InvoiceBalance__c i :invoicepayments) {
                                 i.Paid_Since_Last_Report__c = i.Invoice_Balance_Amount__c * 0.9;
                                }
                  }
}

 

Here is the trigger:

 

trigger InvoicePaymentTrigger on InvoiceBalance__c (before insert) {
                            InvoiceBalance__c[] invoicepayments = Trigger.new;
                            InvoicePayment.calculatePayment(invoicepayments);
}



 

And here is the test method:

 

@isTest
Private Class InvoicePaymentTestClass {

static testMethod void validateInvoicePayment() {

InvoiceBalance__c i = new
InvoiceBalance__c(Name='I110811EP3-3', 
Invoice__c = 'a01U000000180Wy',
Invoice_Balance_Amount__c=300);
System.debug('Paid Since Last Report before inserting new balance record:' + i.Paid_Since_Last_Report__c);
//Insert Balance Record
insert i;
//display the payment after the insert
System.debug('Invoice_Balance_Amount__c after inserting new balance record:' + i.Invoice_Balance_Amount__c); 
System.debug('Paid Since Last Report after inserting new balance record:' + i.Paid_Since_Last_Report__c);
//Test that the trigger correctly fired
System.assertEquals(270, i.Paid_Since_Last_Report__c);
}
}

When I run the trigger manually, it works.  But when I run the trigger, the value in Paid_Since_Last_Report__c is null.

 

What am I doing wrong in my test method?  Thanks

 

Hello,

 

I am getting started with the IDE after doing some development in the online environment.  I have force IDE installed and I can sync my schema so that if I make a change to the schema on the online side, the change to the schema shows up in the IDE when I refresh the schema. 

 

I made a couple of classes in the online environment, but I dont know how to get them into the force IDE environment.  I tried the Force.com options accessed by right clicking on the src folder or subfolders in the Project Explorer, but these all generate a variety of errors. 

 

Is there something else I need to do to set up the syncronization?    All my project properties seem to be in order.  Thanks

 

I'm sure it's me, but...

 

On pages 27-29 of the Apex language reference manual, there is an example that creates a custom object (Book_c and a custom field within the object Price_c).   Then,  a sample for loop within an apex class is demonstrated with the code below:

 

public class MyHelloWorld {  

    public static void applyDiscount(Book_c[] books) {

 for (Book_c  b  :books) 

 {  

   b.Price_c *= 0.9;

    }

  }

}

 

However, when I try to build this code , I get the following error:

 

Error:Compile Error: Invalid type: Book_c at line 3 column 6

 

Like I said, I'm sure it's me but...why is this not working?

 

Thanks for any assistance

I'm sure it's me, but...

 

On pages 27-29 of the Apex language reference manual, there is an example that creates a custom object (book_c and a custom field within the object Price_c).   Then,  a sample for loop within an apex class is demonstrated with the code below:

 

public class MyHelloWorld {
  public static void applyDiscount(Book_c[] books){
for (Book_c  b  :books) {
    b.Price_c *= 0.9; 
   }
  }   
}

 

However, when I try to build this code , I get the following error:

 

Error:Compile Error: Invalid type: Book_c at line 3 column 6

 

Like I said, I'm sure it's me but...why is this not working?

 

Thanks for any assistance