• sduda
  • NEWBIE
  • 15 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 14
    Replies
If you create two or more of the same objects in a test method, there is a custom-field lookup problem w/ picklists. When you try to query for the second object using the picklist value, it cannot be found. Any test method following will have the same problems.

Example:

Object X
   Fields:  TestPick ( Picklist ), Values: 'A', 'B', 'C'
                TestText ( Text )

Class A
    Test Method 1:
       1. Create Custom Object X, TestPick = 'D', TestText = 'Test'
           1a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test'
           1b. Can Query for Custom Object Using Custom Picklist Field.    <-- Custom-field query only works here
                 - SELECT ID FROM X__c WHERE TestPick = 'D'
       2. Create Custom Object X, TestPick = 'E', TestText = 'Test2'
           2a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test2'
           2b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'E'
    Test Method 2:
       1. Create Custom Object X, TestPick = 'F', TestText = 'Test3'
           1a. Can Query for Custom Object Using Standard Field.
                 - SELECT ID FROM X__c WHERE TestText = 'Test3'
           1b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'F'

Class B
    Test Method 1:
       1. Create Custom Object X, TestPick = 'D', TestText = 'Test'
           1a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test'
           1b. Can Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'D'
       2. Create Custom Object X, TestPick = 'E', TestText = 'Test2'
           2a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test2'
           2b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'E'
    Test Method 2:
       1. Create Custom Object X, TestPick = 'F', TestText = 'Test3'
           1a. Can Query for Custom Object Using Standard Field.
                 - SELECT ID FROM X__c WHERE TestText = 'Test3'
           1b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'F'


When deploying code to Sandbox or Producton enviroment, you encounter the problem above.
Note: If you deploy to Sandbox without running all tests, you will encounter the problem below the FIRST time you run tests in Sandbox. The SECOND time you run the test in sandbox, the problem below will be fixed.

Below is an example using a custom object "Program__c" w/ the custom picklist field "Zone__c". This can be modified replicate the issue with any object w/ custom picklist fields. Also, Class B, Test 1, Query 1a will pass on the first TEST.

Apex Code:
public class APEXTestMethod {

public static testMethod void runTests1() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test1_A';
insert prog;

System.debug( 'APEXTestMethod Test1_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test1_A Lookup By Custom Field' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test1_A'] );

System.debug( 'APEXTestMethod Test1_A Lookup By Custom Field' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test1_A'] );




prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test1_B';
insert prog;

System.debug( 'APEXTestMethod Test1_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test1_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test1_B'] );

}

public static testMethod void runTests2() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test2_A';
insert prog;

System.debug( 'APEXTestMethod Test2_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test2_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test2_A'] );

prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test2_B';
insert prog;

System.debug( 'APEXTestMethod Test2_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test2_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test2_B'] );

}

}


public class APEXTestMethod2 {

public static testMethod void runTests1() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test1_A';
insert prog;

System.debug( 'APEXTestMethod2 Test1_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test1_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test1_A'] );

System.debug( 'APEXTestMethod2 Test1_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test1_A'] );




prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test1_B';
insert prog;

System.debug( 'APEXTestMethod2 Test1_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test1_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test1_B'] );

}

public static testMethod void runTests2() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test2_A';
insert prog;

System.debug( 'APEXTestMethod2 Test2_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test2_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test2_A'] );

prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test2_B';
insert prog;

System.debug( 'APEXTestMethod2 Test2_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test2_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test2_B'] );

}



}


Debug Log Output:

[sf:deploy]
[sf:deploy] *** Beginning Test 1: APEXTestMethod.public static testMethod void runTests1()
[sf:deploy]
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 7, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 7, column 13:     DML Operation executed in 197 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 9, column 10: APEXTestMethod Test1_A Lookup By ID
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 10, column 24: SOQL query with 1 row finished in 14 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 10, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_A, Id=a0H30000000ikWnEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 12, column 10: APEXTestMethod Test1_A Lookup By Custom Field
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 13, column 24: SOQL query with 1 row finished in 23 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 13, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_A, Id=a0H30000000ikWnEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 15, column 10: APEXTestMethod Test1_A Lookup By Custom Field
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 16, column 24: SOQL query with 1 row finished in 20 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 16, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_A, Id=a0H30000000ikWnEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 23, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 23, column 13:     DML Operation executed in 121 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 25, column 10: APEXTestMethod Test1_B Lookup By Id
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 26, column 24: SOQL query with 1 row finished in 14 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 26, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_B, Id=a0H30000000ikWoEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 28, column 10: APEXTestMethod Test1_B Lookup By Custom Field
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 29, column 24: SOQL query with 0 rows finished in 18 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 29, column 10: ()
[sf:deploy] 20081201225632.568:Class.APEXTestMethod: line 3, column 35:     returning from end of method public static testMethod void runTests1() in 410 ms
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 5 out of 100
[sf:deploy] Number of query rows: 4 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 16 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] *** Ending Test APEXTestMethod.public static testMethod void runTests1()
[sf:deploy]





