• Hari nadh babu Eluru
  • NEWBIE
  • 200 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 16
    Replies
In this Trigger Apex,we have two custom sobjects Train__c and Passanger__c. At in Train__c there are two fields Passanger_Old_Phone_Number__c and Passanger_New_Phone_Number__c. At in Passanger__c there are one field Phone_Number__c. If the Phone number in Phone_Number__c was changed by Passanger in Passanger__c then old phone number  can be store in Passanger_Old_Phone_Number__c and new phone number can be store in Passanger_New_Phone_Number__c.
There are Lookup Relationship between Passanger__c to Train__c

We want functionality in Trigger Apex
Thank you !
 
Hi there !
In this Trigger Apex, Nullpoint Exception was getting
The code that i was did is as below
trigger SignIn_Trigger on Sign_In__c (after insert) {
    list<Sign_In__c> i = [select Current_Password__c, New_Password__c,Student__r.Email__c, Password__c, Username__c from Sign_In__c where id IN:trigger.newMap.keySet()];
    for(Sign_In__c s : i){
        if(s.Student__c != trigger.oldMap.get(s.Id).Student__c){
            system.debug('Name is'+ s.Student__c);
            String userEmail = s.Student__r.Email__c;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {userEmail};
            mail.setToAddresses(toAddresses);
            mail.setSubject('Your Password is updated' + ' So#- '+ s.New_Password__c);
            String body = 'Your Password is' + '-' + s.New_Password__c;
            mail.setPlainTextBody(body);
            Messaging.sendEmail(new Messaging.SingleEMailMessage[]{mail});
        }
    }
}
While i'm inserting record the error was getting the image is error as below
Nullpoint Exception error
Apex trigger SignIn_Trigger caused an unexpected exception, contact your administrator: SignIn_Trigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.SignIn_Trigger: line 4, column 1
Please resolve the issue and provide the solution for it. Thank you !
In this Trigger Apex, User wants to change password. Whenever user changed the password an password changed email can be send to user.

Below is the code that i was tried:-
trigger Change_Password on Sign_In__c (after insert) {
    for(Sign_In_c s : trigger.new){
        if(s.Current_Password__c != s.New_Password__c){
    
        }
    }
}

Please give me the code to what we can implement functionality
In this trigger apex, we can give Pincode__c text field. Pincode must be only 6 digits. If Pincode is exceeded 6 digits then we can show error message as "Pincode must be 6 digits"
I tried above code but not getting output:-
trigger Exact_Six_Digits on Customer__c (before insert) {
    for(Customer__c u : trigger.new){
        if(u.Pincode__c.length()!=6){
            u.Pincode__c.adderror('Pincode must be 6 digits');
        }
    }
}
Please give me suggestions for how to implement the condition. Thank you !
 
Hi there !
In this trigger apex code, The amount must be in between 0 to 5000 for Fee__c field
I tried above code
trigger Between_Values on Patient__c (before insert) {
    for(Patient__c a : trigger.new){
        if(a.Fee__c >= 0 || a.Fee__c <= 5000){
            a.Fee__c.adderror('Please enter amount b/w 0 to 5000');
        }
    }
}
Please give me the suggestions to implement the functionality condition
In this trigger apex, I want to give error when Fee_paid__c field must not be blank. We can throw the error as "Please enter amount"
I tried above code
trigger Not_Negative on Student__c (before insert) {
    for(Student__c x: trigger.new){
        if(x.Fee_paid__c < 0 && !(isblank(x.Fee_paid__c))){
            x.Fee_paid__c.adderror('Please enter amount');
        }
    }
}
The above image contains error message that i had getting error
errorPlease suggest me how to implement the condition. Thank you !
Hi there !
In this batch Apex code, I updated Mr. infront of the name if student is Male and Mrs. infront of the name if student is Female but at in output Mr. or Mrs. is getting multiple times. Please give me the suggestions to remove the multiple times of getting Mr. and Mrs. and get only once.
public class UpdateGender implements database.batchable<sobject> {
    
    public database.querylocator start(database.batchableContext abc){
        string a = 'SELECT Student_Id__c, Name, Gender__c FROM Student__c';
        return database.getquerylocator(a);
    }
    
