• sgss
  • NEWBIE
  • 105 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 32
    Replies
Can anyone help in Test Class of following problem.? Consider all positive negative scenario.

 SOQL query on Account and find all associated contact records of the Account which
contains the word 'John'. Print all Account and Contact records retrieved above

public class JohnClass {
    public static void getAccountContact(){
    List<Account> accountList = [SELECT 
                                                                        Id,
                                                                            Name, 
                                (SELECT 
                                                                        Id, 
                                                                            FirstName, 
                                                                                LastName
                                FROM 
                                                                    Contacts 
                                WHERE 
                                                                    FirstName LIKE '%john%' OR LastName LIKE '%john%') 
                                FROM 
                                                                    Account];
    
    for(Account account : accountList) {
        if(account.Contacts.isEmpty()) 
            continue;
            system.debug('Account : ' + account.Name);
        
        for(Contact contact : account.Contacts) {
            system.debug('Contact : ' + contact.FirstName + ' ' + contact.LastName);
        }
    }    
}
}
  • July 25, 2018
  • Like
  • 0
write a soql query to display 100 opportunity record with amount greater than 10000 order by created date.Skip first 50 record and include record from recycle bin

//////Test class required for following code .Can anyone help in this considering all positive negative scenario


public class OpportunityClass {
    public static list<Opportunity> toQueryOnOpportunity(){
        list<Opportunity> listOpportunity = new List<Opportunity>([
                                                                    SELECT 
                                                                                            Id,
                                                                                                Name
                                                                    FROM 
                                                                                            Opportunity 
                                                                    WHERE 
                                                                                            amount>10000
                                                                    ORDER BY 
                                                                                            CreatedDate ASC
                                                                        LIMIT 
                                                                                            100 
                                                                    OFFSET 
                                                                                            12
                                                                        ALL ROWS
                                                                        ]
                                                                    );
        System.debug(listOpportunity);
        return listOpportunity;
    }    
}
  • July 25, 2018
  • Like
  • 0
SOQL query to find all account records where billing state is not tokyo and california. Order the result by billing state in descending order with null value at the end.Display first 1000 record only

///Can anyone provide Test Class for following code?

public with sharing class BillingStateClass {
    public void checkBillingState(){
        List<Account> listAccount = [SELECT 
                                        Id,
                                            Name 
                                    FROM 
                                        Account
                                    WHERE 
                                        Account.BillingState 
                                    NOT IN 
                                        ('tokyo','california') 
                                    ORDER BY 
                                        Account.BillingState DESC
                                    NULLS 
                                        LAST 
                                    LIMIT 
                                        10000];
        System.debug(listAccount);
    }    
}
  • July 25, 2018
  • Like
  • 0
Problem:
Match the contact email field of newly created contact to the website field of ACCOUNT  and assign that contact to account using trigger.

////Can anyone provide test class considering all the cases positive negative bulk for this trigger.

-------Trigger------
trigger assign contact on Contact(before insert, before update){
  assignContact.triggerClass(Trigger.New);
}

--------related class-------------
public class assignContact {
    
    public static void triggerClass(List<Contact> ContactList) {
        Map<String, List<Contact>> domainVsContactMap = new Map<String, List<Contact>>();
        
        for(Contact c: ContactList) {
            if(c.Email != null) {
                List<String> domainsplit=c.email.split('@',2);
                String domain=domainsplit[1];
                                system.debug('Domain---->>>: '+domain);

                if(domainVsContactMap.containsKey(domain)) {
                    List<Contact>temp=domainVsContactMap.get(domain);
                    
                    temp.add(c);
                    domainVsContactMap.put(domain, temp);
                }
                else {
                    domainVsContactMap.put(domain, new List<Contact>{c});
                }
            }    
        }
        
        if(!domainVsContactMap.isEmpty()) {
            system.debug('Not Empty');
            List<Account> accList=new List<Account>();
            accList=[SELECT Id, Website FROM Account WHERE Website In:domainVsContactMap.keySet()];
            system.debug('accList'+accList);
            for(Account acc : accList) {
                system.debug('Account: '+acc);
                List<Contact>conList=new List<Contact>();
                conlist=domainVsContactMap.get(acc.Website);
                for(Contact c : conList) {
                                    system.debug('Contact: '+ c);

                    c.AccountId = acc.Id;
                }
            }
        }
    }
}

 
  • July 25, 2018
  • Like
  • 0