[sf:deploy] *** Beginning Test 2: APEXTestMethod.public static testMethod void runTests2()
[sf:deploy]
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 37, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 37, column 13:     DML Operation executed in 118 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 39, column 10: APEXTestMethod Test2_A Lookup By ID
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 40, column 24: SOQL query with 1 row finished in 12 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 40, column 10: (Program__c:{Zone__c=APEXTestMethod_Test2_A, Id=a0H30000000ikWpEAI})
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 42, column 10: APEXTestMethod Test2_A Lookup By Custom Field
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 43, column 24: SOQL query with 0 rows finished in 14 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 43, column 10: ()
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 47, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 47, column 13:     DML Operation executed in 114 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 49, column 10: APEXTestMethod Test2_B Lookup By Id
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 50, column 24: SOQL query with 1 row finished in 15 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 50, column 10: (Program__c:{Zone__c=APEXTestMethod_Test2_B, Id=a0H30000000ikWqEAI})
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 52, column 10: APEXTestMethod Test2_B Lookup By Custom Field
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 53, column 24: SOQL query with 0 rows finished in 17 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 53, column 10: ()
[sf:deploy]
[sf:deploy] Class.APEXTestMethod.runTests2: line 55, column 9
[sf:deploy]
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 4 out of 100
[sf:deploy] Number of query rows: 2 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 15 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] Stack frame variables and sizes:
[sf:deploy]   Frame0
[sf:deploy]
[sf:deploy] *** Ending Test APEXTestMethod.public static testMethod void runTests2()
[sf:deploy]




[sf:deploy] *** Beginning Test 3: APEXTestMethod2.public static testMethod void runTests1()
[sf:deploy]
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 7, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 7, column 13:     DML Operation executed in 108 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 9, column 10: APEXTestMethod2 Test1_A Lookup By ID
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 10, column 24: SOQL query with 1 row finished in 14 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 10, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test1_A, Id=a0H30000000ikWrEAI})
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 12, column 10: APEXTestMethod2 Test1_A Lookup By Custom Field
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 13, column 24: SOQL query with 0 rows finished in 18 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 13, column 10: ()
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 15, column 10: APEXTestMethod2 Test1_A Lookup By Custom Field
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 16, column 24: SOQL query with 0 rows finished in 16 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 16, column 10: ()
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 23, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 23, column 13:     DML Operation executed in 109 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 25, column 10: APEXTestMethod2 Test1_B Lookup By Id
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 26, column 24: SOQL query with 1 row finished in 10 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 26, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test1_B, Id=a0H30000000ikWsEAI})
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 28, column 10: APEXTestMethod2 Test1_B Lookup By Custom Field
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 29, column 24: SOQL query with 0 rows finished in 18 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 29, column 10: ()
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2: line 3, column 35:     returning from end of method public static testMethod void runTests1() in 297 ms
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 5 out of 100
[sf:deploy] Number of query rows: 2 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 16 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] *** Ending Test APEXTestMethod2.public static testMethod void runTests1()
[sf:deploy]




[sf:deploy] *** Beginning Test 4: APEXTestMethod2.public static testMethod void runTests2()
[sf:deploy]
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 37, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 37, column 13:     DML Operation executed in 109 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 39, column 10: APEXTestMethod2 Test2_A Lookup By ID
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 40, column 24: SOQL query with 1 row finished in 15 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 40, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test2_A, Id=a0H30000000ikWtEAI})
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 42, column 10: APEXTestMethod2 Test2_A Lookup By Custom Field
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 43, column 24: SOQL query with 0 rows finished in 15 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 43, column 10: ()
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 47, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 47, column 13:     DML Operation executed in 104 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 49, column 10: APEXTestMethod2 Test2_B Lookup By Id
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 50, column 24: SOQL query with 1 row finished in 13 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 50, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test2_B, Id=a0H30000000ikWuEAI})
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 52, column 10: APEXTestMethod2 Test2_B Lookup By Custom Field
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 53, column 24: SOQL query with 0 rows finished in 15 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 53, column 10: ()
[sf:deploy]
[sf:deploy] Class.APEXTestMethod2.runTests2: line 55, column 9
[sf:deploy]
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 4 out of 100
[sf:deploy] Number of query rows: 2 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 15 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] Stack frame variables and sizes:
[sf:deploy]   Frame0
[sf:deploy]
[sf:deploy] *** Ending Test APEXTestMethod2.public static testMethod void runTests2()
[sf:deploy]


Message Edited by sduda on 12-01-2008 03:25 PM

Message Edited by sduda on 12-01-2008 03:28 PM

Message Edited by sduda on 12-01-2008 04:15 PM

Message Edited by sduda on 12-01-2008 04:26 PM
  • December 01, 2008
  • Like
  • 0
How you you enable the orange help text bubble so it will appear next to an input / output field in visualforce?
  • November 06, 2008
  • Like
  • 0
One major annoyance I've come across with creating APEX test cases are validation rules & required fields. Say I want to create a new Account in a test case, I need to specify all of the required fields for that object - that's fine the first time around. Now, when I go back to test my APEX code a month later, there's a high probability that another required field has been added to the Account object or some new validation was created. This causes my test case to fail, and in turn requires me to update the APEX code.

What approach have other people used to avoid this issue?


  • October 24, 2008
  • Like
  • 0

I've created a bunch of objects in our sandbox environment and would like to move them into our production environment. What's the easiest way to accomplish this?

I've tried creating an unmanaged package for only these new objects, however, it automatically includes every custom object ever created (in addition to my new objects) since they are all tied together.

  • December 20, 2007
  • Like
  • 0
I have two fields defined on a custom object:

N1 : Currency(3, 8)
N2 : Number(2, 0)

Using APEX, I query for this record and place into a variable named 'rec'.
Then, I use debug to print out these values to the console:

Here is what it prints out:
rec.N1 = 125.0
rec.N2 = 12.0

Then, I try to divide the two numbers:
Double N3 = rec.N1 / rec.N2;

When i print out N3, it displays:
N3 = 10.4

However, If I assign N3 = 125.0/12.0 and print out N3 again, i get:
N3 = 10.416666666666666 ( Which is the correct value... not 10.4 )

Why is APEX truncating/rounding the first value to 10.4?



  • December 17, 2007
  • Like
  • 0
After installing the excel connector I'm getting a VBA error when I open excel. ( In the code that's trying to create the custom toolbar )

"Compile Error: Automation Error: Unknown Source"

This line is highlighted in the VBA code:

Sub CreateSubMenu1(InputCtrl As CommandBarPopup)


Thanks
  • October 19, 2007
  • Like
  • 0
When ever I try to use the synchronize feature of the eclipse plugin, it takes about 5 mins figure out which files are out of synch. The status bar continues to increase the percentage complete, and gets to around 50,000% before completing. Has anyone experienced this problem?
  • September 26, 2007
  • Like
  • 0
How do I generate a WSDL from an APEX class in production? I only have the option while in sandbox.

Thanks

Seth
  • August 27, 2007
  • Like
  • 0
How do I throw one of the system defined exception types?

it says: throw <ExceptionObject>

I've tried:

throw new StringException();
throw new System.StringException();
throw StringException;

It returns the error message:

Exception type cannot be constructed

Thanks
  • August 24, 2007
  • Like
  • 0

I am trying to create a APEX code class with a method defined as a WebService. What are the valid parameter types that I can pass to this method? I tried using a Set, but it says that it's not a valid parameter type (It doesn’t give this error if the method isn't a WebService). Are only primitive data types valid? Is it possible to pass a Set of primitive data types?

  • August 23, 2007
  • Like
  • 0

I just installed the new version of the APEX plug-in for Eclipse. I've deleted and created a new project for the test server. When I try to create a new trigger, it initially says as a warning:

File only saved locally, not to Salesforce

If I add anything to the Trigger and save again it says as an error:

Conflict found while saving ConfirmationTrigger.tgr to server.  Remote instance has been updated since last save or sync.  Use the Synchronize Perspective to resolve the conflict.

I've tried using the synchronize perspective with no success - I can't get rid of the error.

  • August 21, 2007
  • Like
  • 0
While using Print Anything, I extended the driver to include support for an equals tag. If anyone is using print anything, I found this very helpful when creating more advanced templates. It also supports nested equal statements.

Here's how it works:

