• eric.luis
  • NEWBIE
  • 49 Points
  • Member since 2012

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

hi i am always doing wrong with void and non void method i am not understanding when , where and how these methods are used , could any body explain in detail

I am an administrator that is working on someone elses code. I know the basics about Java programing and even less on apex.  My goal is the get the test coverage above 75%.

 

Most of my errors are

 

"System.QueryException: List has no rows for assignment to SObject".

 

From what I am reading on other boards I have a basic idea of what I need to change. But once I change it, something else down the code gives me an errors.

Here is the original code

 public static testMethod void testManageVendorBillDetails(){  
        Invoice_and_Billing_Detail__c invoiceDetails = [Select Id,Adjustment_amount__c,Amount__c, Vendor_Bill__c
        from Invoice_and_Billing_Detail__c  limit 1 for Update];  
      

 Then I changed it to a List<>

 public static testMethod void testManageVendorBillDetails(){  
        List <Invoice_and_Billing_Detail__c> invoiceDetails = [Select Id,Adjustment_amount__c,Amount__c, Vendor_Bill__c
        from Invoice_and_Billing_Detail__c  limit 1 for Update];  
          

 But now I get an error further down the method. Here is the whole method and I will note what line (towards the bottom) that is giving me the error.

 public static testMethod void testManageVendorBillDetails(){  
        List <Invoice_and_Billing_Detail__c> invoiceDetails = [Select Id,Adjustment_amount__c,Amount__c, Vendor_Bill__c
        from Invoice_and_Billing_Detail__c  limit 1 for Update];  
          
        Vendor_Bills__c vendorBillRecord = new Vendor_Bills__c();
        vendorBillRecord.Bill_Date__c = System.today();
        vendorBillRecord.Due_Date_On_Bill__c = System.today().addDays(10);
        vendorBillRecord.Vendor_Invoice_Number__c = 'Test Bill Record';

        Account vend = new Account(Name = 'Test Vendor', 
                       Phone = '(508) 555-1212',
                       Fax = '(508) 555-1213',
                       Type = 'Vendor',
                       Address1__c = 'asfasd',
                       City__c = 'myTstVen',
                       State__c = 'MA',
                       Zip_Code__c = '2090',
                       Company_Name__c = 'Test Vendor',
                       QB_Account__c = 'QB Account Name',
                       Account_QB_Account_Name__c = 'QB Account Name Ven',
                       Account_Code__c = 'testven1');
        insert vend;
        vend = [select ID from Account where Name Like '%myTstVen%' Limit 1];
        
        User userNAM = [select Id from User limit 1];
        
        Account acct = new Account(Name = 'Test Account Name', 
                   Phone = '(508) 555-1212',
                   Fax = '(508) 555-1213',
                   Type = 'Client',
                   Address1__c = '2234234',
                   City__c = 'ShortPayTstClnt',
                   State__c = 'MA',
                   Zip_Code__c = '2090',
                   QB_Account__c = 'QB Account Name',
                   Account_QB_Account_Name__c = 'QB Account Name',
                   Account_Code__c = 'aewrew',
                   NAM_User__c = userNAM.Id,
                   Generate_Tree_Report_Data__c = false,
                   Generate_Tree_Report_As_Of__c = date.today());
        
    	insert acct;
    	
        Contact tstContact = new Contact(LastName = 'test',
						AccountId = acct.Id,
						Contact_Type__c = 'Client',
						Phone = '(555) 555-5555',
						Contact_Region__c = 'test');
    	insert tstContact;
    
        Location__c loc = new Location__c(Name = 'myTst Location', 
                                    Account__c = acct.Id, 
                                    Address__c = '12543',
                                    City__c = '233',
                                    State__c = 'ID',
                                    Zip_Code__c = '2090',
                                    Location_County__c = 'asfsd',
                                    Active_Date__c = date.today(),  //.parse('1/1/2009'),
                                    //Location_Billing__c = 'TestLoc2',
                                    Non_Active_Date__c = date.today(),
                        			Non_Active_Reason_Code__c='asfsd',
                       			    Close_Date__c =date.today(),
                                    Billing_Address_1__c = '23q234',
                                    Billing_City__c = 'Westwood',
                                    Billing_Zip__c = '2090',
                                    Billing_State__c = 'MA',
                                    Quickbooks_Account_Name__c = 'QB Account Name',
                                    Market_Type__c='Open Market',
                                    Contact2__c = tstContact.Id);
                                   
        insert loc; 
            
        loc =  [select ID, Name, Account__c, Account__r.Name from Location__c where Name = 'myTst Location' Limit 1];
        Vendor_Location__c vendLoc = new Vendor_Location__c(Name = 'mytestven1 (sgfsdf)',
                                        RecordTypeId = '01280000000BTSPAA4',
                                        Locationnew__c = loc.ID,
                                        Vendor__c = vend.ID,
                                        PO_Number__c = 'sgdfds',
                                        Commencement_Date__c = date.today(),  //.parse('1/1/2009'),
                                        Vendor_Account_Number__c = 'sgfsdf',
                                        Quickbooks_Account_Name__c = 'QB Account Name',
                          				           
                                        Billing_Vendor__c = vend.ID);
        insert vendLoc; 
        vendLoc = [select ID, Locationnew__c from Vendor_Location__c where Locationnew__c = :loc.ID Limit 1];
        System.debug('vendloc = ' + vendLoc + '   Loc.ID = ' + loc.ID);
        vendorBillRecord.Vendor_Location__c = vendLoc.ID;
        
        insert vendorBillRecord;
        
        invoiceDetails.Vendor_Bill__c  = vendorBillRecord.Id;/*Save Error: Initial term of field expression must be a concrete SObject List<Invoice_and_Billing_Detail__c>*/
        update invoiceDetails;
        
        delete invoiceDetails; 
    }

Any help would be great!

 

Thank you in advance.

  • February 03, 2012
  • Like
  • 0

How can I use query to get value atleast 0 but not null ???

Like In SQL,

I can check value at query execution as [ SELECT ISNULL(fieldname, 0) FROM tablename ].

If the value is null then it will assign it to as 0 but not null.

same thing that i want in SOQL then how do i get that ?

 

should I set formula field in the object field ??

or I can do this by query itself ??

 

please reply me fast

I am trying to Auto populate the name of client in Related to Client field which is a custom field on standard Idea object .

Idea is a salesforce standard object.

Onclick of button I have to display relateded Opportunity Name on Related to opportunity test box.

I am trying to pass the value for Related to opportunity field as below in URL which i have written on button logic

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp

On click of button I am getting Id in URL as below
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

Opportunity value is displaying on the text box.

Can anybody suggest on above issue.
how to populate value which i am passing in URL.
 

Idea object have Opportunity__c Look up fields with search option.From view source i got as below for Opportunity custom field
<input  id="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" maxlength="255" name="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" onchange="getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid').value='';getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_mod').value='1';" size="20" type="text" /><script  type="text/javascript">
I have tried with below option but its not working.
Please help me on this.

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c={!Opportunity.Name}&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&Opportunity__c={!Opportunity.Name}&Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp

Thanks
Ajit

  • February 05, 2012
  • Like
  • 0

Hello,

 

I try to delete a trigger and its test class from production.

I follow this process :

 

Using the IDE:
1) Assuming you have a sandbox environment synchronized with your Prod org, you will first want to inactivate the trigger in sandbox.  You can refresh your IDE project to consume these changes
2) In the Sandbox org, you will then want to run all tests: Navigate to Setup->Develop->Apex Classes and click "Run All Tests".  This will run all of the tests in the sandbox org.  This is an important step to validate whether or not the inactive trigger has impacted any asserts within your test methods.  Assuming this behavioral change has impacted your tests, you will need to update your asserts to reflect this.
3) Once all tests are passing, you can now deploy these changes to your production environment.  You can use the Deploy to Server wizard in the IDE.  Simply select the tests that you have modified, as well as the inactive trigger, and deploy these changes to your production environment.
4) Validate the trigger is now inactive in your production environment.

