• Tanner Russell
  • NEWBIE
  • 180 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 46
    Replies
I have  written a practice trigger Which populates the Description feild on Account object If the Industry = Banking. From the UI it works good. Also get 100 Test coverage. I feel the trigger is not firing from Test class because my System.debug are not logging the fields I need. I would be very thankful if anyone can point out my mistake. I would like to add my System.assertEquals are failing. Please help me learn


/*Trigger*/

trigger UpdateDescriptionOnAccount on Account (before insert) {
    list<Account> ActList=new list<Account>();
    for(Account a :Trigger.new)
    {
        if(a.Industry=='Banking' && a.Description == Null)
        {
            a.Description='This is a Banking Account';
            ActList.add(a);
        }
       
    }
    //insert ActList;

}

This is my test Class
/*Test Class*/

@isTest
public class TestUpdateDescriptionOnAccount {
    static testmethod void TestUpdate()
    {
       Account a = New Account(Name='Test Account 1',Industry='Banking');
       insert a;
      System.debug('Account Inserted '+a.Name + 'Description ='+a.Description +a.Industry);
       //system.assertEquals('This is a Banking Account',a.Description);
       
        
       Account b = New Account(Name='Test Account 2',Industry='Agriculture');
       insert b;
       //System.assertEquals(Null, b.Description);
        
       list<Account>testAccount = new List<Account>();
        for(integer i=0;i<200;i++)
        {
            Account c = new Account(Name='Account '+i, Industry='Banking');
            testAccount.add(c);
        }
        test.startTest();
        	insert testAccount;
        test.stopTest();
      for(Account d : TestAccount)
       {
            //system.assertEquals('This is a Banking Account',d.Description);
           System.debug('Account Inserted '+d.Name + 'Description ='+d.Description);
       }
        
    }

}


 
Hi All,

I am not a developer at all and tried to deploy a small apex class from Sandbox to Production and hit this error below. Any help and/or guidance is highly appreciated
Screenshot of Error

Thank You
  • April 12, 2017
  • Like
  • 0
So I am stumped when it comes to getting passed timed events on a flow/process builder in a test class, I am able to invoke the process using a simple update/insert on the record but in the middle of the process there is a wait 1 hour.
What I have found so far is that I am able to query the FlowInterview based on the label but cannot/do not know how to forcefully start the FlowInterview through code. I have the interview wrapped in a test.starttest and test.stoptest so in theory if I can just force the execution the rest should just work.
If anyone here has experience writing test coverage for timed Flow/process builder events and can give me some tips it would be a huge help.
 
FlowInterview fI  = [select id, name,InterviewLabel,CurrentElement,Guid,PauseLabel,WasPausedFromScreen   from flowinterview where InterviewLabel = 'Change_Record_Type_to_RR_Escalation-15_InterviewLabel' limit 1]; 
//Somehow force the interview to continue		  //Flow.resumeFlow(fI);

 
I have a very weird situation where I have code that queries admin users and fixes their email address on sandbox refresh. The issue I am having is the code works perfectly fine if I click the refresh button but if another system admin with exact same permissions clicks it the code will fail and spit out this username is already used in another org error, I have even tried using the login as option and chose a fellow admin and the code failed. Another note I refreshed the exact same sandboxes that they did while they got the error it worked for me... any advice helps we have all same permissions.
I have the task where I need to make all of the data export dynamic and automated I have the automation part all handled the issue Im running into is on the line
<entry key="sfdc.extractionSOQL" value="Select Id, name FROM Account"/>
I need this to cover all of the fields on the object and if a new field was added that day it will need to be added to the query and included..

basically I just need a way to change all my extraction queries to select * from account etc for each object and it will be done and working any ideas? does sfdc support the select * syntax or a variation?
I have a tree view of records 
->Account
            Contact
                     Case
each have urls linking to the record they are related to but as per my instructions I am supposed to embed this records page in the visual force page when clicked for easy viewing does anyone know how I can approach this?
I want to compare 2 fields in child objects of a parent in a single query I thought the query below might do it by readding the select to it but it does not like that. How can I do this if its possible? I am comparing a field called block_number__c on each object, Thanks (possibly using the Not In could work?)