<prtany:equal Contact1.FirstName="some value" Contact1.LastName="some other value" ........ >
  
    Displays this text only if:
    Contact1.FirstName="some value" and
    Contact1.LastName="some other value"

    <prtany:equal Contact1.LastName="some other value 2">
  
        Displays this text only if:
        Contact1.LastName="some other value 2" and
        parent equals tag is true

    </prtany:equal>

</prtany:equal>

<prtany:equal Contact1.FirstName!="some value" >
  
    Displays this text only if:
    Contact1.FirstName does not equal "some value"

</prtany:equal>



(Put new code inside the merge function after the last while statement)

Code:
 // remove any conditional content
while (result.indexOf("<prtany:equal") != -1) {
var level = 1;

// Find next start tag (<prtany:equal ... >)
var startTagStartPos = result.indexOf("<prtany:equal");
var startTagEndPos = result.indexOf(">", startTagStartPos);

var parsePos = startTagEndPos;

var nextStartTagPos;
var nextEndTagPos;

// Find corresponding end tag (</prtany:equal>)
do {
nextStartTagPos = result.indexOf("<prtany:equal",parsePos);
nextEndTagPos = result.indexOf("</prtany:equal", parsePos);
if( nextStartTagPos < nextEndTagPos && nextStartTagPos != -1 ) {
level = level + 1;
parsePos = nextStartTagPos + 1;
} else {
level = level - 1;
parsePos = nextEndTagPos + 1;
}
} while ( level > 0 )

if (nextEndTagPos == -1) {
throw "No equal end tag was found";
}

var endTagEndPos = result.indexOf(">", nextEndTagPos);

var conditionalString = result.substring(startTagEndPos+1,nextEndTagPos);

// Parse start tag conditions (<prtany:equal var="value" var2!="value" ... >
var statement = result.substring(startTagStartPos+1,startTagEndPos);
var reg = /(\S+?)\s*(\!?=)\s*\"(.+?)\"/g;

var match = reg.exec( statement );
while( match != null ) {
var conditionalValue = mergeData[match[1]];
if( match[2] == "!=" ) {
if (conditionalValue == match[3]) {
conditionalString = "";
}
} else {
if (conditionalValue != match[3]) {
conditionalString = "";
}
}
match = reg.exec( statement );
}

result = result.substring(0,startTagStartPos) + conditionalString + result.substring(endTagEndPos+1)
}

 





Message Edited by sduda on 03-29-2007 02:23 PM

Message Edited by sduda on 04-09-2007 09:28 AM

Message Edited by sduda on 04-09-2007 09:30 AM

  • March 29, 2007
  • Like
  • 0
Hi, I have installed the "Sidebar Summary" and it works great.
 
But now when I tried to deploy another class, it says:
 

Test Class VFController_Sidebar_Summary
Tests Run 1
Test Failures 1
Code coverage total % 100
Total time (ms) 0

Class VFController_Sidebar_Summary testVFController_Sidebar_Summary 136 System.Exception: Too many query rows: 501 Class.VFController_Sidebar_Summary.getPastDueOppty: line 52, column 8
Class.VFController_Sidebar_Summary.testVFController_Sidebar_Summary: line 68, column 14

This test calss is not in the "package.xml” file. So why it runs this test? Not the one I specified in "package.xml"? Should they be independent?

 

 

  • December 16, 2008
  • Like
  • 0
If you create two or more of the same objects in a test method, there is a custom-field lookup problem w/ picklists. When you try to query for the second object using the picklist value, it cannot be found. Any test method following will have the same problems.

Example:

Object X
   Fields:  TestPick ( Picklist ), Values: 'A', 'B', 'C'
                TestText ( Text )

Class A
    Test Method 1:
       1. Create Custom Object X, TestPick = 'D', TestText = 'Test'
           1a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test'
           1b. Can Query for Custom Object Using Custom Picklist Field.    <-- Custom-field query only works here
                 - SELECT ID FROM X__c WHERE TestPick = 'D'
       2. Create Custom Object X, TestPick = 'E', TestText = 'Test2'
           2a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test2'
           2b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'E'
    Test Method 2:
       1. Create Custom Object X, TestPick = 'F', TestText = 'Test3'
           1a. Can Query for Custom Object Using Standard Field.
                 - SELECT ID FROM X__c WHERE TestText = 'Test3'
           1b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'F'

