• Nikong
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
We want an online PDF order form that will display products and pricebooks related to a certain account. The PDF form would have checkboxes next to the products that customers will be able to check. There will aslo be a box where they can enter the number of the products they want.

My question is... is it possible to use apex to get the information from the PDF order form and create an Opportunity in Salesforce with line items when the customers hit submit?
  • February 18, 2014
  • Like
  • 0
We want an online PDF order form that will display products and pricebooks related to a certain account. The PDF form would have checkboxes next to the products that customers will be able to check. There will aslo be a box where they can enter the number of the products they want.

My question is... is it possible to use apex to get the information from the PDF order form and create an Opportunity in Salesforce with line items when the customers hit submit?
  • February 18, 2014
  • Like
  • 0
I've had this issue for quite awhile but just assumed it was working as designed. But since I can't find any references on it in documentation, I thought I'd post here to be sure. Is this a bug or by design?

Running test cases which insert records into an object with an autonumber field cause the autonumber value to actually increment by the number of records inserted during the testmethod execution. After the test is complete, inserting a new record will result in an out-of-sequence autonumber value to be set on the new record. In other words, the autonumber values aren't rolled back during test execution.

In this simple example below the test method inserts 5 records into a custom object called "Book". The custom object contains a field called "Book Id" which is an autonumber field. After running this, the next record that is inserted into the Book object will have a Book Id 5 greater than the previously inserted record.

Code:
public class MyBookClass{

    public static void CreateNewBooks(List<String> titles){
        
        List<Book__c> booksToInsert = new List<Book__c>();
        
        for(String title : titles){
            Book__c b = new Book__c();
            b.Name = title;
            booksToInsert.add(b);
        }
        
        insert booksToInsert;
    }
    
    public static testmethod void CreateNewBookTest(){
        List<String> titles = new List<String>{'Title 1','Title 2','Title 3','Title 4','Title 5'};
        
        CreateNewBooks(titles);
        
        Integer count = [SELECT count() from Book__c where name in ('Title 1','Title 2','Title 3','Title 4','Title 5')];
        
        System.AssertEquals(5, count );
    }

}

 

  • November 11, 2008
  • Like
  • 0