select id, (Select id, property_name__r.name, block_number__c from Spaces__r where Occupied__c = true or occupied_rr__c = true limit 1), (Select id, block_number__c, property_name__c from contacts) from account where (Select id, block_number__c, property_name__c from contacts).block_number__c != (Select id, property_name__r.name, block_number__c from Spaces__r where Occupied__c = true or occupied_rr__c = true limit 1).block_number__c

 
Account la_test = new Account(Name='Test');
        insert la_test;
	Contact lcon_test = new Contact(LastName='Test', Accountid=la_Test.id, Email='test@test.com');
        insert lcon_test;
        location__C lloc_test = new Location__C(name = locName, site_wf__c = site);
        insert lloc_test;
        RecordType rec = [SELECT Id,Name FROM RecordType WHERE SobjectType='Case' and name = :record];
        Case lc_test = new Case(Subject='This is a test ', Accountid=la_Test.id, Status='New', RecordTypeId=rec.id, Contactid=lcon_test.id, Location__c= lloc_test.id,  Notify_contact__c = true); 
        //for trigger testing

        insert lc_test;
If I do a lookup query on the location id being passed into case its name value is populated but when I do lc_test.location__r.name it shows as null (location__c being a lookup field) does anyone know what im doing wrong?
I need help with modifying my code to work around the heap size limit I have tried using @future but it seems to be having issues with my callout session ID can anyone give me tips on how this can be worked around with this code?
public class TransferLiveData {
    
    public static void TransferData(Boolean IsCreate, String resourceName, String ContentT, String CacheCont){
        //create a list to hold the object maps
        List<Map<id,sObject>> masterList = new List<Map<id,sObject>>();
        //convert each query results from List<sObject> to Map<id,sObject> 
        //using query util library to pull all fields
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllLimit(Account.getSObjectType().getDescribe(), 'limit 25')));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Space__c.getSObjectType().getDescribe(), 'Account__c', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Contact.getSObjectType().getDescribe(), 'Accountid', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Case.getSObjectType().getDescribe(), 'Space__c', masterList[1].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Asset.getSObjectType().getDescribe(), 'Space__c', masterList[1].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Lease__c.getSObjectType().getDescribe(), 'Space__c', masterList[1].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Opportunity.getSObjectType().getDescribe(), 'Accountid', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAllWhereIN(Contract.getSObjectType().getDescribe(), 'Accountid', masterList[0].keySet())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAll(Location__c.getSObjectType().getDescribe())));
        masterList.add(new Map<id,sObject>(QueryUtil.QueryAll(Lead.getSObjectType().getDescribe())));
        
        //serialize the the json
        String jsonDump = JSON.serialize(masterList);
        
        //is this going to be a new static resource or an update
        if(IsCreate){
            MetadataServiceExamples.createStaticResource(resourceName, ContentT, CacheCont, jsonDump);
        }else{
            MetadataServiceExamples.updateStaticResource(resourceName, ContentT, CacheCont, jsonDump);


        }
        
       
        
    }
}

 
I am trying to setup a method that will be auto run when the sandbox is refreshed the problem is that it is an aync class and I am getting
'Unsupported parameter type SandboxContext' since @future methods must be static. Does anyone know of a way to setup async SandboxPostCopy  methods?

