• Rakesh Samal
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies
Visual force page::
<apex:page controller="TrainingDealClass" tabStyle="Training_Deal__c" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Training Deal List">
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!TrainingDetails}" var="item" id="Table">
                    <apex:column value="{!item.Course}" headerValue="Course" />
                    <apex:column value="{!item.Name}" headerValue=" Trainer First Name" />
                    <apex:column value="{!item.LastName}" headerValue="Trainer Last Name" />
                    <apex:column value="{!item.Education}" headerValue="Trainer Education" />
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:::
 
public class TrainingDealClass {
    public list<TrainingDetail> TrainingDetails {get;set;}
    
    public TrainingDealClass()
    {
        TrainingDetails = New list<TrainingDetail>();
        
        list<Training_Deal__c> listTrainingDeal = [SELECT Course__r.Course_Name__c,Trainer_Appointed__r.Name,Trainer_Appointed__r.Last_Name__c,Trainer_Appointed__r.Education__c FROM Training_Deal__c];
        
        for(Training_Deal__c varTrainingDeal:listTrainingDeal)
        {
            TrainingDetails.add(new TrainingDetail(varTrainingDeal));
        }
    }
    
    public class TrainingDetail
    {
        public string Name {get;set;}
        public string Course {get;set;}
        public string LastName {get;set;}
        public string Education {get;set;}
        
        public TrainingDetail(Training_Deal__c TrainingDeal)
        {
            this.Course = TrainingDeal.Course__r.Course_Name__c;
            this.Name = TrainingDeal.Trainer_Appointed__r.Name;
            this.LastName = TrainingDeal.Trainer_Appointed__r.Last_Name__c;
            this.Education = TrainingDeal.Trainer_Appointed__r.Education__c;
        }
    }
}
This is my apex class: Anyone pls help. I am new to test classes

public class StudentMasterClass {
    public static list<Student_Master__c> StudentMasterList {get;set;}
    
    public StudentMasterClass()
    {
        StudentMasterList = [SELECT Name,Last_Name__c,Company__c,City__c,Phone__c FROM Student_Master__c];
    }
}
I created a vfp "Vendor reg form".
Fields: Vendor Company Name(text),  Vendor Contact Person(text),
Amount per event(text). city(text),  country(text).
3 buttons:  Send Email, Rest,  Generate PDF
(on press of send email button, mail to CEO).

validation for above case:
1. Vendor name is mandatory
2. If amount is blank, he cannot click on "SEND EMAIL" button
3. Generate pdf not possible when "city" and "country" not mentioned.
4. use renderAS attribute to generate pdf. But onclick button.

Kindly help me anyone. Below is my code. I am stuck on send email and generate pdf.

visualforce page:
<apex:page controller="VendorRegistrationClass" >
    <script>
    
    function validate()
    {
         if(document.getElementById('{!$component.frm.vendorRegFrm.vendorDetails.vendorName}').value=='')  
            {
                alert('Vendor Name is Mandatory');
            }
    }
    
    </script>
    
    <apex:form id="frm">
        <apex:pageBlock title="Vendor Registration Form" id="vendorRegFrm">
            <apex:pageBlockSection columns="2" id="vendorDetails">
                <apex:outputLabel >Vendor Company Name:</apex:outputLabel>
                <apex:inputText value="{!VendorCompanyName}" id="vendorName"/>
                <apex:outputLabel >Vendor Contact Person:</apex:outputLabel>
                <apex:inputText value="{!VendorContactPerson}" id="vendorContact"/>
                <apex:outputLabel >Amount Per Event:</apex:outputLabel>
                <apex:inputText value="{!AmountPerEvent}" id="amount" onkeyup=""/>
                <apex:outputLabel >City:</apex:outputLabel>
                <apex:inputText value="{!City}" id="city"/>
                <apex:outputLabel >Country:</apex:outputLabel>
                <apex:inputText value="{!Country}" id="country"/>
                <apex:commandButton value="Send Email" action="{!SendEmail}" onclick="validate()" id="email" reRender="vendorName"/>
                <apex:commandButton value="Reset" action="{!Reset}"/> 
                <apex:commandButton value="Generate PDF" action="{!GeneratePDF}"/>
                <apex:outputLabel >{!message}</apex:outputLabel>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex class:
public class VendorRegistrationClass {
    public string VendorCompanyName {get;set;}
    public string VendorContactPerson {get;set;}
    public string AmountPerEvent {get;set;}
    public string City {get;set;}
    public string Country {get;set;}
    public boolean email {get;set;}
    public string message {get;set;}
    
    
    public PageReference Reset()
    {
        PageReference newpage = new PageReference(System.currentPageReference().getURL());
        newpage.getParameters().clear();
        newpage.setRedirect(true);
        return newpage;
    }
}




 
Custom object: Trainer_Master__c
picklist Field: Verification_status__c(details needed, verified, unverified)

how many trainers are found unverified? Then Send email to CEO in batch apex finish method. This all work should be on finish method batch class.

Please help me on this
I have two custom object. 
One is student_Master__c. Field is: Name,Pancard Number,Phone, Background Check Status.
and another is Black_Listed_candidate__c. Field is: Name, PAN, phone.

Condition: Whenever we are inserting record in student_Master__c it has to check "pancard number" in above database. If the "PAN number" is found in "Black_Listed_candidate__c" object, then show message in "Background Check Status" field that "candidate is blacklisted. we cannot hire!."
 And also as well as update "Phone" field in "Black_Listed_candidate__c" object record with new phone present in "student_Master__c" object record.

Please help me with this. I am trying but give error.

This is my code below:

Apex Class:

public class PancardCheckClass {
   @future 
    public static void updateBlackListPhone(Map<Id,string> idAndPhoneMap)
    {
        list<Black_Listed_Candidate__c> blackListedPans = [SELECT Name,PAN__c,Phone__c FROM Black_Listed_Candidate__c WHERE Id IN:idAndPhoneMap.KeySet()];
        for(Black_Listed_Candidate__c black :blackListedPans)
        {
            black.Phone__c = idAndPhoneMap.get(black.Id);
        }
        Update blackListedPans;
    }    
}

Trigger:

trigger PancardCheckClassTrigger on Student_Master__c (before insert) {
    
    list<Black_Listed_Candidate__c> blackList =[SELECT Name,PAN__c,Phone__c FROM Black_Listed_Candidate__c];
    system.debug('kdng' + blackList);
    list<Student_Master__c> newRecord = new list<Student_Master__c>();
    Map<Id,string> IdAndBlackListPhoneMap = New Map<Id,string>();
    
    for(Student_Master__c varStudent: trigger.new)
    {
        for(Black_Listed_Candidate__c varBlacklist:blackList)
        {
            if(varBlacklist.PAN__c==varStudent.Pan_Card_Number__c)
            {
                varBlacklist.Phone__c=varStudent.Phone__c;
                IdAndBlackListPhoneMap.put(varBlacklist.Id, varBlacklist.Phone__c);
                newRecord.add(varStudent);
            }
        }
        if(newRecord.size() > 0)
        {
            PancardCheckClass.updateBlackListPhone(IdAndBlackListPhoneMap);
            for(Student_Master__c newAppRecord : newRecord)
            {
                newAppRecord.Background_Check_Status__c='Candidate is Blacklisted! We cannot hire!';
            }
        }
    }
    User-added image
}
This is my apex class: Anyone pls help. I am new to test classes

public class StudentMasterClass {
    public static list<Student_Master__c> StudentMasterList {get;set;}
    
    public StudentMasterClass()
    {
        StudentMasterList = [SELECT Name,Last_Name__c,Company__c,City__c,Phone__c FROM Student_Master__c];
    }
}
Custom object: Trainer_Master__c
picklist Field: Verification_status__c(details needed, verified, unverified)

how many trainers are found unverified? Then Send email to CEO in batch apex finish method. This all work should be on finish method batch class.

Please help me on this
I have a Visualforce Page, with some input text fields. (There is NO standard or custom object associated with this Page). There is a button 'Generate PDF'. On click of this button, PDF needs to be generated having all the input text values.
How do we send the input text values to the PDF? (PDF is getting generated having only labels, no values) Please let me know!
  • October 25, 2021
  • Like
  • 0
Create a new Custom objects Application and BlackList
 Object Name                          Field Names
--------------------                           -----------------
  Application                               Name,Pancard ,Phone
  BlacKList                                  Name,Pancard,phone

a. When ever we are inserting new Application it has to check pancard no of the new application record is 
in the Blakc list or not .
b.If the pancard of the Appliction is in the blacklist object then update the blackList phone with new application phone no  and throw error


below code is throws error as per scenario but it not update the phone number in the object please help any one
trigger Application on Applications__c (before insert) {
    
    list<blacklist__c> balack=[select name,pancard__c,mobile_num__c from blacklist__c];
    list<blacklist__c> newre=new list<blacklist__c>();
    for(Applications__c c: trigger.new){
        for(blacklist__c bp:balack){
            if(bp.pancard__c==c.Pancard__c){
                bp.mobile_num__c=c.mobile_num__c;
                newre.add(bp);
                c.name.adderror('applicant is in blacklist');
            }
        }
        update newre;
    }
}

 
  • January 22, 2018
  • Like
  • 0