Class B
    Test Method 1:
       1. Create Custom Object X, TestPick = 'D', TestText = 'Test'
           1a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test'
           1b. Can Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'D'
       2. Create Custom Object X, TestPick = 'E', TestText = 'Test2'
           2a. Can Query for Custom Object Using Standard Field or non-picklist.
                 - SELECT ID FROM X__c WHERE TestText = 'Test2'
           2b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'E'
    Test Method 2:
       1. Create Custom Object X, TestPick = 'F', TestText = 'Test3'
           1a. Can Query for Custom Object Using Standard Field.
                 - SELECT ID FROM X__c WHERE TestText = 'Test3'
           1b. Can't Query for Custom Object Using Custom Picklist Field.
                 - SELECT ID FROM X__c WHERE TestPick = 'F'


When deploying code to Sandbox or Producton enviroment, you encounter the problem above.
Note: If you deploy to Sandbox without running all tests, you will encounter the problem below the FIRST time you run tests in Sandbox. The SECOND time you run the test in sandbox, the problem below will be fixed.

Below is an example using a custom object "Program__c" w/ the custom picklist field "Zone__c". This can be modified replicate the issue with any object w/ custom picklist fields. Also, Class B, Test 1, Query 1a will pass on the first TEST.

Apex Code:
public class APEXTestMethod {

public static testMethod void runTests1() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test1_A';
insert prog;

System.debug( 'APEXTestMethod Test1_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test1_A Lookup By Custom Field' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test1_A'] );

System.debug( 'APEXTestMethod Test1_A Lookup By Custom Field' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test1_A'] );




prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test1_B';
insert prog;

System.debug( 'APEXTestMethod Test1_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test1_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test1_B'] );

}

public static testMethod void runTests2() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test2_A';
insert prog;

System.debug( 'APEXTestMethod Test2_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test2_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test2_A'] );

prog = new Program__c();
prog.Zone__c = 'APEXTestMethod_Test2_B';
insert prog;

System.debug( 'APEXTestMethod Test2_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod Test2_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod_Test2_B'] );

}

}


public class APEXTestMethod2 {

public static testMethod void runTests1() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test1_A';
insert prog;

System.debug( 'APEXTestMethod2 Test1_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test1_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test1_A'] );

System.debug( 'APEXTestMethod2 Test1_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test1_A'] );




prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test1_B';
insert prog;

System.debug( 'APEXTestMethod2 Test1_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test1_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test1_B'] );

}

public static testMethod void runTests2() {

Program__c prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test2_A';
insert prog;

System.debug( 'APEXTestMethod2 Test2_A Lookup By ID' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test2_A Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test2_A'] );

prog = new Program__c();
prog.Zone__c = 'APEXTestMethod2_Test2_B';
insert prog;

System.debug( 'APEXTestMethod2 Test2_B Lookup By Id' );
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE Id = :prog.Id] );

System.debug( 'APEXTestMethod2 Test2_B Lookup By Custom Field' );
// Should Find 1 Record, But Finds None
System.debug( [SELECT p.Id, p.Zone__c FROM Program__c p WHERE p.Zone__c = 'APEXTestMethod2_Test2_B'] );

}



}


Debug Log Output:

[sf:deploy]
[sf:deploy] *** Beginning Test 1: APEXTestMethod.public static testMethod void runTests1()
[sf:deploy]
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 7, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 7, column 13:     DML Operation executed in 197 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 9, column 10: APEXTestMethod Test1_A Lookup By ID
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 10, column 24: SOQL query with 1 row finished in 14 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 10, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_A, Id=a0H30000000ikWnEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 12, column 10: APEXTestMethod Test1_A Lookup By Custom Field
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 13, column 24: SOQL query with 1 row finished in 23 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 13, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_A, Id=a0H30000000ikWnEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 15, column 10: APEXTestMethod Test1_A Lookup By Custom Field
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 16, column 24: SOQL query with 1 row finished in 20 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 16, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_A, Id=a0H30000000ikWnEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 23, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 23, column 13:     DML Operation executed in 121 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 25, column 10: APEXTestMethod Test1_B Lookup By Id
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 26, column 24: SOQL query with 1 row finished in 14 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 26, column 10: (Program__c:{Zone__c=APEXTestMethod_Test1_B, Id=a0H30000000ikWoEAI})
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 28, column 10: APEXTestMethod Test1_B Lookup By Custom Field
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 29, column 24: SOQL query with 0 rows finished in 18 ms
[sf:deploy] 20081201225632.568:Class.APEXTestMethod.runTests1: line 29, column 10: ()
[sf:deploy] 20081201225632.568:Class.APEXTestMethod: line 3, column 35:     returning from end of method public static testMethod void runTests1() in 410 ms
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 5 out of 100
[sf:deploy] Number of query rows: 4 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 16 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] *** Ending Test APEXTestMethod.public static testMethod void runTests1()
[sf:deploy]





[sf:deploy] *** Beginning Test 2: APEXTestMethod.public static testMethod void runTests2()
[sf:deploy]
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 37, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 37, column 13:     DML Operation executed in 118 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 39, column 10: APEXTestMethod Test2_A Lookup By ID
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 40, column 24: SOQL query with 1 row finished in 12 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 40, column 10: (Program__c:{Zone__c=APEXTestMethod_Test2_A, Id=a0H30000000ikWpEAI})
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 42, column 10: APEXTestMethod Test2_A Lookup By Custom Field
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 43, column 24: SOQL query with 0 rows finished in 14 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 43, column 10: ()
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 47, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 47, column 13:     DML Operation executed in 114 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 49, column 10: APEXTestMethod Test2_B Lookup By Id
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 50, column 24: SOQL query with 1 row finished in 15 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 50, column 10: (Program__c:{Zone__c=APEXTestMethod_Test2_B, Id=a0H30000000ikWqEAI})
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 52, column 10: APEXTestMethod Test2_B Lookup By Custom Field
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 53, column 24: SOQL query with 0 rows finished in 17 ms
[sf:deploy] 20081201225632.982:Class.APEXTestMethod.runTests2: line 53, column 10: ()
[sf:deploy]
[sf:deploy] Class.APEXTestMethod.runTests2: line 55, column 9
[sf:deploy]
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 4 out of 100
[sf:deploy] Number of query rows: 2 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 15 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] Stack frame variables and sizes:
[sf:deploy]   Frame0
[sf:deploy]
[sf:deploy] *** Ending Test APEXTestMethod.public static testMethod void runTests2()
[sf:deploy]




[sf:deploy] *** Beginning Test 3: APEXTestMethod2.public static testMethod void runTests1()
[sf:deploy]
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 7, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 7, column 13:     DML Operation executed in 108 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 9, column 10: APEXTestMethod2 Test1_A Lookup By ID
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 10, column 24: SOQL query with 1 row finished in 14 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 10, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test1_A, Id=a0H30000000ikWrEAI})
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 12, column 10: APEXTestMethod2 Test1_A Lookup By Custom Field
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 13, column 24: SOQL query with 0 rows finished in 18 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 13, column 10: ()
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 15, column 10: APEXTestMethod2 Test1_A Lookup By Custom Field
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 16, column 24: SOQL query with 0 rows finished in 16 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 16, column 10: ()
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 23, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 23, column 13:     DML Operation executed in 109 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 25, column 10: APEXTestMethod2 Test1_B Lookup By Id
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 26, column 24: SOQL query with 1 row finished in 10 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 26, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test1_B, Id=a0H30000000ikWsEAI})
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 28, column 10: APEXTestMethod2 Test1_B Lookup By Custom Field
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 29, column 24: SOQL query with 0 rows finished in 18 ms
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2.runTests1: line 29, column 10: ()
[sf:deploy] 20081201225633.282:Class.APEXTestMethod2: line 3, column 35:     returning from end of method public static testMethod void runTests1() in 297 ms
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 5 out of 100
[sf:deploy] Number of query rows: 2 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 16 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] *** Ending Test APEXTestMethod2.public static testMethod void runTests1()
[sf:deploy]