User-added image

Can anyone help me with workflow rule of following questions?
  • July 23, 2018
  • Like
  • 0
I want to write trigger for folloeing use case
Match the contact email field of newly created contact to the website field of ACCOUNT  and assign that contact to account using trigger.
  • July 23, 2018
  • Like
  • 0
User-added image

What steps should i follow and how to solve this Can anyone help?
  • July 22, 2018
  • Like
  • 0


I need to Use TRigger for above Question also need Test Class for it. I have created custom object mentioned above. Can anyone help me in Trigger ANd Test Class ? Its urgent. 


Thanks in advance.User-added image
  • July 22, 2018
  • Like
  • 0
Prepare the following map structures :
 
 Code:
 /** a. Account Name as key and AccountId as value.*/
 public class AccountMapClass {
  public static Map<String,String> accountMap(){
        Map<String,String> mapAccount = new Map<String,String>();
        for (Account acc :[SELECT Name,Id
                          FROM Account])
        {
            mapAccount.put(acc.Name,acc.Id);
        }
        System.debug(mapAccount);
        return mapAccount;
    }
    
  /*b. Account Id as key and entire Account object as value*/      
    public static Map<String, Account> accountMapNew(){
        Map<String, Account> mapAccount = new Map<String, Account>();
        for(Account accountObject  : [SELECT Id,Name,BillingAddress 
                                     FROM Account])
        {
            mapAccount.put(accountObject.Id, accountObject);
        }
        System.debug(mapAccount);
        return mapAccount;
    }    
}

Can anyone help in Test Class for following code. Considering positive and negative test Cases for both methods.
  • July 22, 2018
  • Like
  • 0
 Need COde for Following SOQL along with Test Cases

Need SOQL and Test Class for each Question. Any Help will be appreciated.
Thanks
  • July 21, 2018
  • Like
  • 0
//////Can anyone help me out for the Test Class of following Code, If any modification is needed to simplify Test Class you can provide in the code.
Cover all positive negative Bulk Testing if possible

////Description: Use of map and its methods

public class MapClass {
public void createMap(){
    /**
    1. Create Map and Enter Key value using : Map.put(key,value)
    2. The map elements of mapString2 are copied from mapString

        Account account1 = new Account(Name='marry',BillingCity='Las Vegas');
        Account account2 = new Account(Name='John',BillingCity='Sydney'); 
        Map<Integer, Account> mapAccount = new Map<Integer, Account> {};

        mapAccount.put(1, account1);
        mapAccount.put(2,account2);
        System.debug('Map mapAccount contains: '+mapAccount);

    /**
     Create Map and get value using : Map.get(Key)
     */
        Map<Integer, Account> mapAccount2 = mapAccount.clone();
        mapAccount.get(1).BillingCity ='Las Vegas';
        System.assertEquals('Las Vegas',mapAccount2.get(1).BillingCity);

    /**
    Map.containskey(key) : To check if map contains particular Key
     */
        Boolean contains = mapAccount.containsKey(3);  
        System.debug('containskey result'+contains);

    /**
    keyset : Returns a set that contains all of the keys in the map.
     */
        Set <Integer> keysetInt = new Set<Integer>();  
        keysetInt = mapAccount.keySet();

    /**
     Map.size() : Function to get Number of Element in Map
      */
        Integer mapSize = mapAccount.size(); 
        System.debug('Size of Map is'+mapSize);

    /**
    Map.value() : To get All value is Map
     */
        List<Account> accountList = new List<Account>(); 
        accountList = mapAccount.values();
        System.debug('Value in Account List : '+accountList);

    /**
    Map.remove(key) : Remove Value at that key
     */
    mapAccount.remove(1);   
    System.debug('Map mapAccount after remove: '+mapAccount);
}

}
  • July 21, 2018
  • Like
  • 0