    public void execute(database.batchableContext def, list<Student__c> x){
        for(Student__c a : x){
            if(a.Gender__c == 'Male'){
                a.Name = 'Mr.'+a.Name;
            }
            else if(a.Gender__c == 'Female'){
                a.Name = 'Mrs.'+a.Name;
            }
        }
        upsert x;
    }
    
    public void finish(database.batchableContext ghi){
        system.debug('Finish::!');
    }
}



The above image is multiple times getting Mr. and Mrs. in output 
Multiple times Mrs.
Multiple times Mr.
Hi there !
Write a batch apex to update the records in student custom sobject as if the student is male give the discount of 10% and if the student is female give the discount of 20%
Hi there,
In this visualforce page there are two inputs and one button name as swap. How the swap the values in given two inputs from input-1 to input-2. Please provide suggestions

I tried the above code
VF code:-
<apex:page controller="Swap_Values">
<apex:form >
<apex:outputLabel >Enter Value</apex:outputLabel>
<apex:inputText value="{!x}"/>
<apex:inputText value="{!y}"/>
<apex:commandButton value="Swap" action="{!SV}"/>
</apex:form>
</apex:page>
Apex code:-
public class Swap_Values {

    public String y { get; set; }

    public String x { get; set; }

    public PageReference SV() {
        x=y;
        y=x;
        return null;
    }

}


 
Hi all, I did this batch apex code.
public class UpdateGender {
    
    public database.querylocator start(database.batchableContext abc){
        string a = 'SELECT Student_Id__c, Name, Gender__c FROM Student__c';
        return database.getquerylocator(a);
    }
    
    public void execute(database.batchableContext def, list<Student__c> x){
        for(Student__c a : x){
            if(a.Gender__c == 'Male'){
                a.Name = 'Mr'+a.Name;
            }
            else if(a.Gender__c == 'Female'){
                a.Name = 'Mrs'+a.Name;
            }
        }
        update x;
    }
    
    public void finish(database.batchableContext ghi){
        system.debug('Finish::!');
    }
}
I wrote executed code in anonymous windows is as follows above
UpdateGender obj = new UpdateGender();
database.executeBatch(obj,10);
While i'm executing this batch in anonymous window they were showing error as below image
error
Please resolve my issue problem. Thank you to all
Hi all,
By using batch apex, write an apex class to update the records of custom sobject as like gender is male then we can add Mr infront of the name and gender is female then we can add Miss infront of the name.
Please provide code to me. Thank you !
Hi all,
At in batch apex coding, they want to update the records in Student__c custom sobject as like if student is male they can appear Mr infront of his name. If student is female they can appear Miss infront of her name

I tried this above code:
public class apex_student implements database.batchable<sobject>{
    integer count = 0;
    
    public database.querylocator start(database.batchableContext abc){
        string myacc = 'SELECT Student_Id__c, Name, Gender__c FROM Student__c';
        system.debug('start:::');
        return database.getquerylocator(myacc);
    }
    
    public void execute(database.batchableContext abc, list<Student__c> acc){
        count++;
        system.debug('Execute'+count);
            
        for(Student__c x:acc){
            if(x.Gender__c == 'Male'){
                x.Gender__c = 'Mr';
            }
            
            if(x.Gender__c == 'Female'){
                x.Gender__c = 'Miss';
                update x;
            }
        }
    }
    
    public void finish(database.batchableContext abc){
        system.debug('Finish:::');
    }
}
But records in sobject was not updated, Please resolve my problem. Thank You !
 
Hi all,
One picklist is there, it consists values of Pulsar, FZ, Glamour above three values had a three bike images.At in picklist we select pulsar then pulsar image can be show remaining images can be hide, if FZ is select from picklist then FZ iamge can be show and remaining images can be hide, if Glamour is selected from picklist then Glamour image can be show remaining images can be hide

