function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mathías del Valle SanchezMathías del Valle Sanchez 

need help with map in apex class

hi all,
i'm new with SF and apex, so i don't know how start

i am trying to create a apex class that can map or link the name of a custom object (eg. "test1__c") with the description of de Case Object

So, when the users clicks the name of the custom object, he can see the description of the Case.

I think it starts like this, but I don't know how to continue


Map<test__c,Case> Ticketmap=new Map<test__c,Case>([SELECT description FROM Case];
Best Answer chosen by Mathías del Valle Sanchez
Suraj Tripathi 47Suraj Tripathi 47

Hi Mathias,
find the below solution

public with sharing class testApex {
    public static void testApex() {
        List<test1__c> testList=[Select Id, Name, Description__c Form test1__c];
        Map<String , String> name_vs_Description = new Map<String , String>();
        for(test1__c test:testList){
            if(!name_vs_Description.containsKey(test.Name))
            {
                name_vs_Description.put(test.Name,test.Description__c);
            }
        }
        //now you can iterate this map using key.
        for(test1__c test:testList){
            System.debug('Name:'+test.Name+'===== Desciption:'+name_vs_Description.get(test.Name));
        }
    }
}

If you find this helpful mark it as the best answer

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

In order to achieve this,you would need to create the helptext on the field by overriding the page with the visualforce page.

Please refer the below sample code for the same.

https://salesforce.stackexchange.com/questions/65683/how-to-add-field-help-text-in-visualforce-page

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
ravi soniravi soni
hi Mathías,
try following method.
Map<Id,case> mapOfCase = new Map<Id,case>([Select Id,description From Case]);
for(string caseId : mapOfCase.keySet()){
    system.debug(mapOfCase.get(caseId).description);
}
let me know if it helps you and marking it as best.
Thank You
Suraj Tripathi 47Suraj Tripathi 47

Hi Mathias,
find the below solution

public with sharing class testApex {
    public static void testApex() {
        List<test1__c> testList=[Select Id, Name, Description__c Form test1__c];
        Map<String , String> name_vs_Description = new Map<String , String>();
        for(test1__c test:testList){
            if(!name_vs_Description.containsKey(test.Name))
            {
                name_vs_Description.put(test.Name,test.Description__c);
            }
        }
        //now you can iterate this map using key.
        for(test1__c test:testList){
            System.debug('Name:'+test.Name+'===== Desciption:'+name_vs_Description.get(test.Name));
        }
    }
}

If you find this helpful mark it as the best answer
This was selected as the best answer