• vinodshivhare
  • NEWBIE
  • 0 Points
  • Member since 2008
  • Dell

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
Does anyone have more insight on the below topic:
-- "Amount" field (Standard field) on opportunity has label name "Amount" but it shows as "Asset" on Opportunity detail page. Similarly "Type" field (Standard field) label shows as "Transition Type" on Opportunity detail page. Why?

Is it possible that warning messages can be displayed instead of error messages using validation rules?

Anyone has any idea about it or anyone has other work around for this.

 

Thanks,

Vinod 

I don't have much credit finding this weird thing but I wanted to know if it's a bug or if it's really intended, which I cannot imagine. 

copy paste from this blog: http://blog.tquila.com/2012/06/25/grokking-force-dot-com-apex/

 

"Unit Tests increment your Objects unique Id

This is not covered in the documentation, or atleast I haven’t found it in the Apex docs. When you run unit tests that insert/create records for a particular object(standard or otherwise), it increments the value of the Name field(of type Auto Number) outside of the test context.

Let’s say you have a custom object “Invoice Statement” (Invoice_Statement__c) that has a Name field called “Invoice Number”, and is of type “Auto Number”. The format of the field is: INV-{0000}, and let’s assume that the latest record number is INV-2058.

If you insert 10 records in the test class as follows:

 

1// Let's assume that this runs inside of a test method
2List<Invoice_Statement__c> invStatementList = new List<Invoice_Statement__c>();
3for(Integer i = 0; i < 10; i++) {
4  invStatementList.add(new Invoice_Statement__c(company='acme ltd');
5}
6insert invStatementList;

 

Now, when you insert a new Invoice Statement record outside of the test method via a trigger, or batch, or the User Interface, the next inserted record will have the id INV-2069. So don’t rely on the unique name field if you have strict rules around the auto-increment feature in your application. Instead add a custom field which is auto-incremented in a workflow or trigger to have more granular control over how the value is incremented."

 

I verified that by myself, and this indeed happen. I remember having used these numbers for customer who want to have exactly one unique number per record (especially for bills), so this could be a huge issue.

 

Anyone aware of that? I didn't find it in the Salesforce known bug ....

Let me first start by saying that I am completely new to the Appex scene.  I created the below trigger with some help from another cummunity member yesterday.  The logic is very simple: Whenever the field opp.StageName is updated to '4 - Closed Won' and the roll-up summary field opp.Hosting__c is greater than zero, change the account.type to 'Customer'.  

 

 

trigger OpportunityUpdateAccount on Opportunity(after insert, after update) {
List<Account> accsToUpdate = new List<Account>();

for(Opportunity opp : trigger.new)
{if (opp.StageName == '4 - Closed Won' && opp.Hosting__c > 0)
accsToUpdate.add(new Account(Type = 'Customer'));
}
if (accsToUpdate != null && !accsToUpdate.isEmpty())
Database.update(accsToUpdate);
}

 However, when I go into an Opportunity and (in either order) add a product to increase the Hosting__c above $0 and update the StageName to '4 - Closed Won', it throws the below error:

 

Apex trigger OpportunityUpdateAccount caused an unexpected exception, contact your administrator: OpportunityUpdateAccount: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.OpportunityUpdateAccount: line 9, column 1  

 

 

My guess is that I have not done a well enough job identifying what records actually need to be changed.  

 

Any suggestions?

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
Hi,
 
How can I enable a profile whereby an user has access to only add/edit/delete attachments in Notes and Attachment section for Accounts that may/may NOT be owned by the user.
 
Thanks and regards,
Ambili
 
  • August 31, 2007
  • Like
  • 0