Deleting the trigger (if necessary - an inactive trigger will not fire and therefore can be considered as "soft deleted")
5) Create a new IDE project against your Active production org.
6) Right click on the specified trigger and select delete.  Accept the option to delete from server.  Since the trigger is inactive - it can now be deleted from the production environment.

But I can't deploy an inactive trigger, I have this error :

Failure Message: "System.AssertException: Assertion Failed: Expected: 1002, Actual: null", Failure Stack Trace: "Class.PI_Num_Auto_Increment_Test_Class.validate_PI_Num_Auto_Increment: line 38, column 9 External entry point"

 

Can you explain me how can I do this deletion ?

 

Thank you.

hi i am always doing wrong with void and non void method i am not understanding when , where and how these methods are used , could any body explain in detail

I am an administrator that is working on someone elses code. I know the basics about Java programing and even less on apex.  My goal is the get the test coverage above 75%.

 

Most of my errors are

 

"System.QueryException: List has no rows for assignment to SObject".

 

From what I am reading on other boards I have a basic idea of what I need to change. But once I change it, something else down the code gives me an errors.

Here is the original code

 public static testMethod void testManageVendorBillDetails(){  
        Invoice_and_Billing_Detail__c invoiceDetails = [Select Id,Adjustment_amount__c,Amount__c, Vendor_Bill__c
        from Invoice_and_Billing_Detail__c  limit 1 for Update];  
      

 Then I changed it to a List<>

 public static testMethod void testManageVendorBillDetails(){  
        List <Invoice_and_Billing_Detail__c> invoiceDetails = [Select Id,Adjustment_amount__c,Amount__c, Vendor_Bill__c
        from Invoice_and_Billing_Detail__c  limit 1 for Update];  
          

 But now I get an error further down the method. Here is the whole method and I will note what line (towards the bottom) that is giving me the error.

 public static testMethod void testManageVendorBillDetails(){  
        List <Invoice_and_Billing_Detail__c> invoiceDetails = [Select Id,Adjustment_amount__c,Amount__c, Vendor_Bill__c
        from Invoice_and_Billing_Detail__c  limit 1 for Update];  
          
        Vendor_Bills__c vendorBillRecord = new Vendor_Bills__c();
        vendorBillRecord.Bill_Date__c = System.today();
        vendorBillRecord.Due_Date_On_Bill__c = System.today().addDays(10);
        vendorBillRecord.Vendor_Invoice_Number__c = 'Test Bill Record';

        Account vend = new Account(Name = 'Test Vendor', 
                       Phone = '(508) 555-1212',
                       Fax = '(508) 555-1213',
                       Type = 'Vendor',
                       Address1__c = 'asfasd',
                       City__c = 'myTstVen',
                       State__c = 'MA',
                       Zip_Code__c = '2090',
                       Company_Name__c = 'Test Vendor',
                       QB_Account__c = 'QB Account Name',
                       Account_QB_Account_Name__c = 'QB Account Name Ven',
                       Account_Code__c = 'testven1');
        insert vend;
        vend = [select ID from Account where Name Like '%myTstVen%' Limit 1];
        
        User userNAM = [select Id from User limit 1];
        
        Account acct = new Account(Name = 'Test Account Name', 
                   Phone = '(508) 555-1212',
                   Fax = '(508) 555-1213',
                   Type = 'Client',
                   Address1__c = '2234234',
                   City__c = 'ShortPayTstClnt',
                   State__c = 'MA',
                   Zip_Code__c = '2090',
                   QB_Account__c = 'QB Account Name',
                   Account_QB_Account_Name__c = 'QB Account Name',
                   Account_Code__c = 'aewrew',
                   NAM_User__c = userNAM.Id,
                   Generate_Tree_Report_Data__c = false,
                   Generate_Tree_Report_As_Of__c = date.today());
        
    	insert acct;
    	
        Contact tstContact = new Contact(LastName = 'test',
						AccountId = acct.Id,
						Contact_Type__c = 'Client',
						Phone = '(555) 555-5555',
						Contact_Region__c = 'test');
    	insert tstContact;
    
        Location__c loc = new Location__c(Name = 'myTst Location', 
                                    Account__c = acct.Id, 
                                    Address__c = '12543',
                                    City__c = '233',
                                    State__c = 'ID',
                                    Zip_Code__c = '2090',
                                    Location_County__c = 'asfsd',
                                    Active_Date__c = date.today(),  //.parse('1/1/2009'),
                                    //Location_Billing__c = 'TestLoc2',
                                    Non_Active_Date__c = date.today(),
                        			Non_Active_Reason_Code__c='asfsd',
                       			    Close_Date__c =date.today(),
                                    Billing_Address_1__c = '23q234',
                                    Billing_City__c = 'Westwood',
                                    Billing_Zip__c = '2090',
                                    Billing_State__c = 'MA',
                                    Quickbooks_Account_Name__c = 'QB Account Name',
                                    Market_Type__c='Open Market',
                                    Contact2__c = tstContact.Id);
                                   
        insert loc; 
            
        loc =  [select ID, Name, Account__c, Account__r.Name from Location__c where Name = 'myTst Location' Limit 1];
        Vendor_Location__c vendLoc = new Vendor_Location__c(Name = 'mytestven1 (sgfsdf)',
                                        RecordTypeId = '01280000000BTSPAA4',
                                        Locationnew__c = loc.ID,
                                        Vendor__c = vend.ID,
                                        PO_Number__c = 'sgdfds',
                                        Commencement_Date__c = date.today(),  //.parse('1/1/2009'),
                                        Vendor_Account_Number__c = 'sgfsdf',
                                        Quickbooks_Account_Name__c = 'QB Account Name',
                          				           
                                        Billing_Vendor__c = vend.ID);
        insert vendLoc; 
        vendLoc = [select ID, Locationnew__c from Vendor_Location__c where Locationnew__c = :loc.ID Limit 1];
        System.debug('vendloc = ' + vendLoc + '   Loc.ID = ' + loc.ID);
        vendorBillRecord.Vendor_Location__c = vendLoc.ID;
        
        insert vendorBillRecord;
        
        invoiceDetails.Vendor_Bill__c  = vendorBillRecord.Id;/*Save Error: Initial term of field expression must be a concrete SObject List<Invoice_and_Billing_Detail__c>*/
        update invoiceDetails;
        
        delete invoiceDetails; 
    }

Any help would be great!

 

Thank you in advance.

  • February 03, 2012
  • Like
  • 0

How do you join a  "recursive" object (returning values from two records in one row) using SOQL?

 

In UserRole for example, I'd like to show the Id, Name, and Name of the parent of the role (if any)

 

In SQL, it would be something like:

 

select Id, Name, (select Name from UserRole Y  where Y. Id=X.ParentRoleId) as TheParentRolesName

from UserRole X

 

Is there a SOQL equivalent?  Also, would the syntax vary between Standard and Custom objects?


My objective is to insert 500,000 records in ObjectA__c created by looping through Prooduct2 (1,000 records) and Area__c (500 records) objects.


My code below runs fine on for a small sample of the records, however I hit governor limits when trying to executive all records.

 

I been reading on batch apex thinking it may solve my problem, however having never used batch apex, I am not sure if I can pass in the two Objects I need to create the records for the ObjectA__c inserts based on the examples.  If I can, can someone please provide an example on how?

If not any suggestions or examples on how to solve this problem would be greatly appreciated?

 

Thanks in advance

 

public class RefreshAllObjectARelationships {


Public pagereference doRefreshAllObjectARelationships() {
    
    List<ObjectA__c> deleteObjectA_records = [SELECT ID FROM ObjectA__c]; 
    
    System.Debug('DEBUG: deleteObjectA_records List Size =' + deleteObjectA_records.size());
    
    DELETE deleteObjectA_records;
    
    List<Product2> products = [SELECT ID, Name FROM Product2]; //1000 Products returned from Query
   
       System.Debug('DEBUG: products List Size = ' + products.size());
   
    List<Area__c> Areas = [SELECT ID, Name FROM Area__c]; //500 ObjectA records returned from Query
    
	System.Debug('DEBUG: Areas List Size = ' + Areas.size());
    
    
    List<ObjectA__c> ObjectARelationships = new List<ObjectA__c>();
    
        for(Product2 prod : products){
        
        integer i = 0;
        
            for(Area__c A: Areas){
        
                i++;
            
                ObjectA__c ObjA_record = new ObjectA__c(Area__c = A.ID, Service_Task__c = prod.ID);
                             
                      
                      if(i>10){
                        i=0;
                        InsertObjectA_records (ObjectARelationships);
                        ObjectARelationships.Clear();
                    }
                    
                
                    
                    ObjectARelationships.add(ObjA_record);
            }   
        }
        
    InsertObjectA_records (ObjectARelationships);
    
    RETURN NULL;
    
}


public void InsertObjectA_records(List<ObjectA__c> insertObjA_recordList){

System.Debug('DEBUG: ObjA_record List size = ' + insertObjA_recordList.size());

INSERT insertObjA_recordList;

System.Debug('DEBUG: ObjA_record records inserted');


insertObjA_recordList.clear();

  
    
}  

 

  • February 03, 2012
  • Like
  • 0

Hello Friends,

 

We are trying to call a web service which is residing in SAP. To do this we have created an Apex Class using 'Generate from WSDL' and trying to call it from Apex Triggers using following code. However, this is not working.

------------------------------------------------------------------------------------

trigger Oppurtunitycreate on Opportunity (after update) {

    SAPWS.binding BI = new SAPWS.binding();
    BI.ZasEsTest();
   
   System.debug('Price before inserting new book'); 
}

------------------------------------------------------------------------------------

Could you please suggest if this is correct? Or please suggest us the possible ways to do this integration.

 

If someone can share a sample code, that would be of great help!

 

Best regards,

Navneet.

hi all

 

 

i have taken some string values into a list

now my requirement is i want to display each of them single

 

for ex: i have taken a,b,c values into a list variable str

 

 

now if i give str[0] i should get a

str[1] then b and so on how can i display them in a visual force page