Description: Class to insert Account record.
****************************************************************************************/
public class InsertAccountRecord {
    /**
    Function- insertRecord
    @param - Number of Record to be inserted
    **/
    public void insertRecord(Integer numberOfRecord )
    {
    List<Account> listAccount = new List<Account>();
    Account accountObject;
    
        for(Integer i=0;i<=numberOfRecord;i++){
        accountObject = new Account(name='Account'+i);
        listAccount.add(accountObject);
        }
    insert listAccount;
    }
}
  • July 21, 2018
  • Like
  • 0
Test Class is needed for following code

​---------------------------------------------------------------------------------------
Description: Account Record with Name =”Joe”. Create associated
contacts.
****************************************************************************************/
public class AssosciatedClass {
public static void addRecord(){
try {
    Account accountRecord = new Account(Name='Joe');
    insert accountRecord;
    ID acctID = accountRecord.ID;                        //Get Id of the new Record

    Contact contactRecord = new Contact(              // Add a contact to this account.
        FirstName='Joe',
        LastName='Smith',
        AccountId=acctID);
        
    insert contactRecord;
}
 catch(DmlException e) {
    System.debug('An unexpected error has occurred: ' + e.getMessage());
}
}
}
  • July 21, 2018
  • Like
  • 0
Can anyone provide code and Tes Class for this?

 Prepare the following map structures :
a. Account Name as key and AccountId as value.
b. Account Id as key and entire Account object as value.
  • July 21, 2018
  • Like
  • 0
Anyy help in this will be appreciated.

Write a Trigger on Account which will create the clone record. (Hint : Map trigger.new to clone record)
  • July 21, 2018
  • Like
  • 0
Can anyone help me in the following questions along with each questions test cases?

1. Query on all Contact records and add them to the List. Print that contents of this list.
2. Write a SOQL query to retrieve/print all active Users. Prepare a Map having User Id as key and User record as value. (Hint : Map)
3. Prepare the following map structures : a. Account Name as key and AccountId as value. b. Account Id as key and entire Account object as value.
4. Create a multi-select picklist on Account object called as 'Enrollment Year' with values - 2010, 2011, 2012, 2013, 2014, 2015 and 2016.
Get all account records where in selected 'Enrollment Year' is:
a. 2010
b. 2013 and 2014
5. Write a SOQL query to find all Account records where 'Billing State' is not 'Maharashtra' and 'Kerala'. Order the results by Billing State in descending order with null values at the end. Display first 10,000 records only. NOTE: do not use AND operator.
​6. Write a SOQL query to display 100 opportunity records with amount greater than 10,000 order by created date. Skip first 50 records and include records from recycle bin.
Thanks
  • July 21, 2018
  • Like
  • 0
Can any one help in this? I am new in Trigger. and need a code that cover all the conditions.
System.debug the following statements for any object a)Trigger.New b) Trigger.Old c)Trigger.NewMap d)Trigger.oldMap
  • July 21, 2018
  • Like
  • 0
Can anyone help me in test class of following code.??
To retrieve record of contact object.

public with sharing class ContactRecords {
    /**
    Method : getContactRecord() 
    Description : To fetch Id,Name,Department from Contact Object
    */
    public List<Contact> getContactRecord(){
        List<Contact> contactList = [SELECT Id,Name,Department
                                    FROM Contact];
        System.debug(contactList);
        return contactList;
    }
}

//Cover as many test cases as possible.
Thanks 
  • July 21, 2018
  • Like
  • 0
Clustering of Leads - Clustering of Fresh Lead provides the segregation of lead records based on certain inputs which would places the records in one of the cluster i.e. NO NUMBER, DNC,
MOBILE and LANDLINE. The User can view the Lead records and can also find on which Cluster the Lead record exists. Four Record types would be created in Lead i.e. NO NUMBER, DNC, MOBILE and LANDLINE which would be updated from Work Flow based on which cluster Lead is falling.

How to do this using Workflow? I have created 4 record type of DNC, NONUMBER,MOBILE and Landline. What next?
  • July 21, 2018
  • Like
  • 0
Big Deal Alert : -
If your opportunity stage is in 'negotiation/review' stage, send an email to the opportunity owner indicating a big deal is being created. Big deal amount should be greater than 50k. Create email template also.

I dont want to execute this using workflow. I want using big deal alert property. Can anyone help?
  • July 21, 2018
  • Like
  • 0
SOQL query to find all account records where billing state is not tokyo and california. Order the result by billing state in descending order with null value at the end.Display first 1000 record only

///Can anyone provide Test Class for following code?

public with sharing class BillingStateClass {
    public void checkBillingState(){
        List<Account> listAccount = [SELECT 
                                        Id,
                                            Name 
                                    FROM 
                                        Account
                                    WHERE 
                                        Account.BillingState 
                                    NOT IN 
                                        ('tokyo','california') 
                                    ORDER BY 
                                        Account.BillingState DESC
                                    NULLS 
                                        LAST 
                                    LIMIT 
                                        10000];
        System.debug(listAccount);
    }    
}
  • July 25, 2018
  • Like
  • 0
Problem:
Match the contact email field of newly created contact to the website field of ACCOUNT  and assign that contact to account using trigger.

////Can anyone provide test class considering all the cases positive negative bulk for this trigger.

-------Trigger------
trigger assign contact on Contact(before insert, before update){
  assignContact.triggerClass(Trigger.New);
}

--------related class-------------
public class assignContact {
    
    public static void triggerClass(List<Contact> ContactList) {
        Map<String, List<Contact>> domainVsContactMap = new Map<String, List<Contact>>();
        
        for(Contact c: ContactList) {
            if(c.Email != null) {
                List<String> domainsplit=c.email.split('@',2);
                String domain=domainsplit[1];
                                system.debug('Domain---->>>: '+domain);

                if(domainVsContactMap.containsKey(domain)) {
                    List<Contact>temp=domainVsContactMap.get(domain);
                    
                    temp.add(c);
                    domainVsContactMap.put(domain, temp);
                }
                else {
                    domainVsContactMap.put(domain, new List<Contact>{c});
                }
            }    
        }
        
        if(!domainVsContactMap.isEmpty()) {
            system.debug('Not Empty');
            List<Account> accList=new List<Account>();
            accList=[SELECT Id, Website FROM Account WHERE Website In:domainVsContactMap.keySet()];
            system.debug('accList'+accList);
            for(Account acc : accList) {
                system.debug('Account: '+acc);
                List<Contact>conList=new List<Contact>();
                conlist=domainVsContactMap.get(acc.Website);
                for(Contact c : conList) {
                                    system.debug('Contact: '+ c);

                    c.AccountId = acc.Id;
                }
            }
        }
    }
}

 
  • July 25, 2018
  • Like
  • 0
I want to write trigger for folloeing use case
Match the contact email field of newly created contact to the website field of ACCOUNT  and assign that contact to account using trigger.
  • July 23, 2018
  • Like
  • 0
User-added image

What steps should i follow and how to solve this Can anyone help?
  • July 22, 2018
  • Like
  • 0
Prepare the following map structures :
 
 Code:
 /** a. Account Name as key and AccountId as value.*/
 public class AccountMapClass {
  public static Map<String,String> accountMap(){
        Map<String,String> mapAccount = new Map<String,String>();
        for (Account acc :[SELECT Name,Id
                          FROM Account])
        {
            mapAccount.put(acc.Name,acc.Id);
        }
        System.debug(mapAccount);
        return mapAccount;
    }
    
  /*b. Account Id as key and entire Account object as value*/      
    public static Map<String, Account> accountMapNew(){
        Map<String, Account> mapAccount = new Map<String, Account>();
        for(Account accountObject  : [SELECT Id,Name,BillingAddress 
                                     FROM Account])
        {
            mapAccount.put(accountObject.Id, accountObject);
        }
        System.debug(mapAccount);
        return mapAccount;
    }    
}

Can anyone help in Test Class for following code. Considering positive and negative test Cases for both methods.
  • July 22, 2018
  • Like
  • 0
 Need COde for Following SOQL along with Test Cases

Need SOQL and Test Class for each Question. Any Help will be appreciated.
Thanks
  • July 21, 2018
  • Like
  • 0
Anyy help in this will be appreciated.

Write a Trigger on Account which will create the clone record. (Hint : Map trigger.new to clone record)
  • July 21, 2018
  • Like
  • 0
Can anyone help me in the following questions along with each questions test cases?

1. Query on all Contact records and add them to the List. Print that contents of this list.
2. Write a SOQL query to retrieve/print all active Users. Prepare a Map having User Id as key and User record as value. (Hint : Map)
3. Prepare the following map structures : a. Account Name as key and AccountId as value. b. Account Id as key and entire Account object as value.
4. Create a multi-select picklist on Account object called as 'Enrollment Year' with values - 2010, 2011, 2012, 2013, 2014, 2015 and 2016.
Get all account records where in selected 'Enrollment Year' is:
a. 2010
b. 2013 and 2014
5. Write a SOQL query to find all Account records where 'Billing State' is not 'Maharashtra' and 'Kerala'. Order the results by Billing State in descending order with null values at the end. Display first 10,000 records only. NOTE: do not use AND operator.
​6. Write a SOQL query to display 100 opportunity records with amount greater than 10,000 order by created date. Skip first 50 records and include records from recycle bin.
Thanks
  • July 21, 2018
  • Like
  • 0
Can any one help in this? I am new in Trigger. and need a code that cover all the conditions.
System.debug the following statements for any object a)Trigger.New b) Trigger.Old c)Trigger.NewMap d)Trigger.oldMap
  • July 21, 2018
  • Like
  • 0
Can anyone help me with this?

Create a custom object 'A', 'B' and 'C'. Establish 'Master Detail' relationship between them such that
'C' is junction object.
SOQL query on 'C'(created above) to retrieve all records of 'C' with name 'John' along with parent details.
 
  • July 20, 2018
  • Like
  • 0
Can anyone help with the code for
Write a SOQL query to find total number of Lead records by status by Lead Source. Store this information in map and display the same. (Hint: map<string,map<string,integer>>)
  • July 20, 2018
  • Like
  • 0
Hi all,

Here is my code though its not showing any error but I am certain there is someting wrong with it. As it is not fulfilling the requirement.
Please help me rectifying it. and let me know where I am goung wrong.

public class Move_Contact {
    public static void updateContact(List <Contact> conList){
        String MainDomain = '';
        string website ='www' +MainDomain;
                string httpWebsite ='http://www' + MainDomain;
                string httpswebsite ='https://www'+ MainDomain;
                string international = MainDomain + '.%';
        for(Contact myCon : conList){
            if(myCon.Email != null){
                string domain = myCon.Email.split('@').get(1);
                MainDomain = domain;
            }}
                Map <Id,Id> conMap = new Map <Id,Id>();
        for(Contact myCon : conList){
            conMap.put(myCon.Id , mycon.AccountId);
        }
        
                List<Account> acc = [SELECT Id
                                     FROM Account 
                                     WHERE Website =:website
                                     or Website =:httpWebsite
                                     or Website =:httpswebsite
                                     or Website =:international];
                if(acc.size() == 1){
                    For(Contact c : conList){
                        acc.get(0).Id = conMap.get(c.Id);
                        c.AccountId = conMap.get(c.Id);
                    }
                }     
    }

}
HI ,

I need to delete the post in the community , could anyone help me.

this is the link

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BVjIIAW

Thanks in advance
hi all,

I urgently need to edit/delete a post made by me on this discussion forum...But its not allowing me to do so and pops up
saying that 'you cant delete this question as others are interested in it'.
There are no likes and no comments on it still i am unable  to delete it
Any help would be highly appreciated

Its very urgent,
Thanks,