The above is the code that i tried
VF Code
<apex:page controller="Picklist_Show_Hide_Img_Con">
<apex:form >
<apex:selectList id="Picklist_Show_Hide_Img_Con" value="{!w}" size="1">
<apex:actionSupport action="{!showhideimg}" event="onchange"/>
            <apex:selectOption itemValue="Pulsar" itemLabel="Pulsar"/>
            <apex:selectOption itemValue="FZ" itemLabel="FZ"/>
            <apex:selectOption itemValue="Glamour" itemLabel="Glamour"/>
</apex:selectList> <br />
<apex:image value="{!$Resource.Pulsar}" rendered="{!x}" width="200" height="200"/>
<apex:image value="{!$Resource.FZ}" rendered="{!y}" width="200" height="200"/>
<apex:image value="{!$Resource.Glamour}" rendered="{!z}" width="200" height="200"/>
</apex:form>
</apex:page>
Apex Code
public class Picklist_Show_Hide_Img_Con {

    public Boolean z { get; set; }

    public Boolean y { get; set; }

    public Boolean x { get; set; }
    
    public Picklist_Show_Hide_Img_Con() {
        x = true;
        y = true;
        z = true;
    }
    
    public PageReference showhideimg() {
        if(w==x){
            x = true;
            y = false;
            z = false;
        }
        
        if(w==y){
            x = false;
            y = true;
            z = false;
        }
        
        if(w==z){
            x = false;
            y = false;
            z = true;
        }
        return null;
    }


    public String w { get; set; }
}
Please rectify my problem. Thank you very much !

 
VF Code
<apex:page controller="Details_Saved_DB">
<apex:form >
<apex:outputLabel >Enter Name</apex:outputLabel>
<apex:inputText value="{!x}"/>
<apex:outputLabel >Enter Phone</apex:outputLabel>
<apex:inputText value="{!y}"/>
<apex:commandButton value="Save" action="{!InvokeMe}"/>
</apex:form>
</apex:page>
How to put error message tag in input text field above visual force code. Please provide. Thank you !
how to delete saved record in sobject
how to see standard sobject created records. Please explain step by step

page1-->save the record and redirect to second page and show the record details which you have saved.Now specify a button in page2 to delete the record.after deleting record you can move to another page where you can show all records in a table

Error msg when num1 is -ve

 
page1-->save the record and redirect to second page and show the record details which you have saved.
Vf code page 1
<apex:page controller="age">
<apex:form >
<apex:outputLabel >Enter Min Age</apex:outputLabel>
<apex:inputText value="{!p}"/>
<apex:commandButton value="Click me" action="{!ageBut}"/>
</apex:form>
</apex:page>

Apex code Page 1
public class age {

    public PageReference ageBut() {
        PageReference pr = new PageReference ('https://93com4-dev-ed--c.visualforce.com/apex/Max_Age?abc='+p);
        return pr;
    }
    public String p { get; set; }
}

Vf code page 2
<apex:page controller="Max_Age">
<apex:form >
    {!z.name}
    {!z.Age__c}
</apex:form>
</apex:page>

Apex code page 2
public class Max_Age {

    public Student__c z { set; get; }
    
    public Max_Age(){
        string k = ApexPages.currentPage().getParameters().get('abc');
        
     z = [SELECT Name, Student_Id__c, Age__c FROM Student__c WHERE Student_Id__c=:k];
    }
}

The above image was getting error in codes
Error

if user enter min age, max age . fetch all the students in btwn that min and max age

in above example try to load students in ascending order based on age

result can be shown in another page when clicked search button
Hi there !
In this Trigger Apex, Nullpoint Exception was getting
The code that i was did is as below
trigger SignIn_Trigger on Sign_In__c (after insert) {
    list<Sign_In__c> i = [select Current_Password__c, New_Password__c,Student__r.Email__c, Password__c, Username__c from Sign_In__c where id IN:trigger.newMap.keySet()];
    for(Sign_In__c s : i){
        if(s.Student__c != trigger.oldMap.get(s.Id).Student__c){
            system.debug('Name is'+ s.Student__c);
            String userEmail = s.Student__r.Email__c;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {userEmail};
            mail.setToAddresses(toAddresses);
            mail.setSubject('Your Password is updated' + ' So#- '+ s.New_Password__c);
            String body = 'Your Password is' + '-' + s.New_Password__c;
            mail.setPlainTextBody(body);
            Messaging.sendEmail(new Messaging.SingleEMailMessage[]{mail});
        }
    }
}
While i'm inserting record the error was getting the image is error as below
Nullpoint Exception error
Apex trigger SignIn_Trigger caused an unexpected exception, contact your administrator: SignIn_Trigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.SignIn_Trigger: line 4, column 1
Please resolve the issue and provide the solution for it. Thank you !
In this Trigger Apex, User wants to change password. Whenever user changed the password an password changed email can be send to user.

Below is the code that i was tried:-
trigger Change_Password on Sign_In__c (after insert) {
    for(Sign_In_c s : trigger.new){
        if(s.Current_Password__c != s.New_Password__c){
    
        }
    }
}

Please give me the code to what we can implement functionality
In this trigger apex, we can give Pincode__c text field. Pincode must be only 6 digits. If Pincode is exceeded 6 digits then we can show error message as "Pincode must be 6 digits"
I tried above code but not getting output:-
trigger Exact_Six_Digits on Customer__c (before insert) {
    for(Customer__c u : trigger.new){
        if(u.Pincode__c.length()!=6){
            u.Pincode__c.adderror('Pincode must be 6 digits');
        }
    }
}
Please give me suggestions for how to implement the condition. Thank you !
 
Hi there !
In this trigger apex code, The amount must be in between 0 to 5000 for Fee__c field
I tried above code
trigger Between_Values on Patient__c (before insert) {
    for(Patient__c a : trigger.new){
        if(a.Fee__c >= 0 || a.Fee__c <= 5000){
            a.Fee__c.adderror('Please enter amount b/w 0 to 5000');
        }
    }
}
Please give me the suggestions to implement the functionality condition
In this trigger apex, I want to give error when Fee_paid__c field must not be blank. We can throw the error as "Please enter amount"
I tried above code
trigger Not_Negative on Student__c (before insert) {
    for(Student__c x: trigger.new){
        if(x.Fee_paid__c < 0 && !(isblank(x.Fee_paid__c))){
            x.Fee_paid__c.adderror('Please enter amount');
        }
    }
}
The above image contains error message that i had getting error
errorPlease suggest me how to implement the condition. Thank you !
Hi there !
In this batch Apex code, I updated Mr. infront of the name if student is Male and Mrs. infront of the name if student is Female but at in output Mr. or Mrs. is getting multiple times. Please give me the suggestions to remove the multiple times of getting Mr. and Mrs. and get only once.
public class UpdateGender implements database.batchable<sobject> {
    
    public database.querylocator start(database.batchableContext abc){
        string a = 'SELECT Student_Id__c, Name, Gender__c FROM Student__c';
        return database.getquerylocator(a);
    }
    
    public void execute(database.batchableContext def, list<Student__c> x){
        for(Student__c a : x){
            if(a.Gender__c == 'Male'){
                a.Name = 'Mr.'+a.Name;
            }
            else if(a.Gender__c == 'Female'){
                a.Name = 'Mrs.'+a.Name;
            }
        }
        upsert x;
    }
    
    public void finish(database.batchableContext ghi){
        system.debug('Finish::!');
    }
}



The above image is multiple times getting Mr. and Mrs. in output 
Multiple times Mrs.
Multiple times Mr.
Hi there !
Write a batch apex to update the records in student custom sobject as if the student is male give the discount of 10% and if the student is female give the discount of 20%
Hi there,
In this visualforce page there are two inputs and one button name as swap. How the swap the values in given two inputs from input-1 to input-2. Please provide suggestions

I tried the above code
VF code:-
<apex:page controller="Swap_Values">
<apex:form >
<apex:outputLabel >Enter Value</apex:outputLabel>
<apex:inputText value="{!x}"/>
<apex:inputText value="{!y}"/>
<apex:commandButton value="Swap" action="{!SV}"/>
</apex:form>
</apex:page>
Apex code:-
public class Swap_Values {

    public String y { get; set; }

    public String x { get; set; }