global class FixSandboxUsers implements SandboxPostCopy {
    @future
    global static void runApexClass(SandboxContext context){
I have a class that fixes sandbox user emails and a test class that inserts users than calls the method to fix the emails. This code works if I just run it but  cant get it to work on the test data. Anything Im missing? It fails on the assert.
 
//Fix emails of the admin users on the sandboxs automatically
public class FixSandboxUsers {
    @future
    public static void FixUsers(){
        //make sure its a sandbox enviroment
        if([SELECT IsSandbox FROM Organization LIMIT 1].IsSandbox){
            //get the system admin profile
            Profile p = [Select id, name from Profile where name='System Administrator' limit 1];
            //check users with that profile
            List<User> use = [Select id, name, email, Profileid from user where profileid = :p.id];
            //update each users email
            for(User u : use){
                u.email = u.Email.replace('=','@').replace('@example.com','');
                //debug print out the email
               // System.debug(u.Email);
            }
            //update the users
            update use;
        }
    }
}
@isTest
public class FixSandboxUsers_Test {
    @isTest
    public static void FixUsers_Test(){
        Profile profileId = [SELECT Id FROM Profile WHERE Name = 'System Administrator' LIMIT 1];
        List<User> userList = new List<User>();
        for(integer i = 0; i < 10; i++){
            userList.add(new User(LastName = 'LIVESTON' + i,
                                FirstName='JASON' + i,
                                Alias = 'jliv' + i,
                                Email = 'TESTADDRESS' + i + '=asdf.com@example.com',
                                Username = 'TESTADDRESS' + i + '@asdf.com',
                                ProfileId = profileId.id,
                                TimeZoneSidKey = 'GMT',
                                LanguageLocaleKey = 'en_US',
                                EmailEncodingKey = 'UTF-8',
                                LocaleSidKey = 'en_US'
                               ));
        }
        insert userList;
        Test.startTest();
        FixSandboxUsers.FixUsers();
        Test.stopTest();
        For(User u : userList){
            System.debug(u.Email);
            System.assert(!u.email.contains('='));
            System.assert(!u.email.contains('@example.com'));
           
        }
       
    }
}


 
I have users that have sandboxes but the issue is when I refresh the boxs for them the email gets changed to the default @example.com one. How can I setup a user for a sandbox so the email does not change?
I have created a list of maps and serialized it into a json string. What I would like to be a able to do is deserialize this string back into the same List of maps that was used to serialize it. Is this possible or is there a workaround I can perfom? thanks
//code
String json = JSON.serialize(masterList);
//test
List<Map<id,sObject> masterList = JSON.deserializeUntyped(json);
I am getting this error while trying to delete contacts in a test class
System.DmlException: Delete failed. First exception on row 0 with id 003Q0000018OY8CIAW; first error: INVALID_PERSON_ACCOUNT_OPERATION, cannot reference person contact: []

Deletion works fine if I run the code normally but in the test I get this, how can I work around this for testing purposes or should my query be changed to avoid person accounts?
delete[select id,name from Contact where name like '%test%'];
I have been assigned with making sure nothing breaks while changing the global and user locale from english canada to english USA. From my understanding nothing would break during the change and it might not even be possible to test this? Any sudgestions on this? could somthing go wrong if so any recomendations on how to test this?  
I have been assigned with setting up a way to easily move production data to a developer sandbox after a refresh without the use of excel, I was thinking REST API might be useful. Does anyone know of any easier ways or any tips on how I should approach this?
My salesforce for outlook account was automatically logged out but when I click to log back in and enter my credentials I get this message: 
User-added image
 
A few users that are trying to use the salesforce1 mobile app are having issues loading data or loging in when they try to it will either show a loading screen forever or show an ssl unkown error toast message.
any ideas?
I want to store a json file then read the file from apex how do I upload a file to use? Also any examples of reading in a file to a string would be nice
I have a class that does some work but at the end it needs to call the batch apex and pass a query the problem I am having is I want the query to be only where id in MyMap. For example 
Database.executeBatch(new JsonMassImportBatch('Select id, Name from Contract where id in : ' (Map in the batch class with the ids keyset should be here),'Contract',new JsonMassImportBatch.CustomObj(holdLease,new List<String>{'Current_Rental_Rate__c','Renewal_Date__c'},holdDate)));
The end is me passing in the map for the batch call to use ie holdlease

How should i format the batch side to make this work?  
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query + LeaseMap.keySet());
    }
 
I am not sure how to test an async callout and have not had any luck looking at other posts. I am new to apex so i would appreciate any help, my class is below split into 2 methods due to a conflicting trigger. I need the future due to the 10 second cpu limitation and i need to update 2.5k rows of data based on the json it works when i run it pn my test site but i cant get the test coverage.

public class JSONPullData {
   public static List<Contract> con2;
    public static HttpResponse response;
    
    // @future(callout=true)
    public static HttpResponse parseJSONResponse() {        

            update con2;
        
        return response;
    }
        
        
     
    @future(callout=true)
    public static void processData(){
                //Setup the connection to the json to pull in
        JsonUtil Jutil = new JsonUtil();
         Http httpProtocol = new Http();
        // Create HTTP request to send.
        HttpRequest request = new HttpRequest();
        // Set the endpoint URL.
        request.setEndPoint('url');
        // Set the HTTP verb to GET.
        request.setMethod('GET');
        // Send the HTTP request and get the response.
        // The response is in JSON format.
       response = httpProtocol.send(request);
       
        if(response.getStatusCode() == 200){
            //System.debug(response.getBody());
            
            //deserialize the json 
            List<Object> eqt = (List<Object>) JSON.deserializeUntyped(response.getBody());
            //add the street address to the set the set cannot have duplicates so the street must be unique
            Map<string,string> st = new Map<string,string>();
            Map<string,Double> stRent = new Map<string,Double>();
            for (Object o : eqt){
                Map<String,Object> mapobj = (Map<string,Object>)o;
                
                st.put((String)mapobj.get('Street'),(String)mapobj.get('Date'));
                stRent.put((String)mapobj.get('Street'),(Double)mapobj.get('Rent'));
                
            }
            //find all the space names that match the street in the set
            // System.debug(st);
            Map<ID,Contract> con = new Map<ID,Contract>([Select id, Space__r.Name,Current_Rental_Rate__c, Space__c from Contract where Space__r.Name IN :st.keySet() and Active__c = TRUE]);
            
            //create a list of spaces that are connected to the leases
            List<Space__c> s = [Select id,Name,Active_Contract__c from Space__c where Active_Contract__c IN :con.keySet()];
            //System.debug(s);
            //create maps to locate the data
            Map<id, Double> holdLease = new  Map<id, Double>();
            Map<id, Date> holdDate = new  Map<id, Date>();
            for(Space__c c: s){
                //for (Object o : eqt){
                // Map<string,Object> mapobj = (Map<string,Object>)o;
                //  if(c.Name == (String)mapobj.get('Street')){
                //    System.debug((String)mapobj.get('Renewal Date'));
                //map the rent and renewal date
                System.debug(c.Name);
 
                Date d = date.parse(st.get(c.Name));
                
               
                holdDate.put(c.Active_Contract__c, d);
                holdLease.put(c.Active_Contract__c, stRent.get(c.Name));
                
                
            }
            
            //}    
            
            con2 = [Select id, Space__r.Name,Name,Current_Rental_Rate__c, Space__c from Contract where id in :holdLease.keySet()];
            // System.debug(con2);
            // 
            //set up email
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.setSenderDisplayName('Salesforce Support');
            message.toAddresses = new String[] { 'email@email.com' };
                message.optOutPolicy = 'FILTER';
            message.subject = 'Log Updated Rent for lease rr';
            String mess = '';
            mess = mess + 'Lease ID - Lease Name - Space Name - Rent' + '</br></br>';
            for(Contract c: con2){
                if(holdLease.containsKey(c.id)){
                    //modify the values
                    mess = mess + c.id + ' - ' + c.Name + ' - ' + c.Space__r.Name + ' - ' + c.Current_Rental_Rate__c  + '</br>';
                    c.Current_Rental_Rate__c = holdLease.get(c.id);
                    c.Renewal_Date__c = holdDate.get(c.id);
                }
                
                
            }
            
            message.setHtmlBody(mess);
            Messaging.SingleEmailMessage[] messages =  new List<Messaging.SingleEmailMessage> {message};
                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
            JSONPullData.parseJSONResponse();
    }
    
}
}


@isTest
private class JsonPullDataCallout_Test {
    @isTest static void testCallout() {
        // Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new JsonPullData_Test());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock.
        Test.startTest(); 
        JSONPullData.processData();
        Test.stopTest();
        HttpResponse res = JSONPullData.response;
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '[{"Street":"123 Test Road","Rent":1356.95,"Date":"1/9/2017"}]';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
        
        
    }
}


@isTest
global class JsonPullData_Test implements HttpCalloutMock {
    // Implement this interface method
    public static HTTPResponse res;
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('url', req.getEndpoint());
      
        System.assertEquals('GET', req.getMethod());
        
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"Street":"123 Test Road","Rent":1356.95,"Date":"1/9/2017"}]');
        res.setStatusCode(200);
        return res;
    }

    }
I am not sure how to test an async callout and have not had any luck looking at other posts. I am new to apex so i would appreciate any help, my class is below split into 2 methods due to a conflicting trigger. I need the future due to the 10 second cpu limitation and i need to update 2.5k rows of data based on the json it works when i run it pn my test site but i cant get the test coverage.

public class JSONPullData {
   public static List<Contract> con2;
    public static HttpResponse response;
    
    // @future(callout=true)
    public static HttpResponse parseJSONResponse() {        

            update con2;
        
        return response;
    }
        
        
     