[sf:deploy] *** Beginning Test 4: APEXTestMethod2.public static testMethod void runTests2()
[sf:deploy]
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 37, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 37, column 13:     DML Operation executed in 109 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 39, column 10: APEXTestMethod2 Test2_A Lookup By ID
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 40, column 24: SOQL query with 1 row finished in 15 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 40, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test2_A, Id=a0H30000000ikWtEAI})
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 42, column 10: APEXTestMethod2 Test2_A Lookup By Custom Field
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 43, column 24: SOQL query with 0 rows finished in 15 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 43, column 10: ()
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 47, column 13: Insert: SOBJECT:Program__c
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 47, column 13:     DML Operation executed in 104 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 49, column 10: APEXTestMethod2 Test2_B Lookup By Id
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 50, column 24: SOQL query with 1 row finished in 13 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 50, column 10: (Program__c:{Zone__c=APEXTestMethod2_Test2_B, Id=a0H30000000ikWuEAI})
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 52, column 10: APEXTestMethod2 Test2_B Lookup By Custom Field
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 53, column 24: SOQL query with 0 rows finished in 15 ms
[sf:deploy] 20081201225633.582:Class.APEXTestMethod2.runTests2: line 53, column 10: ()
[sf:deploy]
[sf:deploy] Class.APEXTestMethod2.runTests2: line 55, column 9
[sf:deploy]
[sf:deploy]
[sf:deploy] Cumulative resource usage:
[sf:deploy]
[sf:deploy] Resource usage for namespace: (default)
[sf:deploy] Number of SOQL queries: 4 out of 100
[sf:deploy] Number of query rows: 2 out of 500
[sf:deploy] Number of SOSL queries: 0 out of 20
[sf:deploy] Number of DML statements: 2 out of 100
[sf:deploy] Number of DML rows: 2 out of 500
[sf:deploy] Number of script statements: 15 out of 200000
[sf:deploy] Maximum heap size: 0 out of 500000
[sf:deploy] Number of callouts: 0 out of 10
[sf:deploy] Number of Email Invocations: 0 out of 10
[sf:deploy] Number of fields describes: 0 out of 10
[sf:deploy] Number of record type describes: 0 out of 10
[sf:deploy] Number of child relationships describes: 0 out of 10
[sf:deploy] Number of picklist describes: 0 out of 10
[sf:deploy] Number of future calls: 0 out of 10
[sf:deploy] Number of find similar calls: 0 out of 10
[sf:deploy] Number of System.runAs() invocations: 0 out of 20
[sf:deploy]
[sf:deploy] Total email recipients queued to be sent : 0
[sf:deploy] Stack frame variables and sizes:
[sf:deploy]   Frame0
[sf:deploy]
[sf:deploy] *** Ending Test APEXTestMethod2.public static testMethod void runTests2()
[sf:deploy]


Message Edited by sduda on 12-01-2008 03:25 PM

Message Edited by sduda on 12-01-2008 03:28 PM

Message Edited by sduda on 12-01-2008 04:15 PM

Message Edited by sduda on 12-01-2008 04:26 PM
  • December 01, 2008
  • Like
  • 0
Hey Freinds ,
 
How can we call triggers  in Apex code from our S-Control
I have tried to figure out  by trying  for Apex class and my  javascript code
 
global class myClass {

webService static Id makeContact(String lastName, Account a) {

Contact c = new Contact(LastName = lastName, AccountId = a.Id);

return c.id;

}

}

Ajax code

var account = sforce.SObject("Account");

var id = sforce.apex.execute("myClass","makeContact",

{a:"Smith",

b:account});

But not able to get for triggers from S-control

Message Edited by Amans on 09-19-2007 05:46 AM

  • September 19, 2007
  • Like
  • 0
Hi Friends

I don't have much idea about S-Controls,I would like to know can we use Apex code language method within S-Controls to avoid an API call?

Is there any limitation or so?can u suggest any gud link to learn more about S-Controls.

Vineeta
  • September 19, 2007
  • Like
  • 0
The examples for unit testing seem to be mixing the unit tests in with the domain classes.  I don't really like this, as I like to keep test classes separate from the domain classes being tested.  The problem seems to be that if you sepratate your test methods into test classes, Apex expects your test classes to be covered, which turns into an infinite loop. 

Can anyone share what they feel may be a clean and scalable way to do testing with Apex code?

thanks

Jeremy
How do I generate a WSDL from an APEX class in production? I only have the option while in sandbox.

Thanks

Seth
  • August 27, 2007
  • Like
  • 0
Hello. I am making some progress with Apex, but I am stumped on the following. My understanding is that you can use SOQL for loops to do batch update / delete (200 records at a time). In my example below, I looping once for each record. When I try to adapt the code based on the docs (Apex Language Reference), I get an error saying I need an SObject List object. Any help would be appreciated ...   how do I convert this SOQL for loop to do batch processing?

And yes, I realize that there is a Case Contact Roles related list, but the client requires related lists on the Account and Contact objects displaying Case roles. :smileyhappy:

Code:
// we check to see if the subject has changed
if (casenew.subject != caseold.subject) {

  // we try to batch update all case_roles with this case id
  // this seems to do one at a time, instead of 200 at a time
  for(case_role__c cr: [select id,case_subject__c from case_role__c where case__c = :casenew.id ]){
    cr.case_subject__c = casenew.subject;
    update cr;
  } 
}
Message Edited by JohnPCutler on 08-25-200703:48 PM

Message Edited by JohnPCutler on 08-26-200707:04 PM

How do I throw one of the system defined exception types?

it says: throw <ExceptionObject>

I've tried:

throw new StringException();
throw new System.StringException();
throw StringException;

It returns the error message:

Exception type cannot be constructed

Thanks
  • August 24, 2007
  • Like
  • 0
HI i'm a rookie. Beginining to play with salesforce. I've been customizing in salesforce. i am getting quite familiar now. I would like to know what role does apex play. What is the use of apex. wher will i use it . can someone provide me with the necessary information. so that i can learn about how to use apex and where to use it
 
Thanks!
chander

I just installed the new version of the APEX plug-in for Eclipse. I've deleted and created a new project for the test server. When I try to create a new trigger, it initially says as a warning:

File only saved locally, not to Salesforce

If I add anything to the Trigger and save again it says as an error:

Conflict found while saving ConfirmationTrigger.tgr to server.  Remote instance has been updated since last save or sync.  Use the Synchronize Perspective to resolve the conflict.

I've tried using the synchronize perspective with no success - I can't get rid of the error.

  • August 21, 2007
  • Like
  • 0
I have been able to successfully get PrintAnything to format data as necessary, but am having some troubles with one of the finishing touches:

In order to allow people to easily print the output, I've added a javascript "Print" button.  The problem is, however, that since PrintAnything does not accept stylesheet calls (I need to call a "media" stylesheet in this case), I am unable to use javascript code to "hide" the print button when the document is actually printed.

This means that every printout has a big "Print" button on it, which is obviously less than desirable.

Has anyone figured a way around this?

Thanks,
Seth
  • April 02, 2007
  • Like
  • 0
While using Print Anything, I extended the driver to include support for an equals tag. If anyone is using print anything, I found this very helpful when creating more advanced templates. It also supports nested equal statements.

Here's how it works:

<prtany:equal Contact1.FirstName="some value" Contact1.LastName="some other value" ........ >
  
    Displays this text only if:
    Contact1.FirstName="some value" and
    Contact1.LastName="some other value"

    <prtany:equal Contact1.LastName="some other value 2">
  
        Displays this text only if:
        Contact1.LastName="some other value 2" and
        parent equals tag is true

    </prtany:equal>

</prtany:equal>

<prtany:equal Contact1.FirstName!="some value" >
  
    Displays this text only if:
    Contact1.FirstName does not equal "some value"

</prtany:equal>



(Put new code inside the merge function after the last while statement)

Code:
 // remove any conditional content
while (result.indexOf("<prtany:equal") != -1) {
var level = 1;

// Find next start tag (<prtany:equal ... >)
var startTagStartPos = result.indexOf("<prtany:equal");
var startTagEndPos = result.indexOf(">", startTagStartPos);

var parsePos = startTagEndPos;

var nextStartTagPos;
var nextEndTagPos;

// Find corresponding end tag (</prtany:equal>)
do {
nextStartTagPos = result.indexOf("<prtany:equal",parsePos);
nextEndTagPos = result.indexOf("</prtany:equal", parsePos);
if( nextStartTagPos < nextEndTagPos && nextStartTagPos != -1 ) {
level = level + 1;
parsePos = nextStartTagPos + 1;
} else {
level = level - 1;
parsePos = nextEndTagPos + 1;
}
} while ( level > 0 )

if (nextEndTagPos == -1) {
throw "No equal end tag was found";
}

var endTagEndPos = result.indexOf(">", nextEndTagPos);

var conditionalString = result.substring(startTagEndPos+1,nextEndTagPos);

// Parse start tag conditions (<prtany:equal var="value" var2!="value" ... >
var statement = result.substring(startTagStartPos+1,startTagEndPos);
var reg = /(\S+?)\s*(\!?=)\s*\"(.+?)\"/g;

var match = reg.exec( statement );
while( match != null ) {
var conditionalValue = mergeData[match[1]];
if( match[2] == "!=" ) {
if (conditionalValue == match[3]) {
conditionalString = "";
}
} else {
if (conditionalValue != match[3]) {
conditionalString = "";
}
}
match = reg.exec( statement );
}

result = result.substring(0,startTagStartPos) + conditionalString + result.substring(endTagEndPos+1)
}

 





Message Edited by sduda on 03-29-2007 02:23 PM

Message Edited by sduda on 04-09-2007 09:28 AM

Message Edited by sduda on 04-09-2007 09:30 AM

  • March 29, 2007
  • Like
  • 0