    public PageReference SV() {
        x=y;
        y=x;
        return null;
    }

}


 
Hi all, I did this batch apex code.
public class UpdateGender {
    
    public database.querylocator start(database.batchableContext abc){
        string a = 'SELECT Student_Id__c, Name, Gender__c FROM Student__c';
        return database.getquerylocator(a);
    }
    
    public void execute(database.batchableContext def, list<Student__c> x){
        for(Student__c a : x){
            if(a.Gender__c == 'Male'){
                a.Name = 'Mr'+a.Name;
            }
            else if(a.Gender__c == 'Female'){
                a.Name = 'Mrs'+a.Name;
            }
        }
        update x;
    }
    
    public void finish(database.batchableContext ghi){
        system.debug('Finish::!');
    }
}
I wrote executed code in anonymous windows is as follows above
UpdateGender obj = new UpdateGender();
database.executeBatch(obj,10);
While i'm executing this batch in anonymous window they were showing error as below image
error
Please resolve my issue problem. Thank you to all
Hi all,
By using batch apex, write an apex class to update the records of custom sobject as like gender is male then we can add Mr infront of the name and gender is female then we can add Miss infront of the name.
Please provide code to me. Thank you !
Hi all,
One picklist is there, it consists values of Pulsar, FZ, Glamour above three values had a three bike images.At in picklist we select pulsar then pulsar image can be show remaining images can be hide, if FZ is select from picklist then FZ iamge can be show and remaining images can be hide, if Glamour is selected from picklist then Glamour image can be show remaining images can be hide

The above is the code that i tried
VF Code
<apex:page controller="Picklist_Show_Hide_Img_Con">
<apex:form >
<apex:selectList id="Picklist_Show_Hide_Img_Con" value="{!w}" size="1">
<apex:actionSupport action="{!showhideimg}" event="onchange"/>
            <apex:selectOption itemValue="Pulsar" itemLabel="Pulsar"/>
            <apex:selectOption itemValue="FZ" itemLabel="FZ"/>
            <apex:selectOption itemValue="Glamour" itemLabel="Glamour"/>
</apex:selectList> <br />
<apex:image value="{!$Resource.Pulsar}" rendered="{!x}" width="200" height="200"/>
<apex:image value="{!$Resource.FZ}" rendered="{!y}" width="200" height="200"/>
<apex:image value="{!$Resource.Glamour}" rendered="{!z}" width="200" height="200"/>
</apex:form>
</apex:page>
Apex Code
public class Picklist_Show_Hide_Img_Con {

    public Boolean z { get; set; }

    public Boolean y { get; set; }

    public Boolean x { get; set; }
    
    public Picklist_Show_Hide_Img_Con() {
        x = true;
        y = true;
        z = true;
    }
    
    public PageReference showhideimg() {
        if(w==x){
            x = true;
            y = false;
            z = false;
        }
        
        if(w==y){
            x = false;
            y = true;
            z = false;
        }
        
        if(w==z){
            x = false;
            y = false;
            z = true;
        }
        return null;
    }


    public String w { get; set; }
}
Please rectify my problem. Thank you very much !

 
VF Code
<apex:page controller="Details_Saved_DB">
<apex:form >
<apex:outputLabel >Enter Name</apex:outputLabel>
<apex:inputText value="{!x}"/>
<apex:outputLabel >Enter Phone</apex:outputLabel>
<apex:inputText value="{!y}"/>
<apex:commandButton value="Save" action="{!InvokeMe}"/>
</apex:form>
</apex:page>
How to put error message tag in input text field above visual force code. Please provide. Thank you !
how to see standard sobject created records. Please explain step by step

page1-->save the record and redirect to second page and show the record details which you have saved.Now specify a button in page2 to delete the record.after deleting record you can move to another page where you can show all records in a table

Error msg when num1 is -ve

 
page1-->save the record and redirect to second page and show the record details which you have saved.
Take a string type of variable
string pincode = '500038';
  • Pincode must be exactly 6 digits, if the no of digits not equal to 6 then print "Pincode must be 6 digits"
  • Pincode must be numeric only, if user enters alphabets then show error message "Pincode must be numeric only" 
This functionality must be implement only in if condition