    @future(callout=true)
    public static void processData(){
                //Setup the connection to the json to pull in
        JsonUtil Jutil = new JsonUtil();
         Http httpProtocol = new Http();
        // Create HTTP request to send.
        HttpRequest request = new HttpRequest();
        // Set the endpoint URL.
        request.setEndPoint('https://api.myjson.com/bins/hs68h');
        // Set the HTTP verb to GET.
        request.setMethod('GET');
        // Send the HTTP request and get the response.
        // The response is in JSON format.
       response = httpProtocol.send(request);
       
        if(response.getStatusCode() == 200){
            //System.debug(response.getBody());
            
            //deserialize the json 
            List<Object> eqt = (List<Object>) JSON.deserializeUntyped(response.getBody());
            //add the street address to the set the set cannot have duplicates so the street must be unique
            Map<string,string> st = new Map<string,string>();
            Map<string,Double> stRent = new Map<string,Double>();
            for (Object o : eqt){
                Map<String,Object> mapobj = (Map<string,Object>)o;
                
                st.put((String)mapobj.get('Street'),(String)mapobj.get('Date'));
                stRent.put((String)mapobj.get('Street'),(Double)mapobj.get('Rent'));
                
            }
            //find all the space names that match the street in the set
            // System.debug(st);
            Map<ID,Contract> con = new Map<ID,Contract>([Select id, Space__r.Name,Current_Rental_Rate__c, Space__c from Contract where Space__r.Name IN :st.keySet() and Active__c = TRUE]);
            
            //create a list of spaces that are connected to the leases
            List<Space__c> s = [Select id,Name,Active_Contract__c from Space__c where Active_Contract__c IN :con.keySet()];
            //System.debug(s);
            //create maps to locate the data
            Map<id, Double> holdLease = new  Map<id, Double>();
            Map<id, Date> holdDate = new  Map<id, Date>();
            for(Space__c c: s){
                //for (Object o : eqt){
                // Map<string,Object> mapobj = (Map<string,Object>)o;
                //  if(c.Name == (String)mapobj.get('Street')){
                //    System.debug((String)mapobj.get('Renewal Date'));
                //map the rent and renewal date
                System.debug(c.Name);
 
                Date d = date.parse(st.get(c.Name));
                
               
                holdDate.put(c.Active_Contract__c, d);
                holdLease.put(c.Active_Contract__c, stRent.get(c.Name));
                
                
            }
            
            //}    
            
            con2 = [Select id, Space__r.Name,Name,Current_Rental_Rate__c, Space__c from Contract where id in :holdLease.keySet()];
            // System.debug(con2);
            // 
            //set up email
            Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
            message.setSenderDisplayName('Salesforce Support');
            message.toAddresses = new String[] { 'email@email.com' };
                message.optOutPolicy = 'FILTER';
            message.subject = 'Log Updated Rent for lease rr';
            String mess = '';
            mess = mess + 'Lease ID - Lease Name - Space Name - Rent' + '</br></br>';
            for(Contract c: con2){
                if(holdLease.containsKey(c.id)){
                    //modify the values
                    mess = mess + c.id + ' - ' + c.Name + ' - ' + c.Space__r.Name + ' - ' + c.Current_Rental_Rate__c  + '</br>';
                    c.Current_Rental_Rate__c = holdLease.get(c.id);
                    c.Renewal_Date__c = holdDate.get(c.id);
                }
                
                
            }
            
            message.setHtmlBody(mess);
            Messaging.SingleEmailMessage[] messages =  new List<Messaging.SingleEmailMessage> {message};
                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
            JSONPullData.parseJSONResponse();
    }
    
}
}


@isTest
private class JsonPullDataCallout_Test {
    @isTest static void testCallout() {
        // Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new JsonPullData_Test());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock.
        Test.startTest(); 
        JSONPullData.processData();
        Test.stopTest();
        HttpResponse res = JSONPullData.response;
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '[{"Street":"123 Test Road","Rent":1356.95,"Date":"1/9/2017"}]';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
        
        
    }
}

@isTest
global class JsonPullData_Test implements HttpCalloutMock {
    // Implement this interface method
    public static HTTPResponse res;
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('https://api.myjson.com/bins/hs68h', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());
        


        
        //System.assertEquals(1356.95, con2[0].Current_Rental_Rate__c);
        //System.assertEquals(date.parse('1/9/2017'), con2[0].Renewal_Date__c);
        
        return res;
    }

    }
@isTest
global class JsonPullData_Test implements HttpCalloutMock {
    // Implement this interface method
    public static HTTPResponse res;
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('https://api.myjson.com/bins/hs68h', req.getEndpoint());
      
        System.assertEquals('GET', req.getMethod());
        
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"Street":"123 Test Road","Rent":1356.95,"Date":"1/9/2017"}]');
        res.setStatusCode(200);
        return res;
    }

    }
I am new to salesforce SOQL and I seem to be having an issue when i try to use nested queries the query i am trying to perform is 

List<Space__c> sp = [Select Name, Suite__c, (Select Name from Location__c), (Select Name from RecordType where Name = 'Commercial') from Space__c];

and i keep getting this error 

Name, Suite__c, (Select Name from Location__c), (Select Name from
                                  ^
ERROR at Row:1:Column:42
Didn't understand relationship 'Location__c' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

even if i append __r instead of __c i still get the same issue any ideas will help i just need the names out of the 2 related objects
I have the task where I need to make all of the data export dynamic and automated I have the automation part all handled the issue Im running into is on the line
<entry key="sfdc.extractionSOQL" value="Select Id, name FROM Account"/>
I need this to cover all of the fields on the object and if a new field was added that day it will need to be added to the query and included..

basically I just need a way to change all my extraction queries to select * from account etc for each object and it will be done and working any ideas? does sfdc support the select * syntax or a variation?
Account la_test = new Account(Name='Test');
        insert la_test;
	Contact lcon_test = new Contact(LastName='Test', Accountid=la_Test.id, Email='test@test.com');
        insert lcon_test;
        location__C lloc_test = new Location__C(name = locName, site_wf__c = site);
        insert lloc_test;
        RecordType rec = [SELECT Id,Name FROM RecordType WHERE SobjectType='Case' and name = :record];
        Case lc_test = new Case(Subject='This is a test ', Accountid=la_Test.id, Status='New', RecordTypeId=rec.id, Contactid=lcon_test.id, Location__c= lloc_test.id,  Notify_contact__c = true); 
        //for trigger testing

        insert lc_test;
If I do a lookup query on the location id being passed into case its name value is populated but when I do lc_test.location__r.name it shows as null (location__c being a lookup field) does anyone know what im doing wrong?
Hi -

I'm trying to set the Corresponding_Sales_VP__c trigger to a specific user record by using their ID. How do i do it?
 
trigger Set_Corresponding_VP on Compensation_Request__c(after insert) {
	List<Compensation_Request__c> requestsToUpdate = new List<Compensation_Request__c>();
    for(Compensation_Request__c reqs : Trigger.new){
        reqs.Corresponding_Sales_VP__c = //User Record with id 005j000000FmuFu
            requestsToUpdate.add(reqs);
    }
    update requestsToUpdate;
}

 
I have  written a practice trigger Which populates the Description feild on Account object If the Industry = Banking. From the UI it works good. Also get 100 Test coverage. I feel the trigger is not firing from Test class because my System.debug are not logging the fields I need. I would be very thankful if anyone can point out my mistake. I would like to add my System.assertEquals are failing. Please help me learn


/*Trigger*/

trigger UpdateDescriptionOnAccount on Account (before insert) {
    list<Account> ActList=new list<Account>();
    for(Account a :Trigger.new)
    {
        if(a.Industry=='Banking' && a.Description == Null)
        {
            a.Description='This is a Banking Account';
            ActList.add(a);
        }
       
    }
    //insert ActList;

}

This is my test Class
/*Test Class*/

@isTest
public class TestUpdateDescriptionOnAccount {
    static testmethod void TestUpdate()
    {
       Account a = New Account(Name='Test Account 1',Industry='Banking');
       insert a;
      System.debug('Account Inserted '+a.Name + 'Description ='+a.Description +a.Industry);
       //system.assertEquals('This is a Banking Account',a.Description);
       
        
       Account b = New Account(Name='Test Account 2',Industry='Agriculture');
       insert b;
       //System.assertEquals(Null, b.Description);
        
       list<Account>testAccount = new List<Account>();
        for(integer i=0;i<200;i++)
        {
            Account c = new Account(Name='Account '+i, Industry='Banking');
            testAccount.add(c);
        }
        test.startTest();
        	insert testAccount;
        test.stopTest();
      for(Account d : TestAccount)
       {
            //system.assertEquals('This is a Banking Account',d.Description);
           System.debug('Account Inserted '+d.Name + 'Description ='+d.Description);
       }
        
    }

}


 
Hi All,

I am not a developer at all and tried to deploy a small apex class from Sandbox to Production and hit this error below. Any help and/or guidance is highly appreciated
Screenshot of Error

Thank You
  • April 12, 2017
  • Like
  • 0