• bainesy
  • NEWBIE
  • 40 Points
  • Member since 2016
  • CEO
  • Forcivity


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 23
    Replies
I have seen eclipse IDE where Apex class and Controller as well visualforce page can be created just like Salesforce console developer.
Is there any way we can have same in VSS IDE.

Regards
Aniket
I've gone through every step successfully but am banging my head against the wall with step 8. I have more than adequate code coverage but continue to get this error message:
User-added image
I have gone back and rewritten OrderTests twice according to the requirements but can't get past this error. Anyone else had any luck with this?

Here's my code for reference:
@isTest (SeeAllData=false)
private class OrderTests {
    
    static void SetupTestData() {
	    TestDataFactory.InsertTestData(5);
    }
 
    @isTest static void OrderExtension_UnitTest() {
        PageReference pageRef = Page.OrderEdit;
        Test.setCurrentPage(pageRef);
        SetupTestData();
        ApexPages.StandardController stdcontroller = new ApexPages.StandardController(TestDataFactory.orders[0]);        
        OrderExtension ext = new OrderExtension(stdcontroller);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
@isTest
public static void OrderUpdate_UnitTest(){
    setupTestData();
    
   
    Test.startTest();
    
    List<Order> orders = TestDataFactory.orders;
    for (Order o : orders){
        o.Status = Constants.ACTIVATED_ORDER_STATUS;
    }
    List<Product2> oldProducts = TestDataFactory.products;
    Set<Id> productIds = new Set<Id>();
    for (Product2 oldProd : oldProducts){
        productIds.add(oldProd.Id);
    }
    oldProducts = [SELECT Id, Quantity_Ordered__c FROM Product2 WHERE ID IN :productIds];
    Map<Id, Integer> quantities = new Map<Id, Integer>();
    for (OrderItem oi : TestDataFactory.orderItems){
        Integer quantity = 0;
        List<PricebookEntry> pricebookentries = TestDataFactory.pbes;
        for (PricebookEntry pbe : pricebookentries){
            if (oi.PricebookEntryId == pbe.Id){                
                if (quantities.containsKey(pbe.Product2Id)){
                    quantity = quantities.get(pbe.Product2Id);
                }
                quantity += (Integer)oi.Quantity;
                quantities.put(pbe.Product2Id, quantity);
                break;
            }
        }
    }
   
    update orders;
    Map<Id, Product2> currentProducts = new Map<Id, Product2>([Select Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);
  
    for (Product2 prod : oldProducts){
      
        TestDataFactory.VerifyQuantityOrdered(prod, currentProducts.get(prod.Id), quantities.get(prod.Id));
  }
  Test.stopTest();
}
}

 
Hello Mates,

I am getting below error when I am in Lightning Experience Rollout Specialist step - 6 though I am using new trailhead playground.

Challenge Not yet complete... here's what's wrong:
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: GZQPYBSK
I've gone through every step successfully but am banging my head against the wall with step 8. I have more than adequate code coverage but continue to get this error message:
User-added image
I have gone back and rewritten OrderTests twice according to the requirements but can't get past this error. Anyone else had any luck with this?

Here's my code for reference:
@isTest (SeeAllData=false)
private class OrderTests {
    
    static void SetupTestData() {
	    TestDataFactory.InsertTestData(5);
    }
 
    @isTest static void OrderExtension_UnitTest() {
        PageReference pageRef = Page.OrderEdit;
        Test.setCurrentPage(pageRef);
        SetupTestData();
        ApexPages.StandardController stdcontroller = new ApexPages.StandardController(TestDataFactory.orders[0]);        
        OrderExtension ext = new OrderExtension(stdcontroller);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
@isTest
public static void OrderUpdate_UnitTest(){
    setupTestData();
    
   
    Test.startTest();
    
    List<Order> orders = TestDataFactory.orders;
    for (Order o : orders){
        o.Status = Constants.ACTIVATED_ORDER_STATUS;
    }
    List<Product2> oldProducts = TestDataFactory.products;
    Set<Id> productIds = new Set<Id>();
    for (Product2 oldProd : oldProducts){
        productIds.add(oldProd.Id);
    }
    oldProducts = [SELECT Id, Quantity_Ordered__c FROM Product2 WHERE ID IN :productIds];
    Map<Id, Integer> quantities = new Map<Id, Integer>();
    for (OrderItem oi : TestDataFactory.orderItems){
        Integer quantity = 0;
        List<PricebookEntry> pricebookentries = TestDataFactory.pbes;
        for (PricebookEntry pbe : pricebookentries){
            if (oi.PricebookEntryId == pbe.Id){                
                if (quantities.containsKey(pbe.Product2Id)){
                    quantity = quantities.get(pbe.Product2Id);
                }
                quantity += (Integer)oi.Quantity;
                quantities.put(pbe.Product2Id, quantity);
                break;
            }
        }
    }
   
    update orders;
    Map<Id, Product2> currentProducts = new Map<Id, Product2>([Select Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);
  
    for (Product2 prod : oldProducts){
      
        TestDataFactory.VerifyQuantityOrdered(prod, currentProducts.get(prod.Id), quantities.get(prod.Id));
  }
  Test.stopTest();
}
}

 
I am new to this org I am currently working in. I am deploying my first trigger as an admin. I received the attached 2 errors. Any ideas on how I can troubleshoot these:

User-added image
$query = "SELECT count() from Normal_Service__c ";

$response = $mySforceConnection->countQuery($query);

print_r ($response);

$mySforceConnection returns a value to show a connection to the database. 
Any ideas why this code fails to fill the variable $response with the number of records in the custom object Normal_Service__c ?   Thanks.
All the other data is showing except for job title:  

<input id="00ND000000670JS" placeholder="Job Title" maxlength="100" name="job_title_c" size="20" type="text" required /> 

Melanie
Hi All,

I am getting 'System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set ' exception while parsing json, Please help

Thanks.
public class JSONWrapper{
   
    public cls_result[] result{get;set;}
    class cls_result {
        public String parent{get;set;}   //
        public String made_sla{get;set;} //true
        public String caused_by{get;set;}    //
        public String watch_list{get;set;}   //
        public String upon_reject{get;set;}  //cancel
        public String sys_updated_on{get;set;}   //2017-06-20 07:52:14
        public String child_incidents{get;set;}  //0
        public String hold_reason{get;set;}  //
        public String approval_history{get;set;} //
        public String number1{get;set;}   //5002800000m9AD4AAM
        public String resolved_by{get;set;}  //
        public String sys_updated_by{get;set;}   //admin
        public cls_opened_by opened_by{get;set;}
        public String user_input{get;set;}   //
        public String sys_created_on{get;set;}   //2017-06-20 07:52:14
        public cls_sys_domain sys_domain{get;set;}
        public String state{get;set;}    //1
        public String sys_created_by{get;set;}   //admin
        public String knowledge{get;set;}    //false
        public String order{get;set;}    //
        public String calendar_stc{get;set;} //
        public String closed_at{get;set;}    //
        public String cmdb_ci{get;set;}  //
        public String delivery_plan{get;set;}    //
        public String impact{get;set;}   //3
        public String active{get;set;}   //true
        public String work_notes_list{get;set;}  //
        public String business_service{get;set;} //
        public String priority{get;set;} //5
        public String sys_domain_path{get;set;}  ///
        public String rfc{get;set;}  //
        public String time_worked{get;set;}  //
        public String expected_start{get;set;}   //
        public String opened_at{get;set;}    //2017-06-20 07:52:14
        public String business_duration{get;set;}    //
        public String group_list{get;set;}   //
        public String work_end{get;set;} //
        public cls_caller_id caller_id{get;set;}
        public String resolved_at{get;set;}  //
        public String approval_set{get;set;} //
        public String subcategory{get;set;}  //
        public String work_notes{get;set;}   //
        public String short_description{get;set;}    //This is test incident created from salesforce CRM
        public String close_code{get;set;}   //
        public String correlation_display{get;set;}  //
        public String delivery_task{get;set;}    //
        public String work_start{get;set;}   //
        public String assignment_group{get;set;} //
        public String additional_assignee_list{get;set;} //
        public String business_stc{get;set;} //
        public String description{get;set;}  //
        public String calendar_duration{get;set;}    //
        public String close_notes{get;set;}  //
        public String notify{get;set;}   //1
        public String sys_class_name{get;set;}   //incident
        public String closed_by{get;set;}    //
        public String follow_up{get;set;}    //
        public String parent_incident{get;set;}  //
        public String sys_id{get;set;}   //b2472d10db23320085fe72ffbf961960
        public String contact_type{get;set;} //
        public String incident_state{get;set;}   //1
        public String urgency{get;set;}  //3
        public String problem_id{get;set;}   //
        public cls_company company{get;set;}
        public String reassignment_count{get;set;}   //0
        public String activity_due{get;set;} //
        public String assigned_to{get;set;}  //
        public String severity{get;set;} //3
        public String comments{get;set;} //
        public String approval{get;set;} //not requested
        public String sla_due{get;set;}  //
        public String comments_and_work_notes{get;set;}  //
        public String due_date{get;set;} //
        public String sys_mod_count{get;set;}    //0
        public String reopen_count{get;set;} //0
        public String sys_tags{get;set;} //
        public String escalation{get;set;}   //0
        public String upon_approval{get;set;}    //proceed
        public String correlation_id{get;set;}   //
        public String location{get;set;} //
        public String category{get;set;} //inquiry
    }
    class cls_opened_by {
        public String link{get;set;} 
        public String value{get;set;}  
    }
    class cls_sys_domain {
        public String link{get;set;} 
        public String value{get;set;}    
    }
    class cls_caller_id {
        public String link{get;set;} 
        public String value{get;set;}   
    }
    class cls_company {
        public String link{get;set;} 
        public String value{get;set;}    
    }
    public List<JSONWrapper> parse(String json){
        return (List<JSONWrapper>) System.JSON.deserialize(json, List<JSONWrapper>.class);
        
        
    }

    
}
 
public class ServiceNowCntrl {
    
    public string bodyText{get;set;}
    public ServiceNowCntrl (){
    doInit();
    }
    public void doInit(){
           
        try{
        
        string user='xxx';
        
        string password='xxxxxxxx';
        
        HttpRequest request = new HttpRequest();

        request.setEndpoint('https://dev18687.service-now.com/api/now/table/incident?sysparm_limit=10');

        Blob auth = Blob.valueOf(user+':'+password);

        System.debug('Auth: '+ auth);

        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(auth);
        
        request.setMethod('GET');
 
        request.setHeader('Authorization', authorizationHeader);
       
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        
            Http http = new Http();
            HttpResponse res = new HttpResponse();

            res = http.send(request);
            system.debug(res.getBody());
            bodyText=res.getBody();
            
           JSONWrapper jw=new JSONWrapper();
           list<JSONWrapper> jwList=new List<JSONWrapper>();
           jwList=jw.parse(bodyText);

        }catch(System.CalloutException e){
            System.debug('Erro: '+ e.getMessage());
        }
        
    }
    
}

 
Hello,

I'm working to build a simple, custom territory management solution for my org; other territory management tools don't quite do the trick. Basically, I need to assign accounts to territories based on the zip code value in the account's billing address.

First, some object details: I have a custom object for Territories and a custom object for Zip Codes. Each Zip Code record has a lookup field for a Territory record, which basically signifies that the zip code "belongs" to the related territory. I can go to each Territory record and see a related list of the associated Zip Code records. I also have a Territory lookup field on the account record. (I was told that I may need a Zip Code lookup on the account as well to serve as a junction, but I'm not sure about that one yet...)

Now, what I want to accomplish: I need to create an apex trigger that says, "if the value in the account's billing zip code matches the name of any existing Zip Code record, then 'Territory' (on the account) equals the Territory related to that matched Zip Code record."

I was hoping to accomplish this via process builder, but Salesforce Support informed me that this won't be possible... which brings me here. Can anyone help me get started on coding an apex trigger that can accomplish what I stated above? I'd appreciate any guidance you can provide.

Thank you!

I generated enterprise wsdl with below package versions

Package Versions: Unique Entry (Version: 4.0, Namespace: uniqueentry) Rollup Helper - Real-Time (Version: 7.5, Namespace: rhx) Data.com Reports (Version: 1.10, Namespace: jsimpacts) Field Trip (Version: 1.2, Namespace: field_trip) WalkMe for Salesforce (Version: 2.16, Namespace: wm4sf3) Salesforce Connected Apps (Version: 1.6, Namespace: sf_com_apps) Box for Salesforce (Version: 3.46, Namespace: box) Aspira XObject (Version: 1.37, Namespace: aspirax) Data.com Assessment (Version: 3.0, Namespace: ddcassess) Sales Leaderboard (Version: 1.23, Namespace: salesleader) DupeDive (Version: 1.4, Namespace: dupedive) Salesforce1 and Chatter Apps (Version: 1.9, Namespace: sf_chttr_apps) Zendesk for Salesforce (Version: 3.20, Namespace: zendesk) RingDNA for Salesforce (Version: 1.0, Namespace: ringdna) Mass Contact Transfer (Version: 9.14, Namespace: f2b) Apsona for Salesforce (Version: 1.4, Namespace: apsona) Rollup Helper (Version: 7.14, Namespace: rh2) OneMob (Version: 1.8, Namespace: onemob) AAKonsult Campaign Status (Version: 1.4, Namespace: aakcs)

And when I am trying to access Order_Form__c object through `describeSObject("Order_Form__c")`, the function call is giving me "com.sforce.soap.enterprise.fault.InvalidSObjectFault: null" exception. 

Can someone help me with this?

Desperately needing some help here! 

I have a batch class that sends an email to a lead owner based on the Status not changing during a specified timeframe. I manually tested it (without the time query filter) and the code was doing what it needs to do. I've now written the test code only to find the Leadhistory query returns an null record set. I can see the Leads have an ID and I perform some status updates on the test method to generate the LeadHistory records so im clueless as to why it is not returning any records.

test method:
@isTest
private class LeadStatusBatchTest {
	
	@isTest static void test_method_one() {
		// First Load some Leads from resource file
		List<sObject> leads = Test.loadData(Lead.sObjectType, 'Default_Lead_Test_Data');
		system.debug('### [LeadStatusBatchTest] leads (loaded test data): '+ leads);

		//set a datetime to 4 weeks ago to update createdDate
		Datetime weeksAgo_4 = Datetime.now().addDays(-28);
		
		for(Lead ld: (List<Lead>)leads) {
			//update the status and save to DB
			ld.Status = 'Open';
			Test.setCreatedDate(ld.Id, weeksAgo_4.addDays(-7));
		} 
		
		update leads; //to generate a leadHistory entry for Open status
		system.debug('### [LeadStatusBatchTest] Updated CreatedDate on Leads: '+ [Select id, CreatedDate From Lead where Id = :leads]);

		//validate update worked
		for(lead ld: [select id, status, createdDate From Lead where id in : leads]){
			system.assertEquals('Open', ld.Status);
			system.assertEquals(weeksAgo_4.addDays(-7), ld.CreatedDate);
		}

		//get the leadhistory records and update their createddate to same as lead created date
		for(LeadHistory lh: [select id, oldvalue, newvalue from LeadHistory where LeadId =: leads]){
			Test.setCreatedDate(lh.id, weeksAgo_4.addDays(-7));
		}
		system.debug('### [LeadStatusBatchTest] LeadHistory testdata: '+ [select id, oldvalue, newvalue from LeadHistory where LeadId =: leads]);

		//update Status to Contacted
		for(lead ld: (List<Lead>)leads){
			ld.Status = 'Contacted';
		}
		update leads;
		
		//get LeadHistory for Lead and update the CreatedDate
		for(LeadHistory lh: [select id, oldvalue, newvalue from LeadHistory where LeadId =: leads]){
			if(lh.newvalue == 'Contacted')
				Test.setCreatedDate(lh.id, weeksAgo_4);
		}
		system.debug('### [LeadStatusBatchTest] leadHistory Contacted status: '+ [select id, oldvalue, newvalue from LeadHistory where LeadId =: leads]);

		//validate LeadHistory CreatedDate
		for(LeadHistory lh: [select id, CreatedDate from LeadHistory where LeadId =: leads]){
			system.assertEquals(weeksAgo_4, lh.CreatedDate);
		}

		test.startTest();
			//run batch class
			LeadStatusBatch db = new LeadStatusBatch();
			database.executeBatch(db);
		test.stopTest();
		system.debug('### [LeadStatusBatchTest] Stopped Test. ');
		
		//make validations if execution was successful


	}
	
	
}

When I run the test the test method debugs return a null data set on the LeadHistory query that is supposed to set the CreatedDate. All queries before that work just fine.

Is it that you cant query hte LeadHistory table on a testmethods? (doesnt seem right)
Or that changes to the lead are not tracked in LeadHistory?

Any help here would be much appreciated! 
 
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis