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
sfdc-Lsfdc-L 

how to fetch custom object field in apex class

HI all, i have scenario like,1 custom object and 2 custom fields i.e. username_c and password__c so i am storing the password in custom object. so what i want is ,whatever storing the password in custom object that wants to be return by using apex class.i was tring to return but i am not getting so pls relsove this issue.but i am not using any vf page. public with sharing class Sample { public static string registerUser() { List obj = new List(); obj = [Select Username__c,Password__c from Login__c where Username__c =:id Limit 1]; return password__c; } THnaks
Best Answer chosen by Admin (Salesforce Developers) 
SFDC_LearnerSFDC_Learner

do you want to send the username and password to the class once you have saved.

 

If it is your requirement, then

 

-> Write a trigger either in before insert or after insert event.

-> call a class with in the trigger and pass the values to the class from the trigger.

 

 

If it is not your requirement, please let me know the correct requirement.

All Answers

SFDC_LearnerSFDC_Learner

do you want to send the username and password to the class once you have saved.

 

If it is your requirement, then

 

-> Write a trigger either in before insert or after insert event.

-> call a class with in the trigger and pass the values to the class from the trigger.

 

 

If it is not your requirement, please let me know the correct requirement.

This was selected as the best answer
sfdc-Lsfdc-L
thanks correct,i was trying execute but its not working so pls make changes and reply to me asap // public with sharing class Sample { public static string registerUser() { List obj = new List(); obj = [Select Username__c,Password__c from Login__c where Username__c =:id Limit 1]; return password__c; } \\ trigger test on Longin__c(after insert) { sample sm=new Sample(); sm.registerUser(); } THanks alot