• uu
  • NEWBIE
  • 65 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 13
    Replies
Hii Developers,
Please help to write test class for this part of code.
code
Income_Tax__c ITax=[select id,Rent_paid_to_landlord__c,Leave_travel_concessions_or_assistance__c,Employees_PF__c,
                            Interest_payable_paid_to_lender__c,Children_s_Education_Fee__c,PPF__c,Insurance_Premium__c,
                            NSC__c,Deduction_under_Pension_scheme__c,Housing_loan_principal_repayment__c,ELSS_Mutual_Fund__c,
                            NPS__c,Payment_for_Medical_Insurance_Premium__c,Medical_treatment_for_handicapped__c,
                            Medical_for_specified_diseases__c,Education_Loan_Interest_Repayment__c,Interest_on_loan_taken_for_house__c,
                            Donation__c,Rent_deduction_only_if_HRA_not_received__c,Saving_interest__c,Rebate_of_Rs_2000__c,RGESS__c,
                            Royalty__c,Professional_Development_Allowance__c,Car_Maintenance_Allowance__c,
                            Conveyance_Allowance__c,Helper_Allowance__c,Telephone_Internet_allowance__c,
                            Tax_by_previous_employer__c,TDS_already_deducted_by_Current_Company__c,Donation_to_Other__c
                            from Income_Tax__c where id=:tax.id];
        If(ITax.Rent_paid_to_landlord__c!=null){
            Attachment a = new Attachment(parentid=tax.id, Name = 'Rent paid to landlord.jpeg' , Body = myfile.body);
            try {insert a;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Leave_travel_concessions_or_assistance__c!=null){
            Attachment a1 = new Attachment(parentid=tax.id, Name = 'Leave travel concessions or assistance.jpeg', Body = myfile1.body);
            try {insert a1;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Interest_payable_paid_to_lender__c!=null){
            Attachment a2 = new Attachment(parentid=tax.id, Name = 'Interest payable paid to lender.jpeg' , Body = myfile2.body);
            try {insert a2;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Employees_PF__c!=null){
            Attachment a3 = new Attachment(parentid=tax.id, Name = 'Employees Provident Fund.jpeg' , Body = myfile3.body);
            try {insert a3;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }
        
        If(ITax.Children_s_Education_Fee__c!=null){
            Attachment a4 = new Attachment(parentid=tax.id, Name = 'Children Education Fee.jpeg' , Body = myfile4.body);
            try {insert a4;}
            catch(Exception ex){
                ApexPages.addMessages(ex);
                return null;
            }
        }

Please help me
Thank you.
Hello Developers,
Please help me to write test class for below apex contoller
public class HRApplyLeaveController {
    Public HRApplyLeaveController(){}
    public String loggesInName{get;set;}
    Public String ResourceName{get;set;}
    public Date FromDate{get;set;}
    
    public List<Leave__c> allLeave{set;get;}
    
    String loggesInId{set;get;}
    List<Resource__c> user = new List<Resource__c>();
    Leave__c lev;
    
    public HRApplyLeaveController(ApexPages.StandardController controller){
        
        ResourceName = System.currentPagereference().getParameters().get('name');
        lev = (Leave__c)controller.getRecord();
        
        user = [SELECT id,Name,Official_Email__c,Personal_Email__c from Resource__c where Name=:ResourceName];
        if(user.size()>0)
        {
            if(user[0].Name != NULL)
            {
                loggesInName =  user[0].Name;
            }
        }
        fetchallLeave();
    }
    //table
    public void fetchallLeave(){
        if(user.size()>0){
            allLeave=[Select From_Date__c,To_Date__c,Type__c,Decision__c,Number_of_Days__c From Leave__c 
                      where Resource__r.Name=:user[0].Name];
        }
    }
    //popup
     public boolean displayPopup {get; set;}
    public void closePopup()
    {       
        displayPopup = false;   
    }    
    public void showPopup()
    {       
        displayPopup = true;
        save();   
    }
    //insert record
    public Pagereference save(){
        lev.Resource__c=user[0].id;
        try{
            insert lev;
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Thank you!Record saved successfully'));
            
        }
        catch(Exception ex){
            ApexPages.addMessages(ex);
        }
        
        //send email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setSubject('Leave Application |'+user[0].Name);
        
        email.setToAddresses( new List<String>{user[0].Personal_Email__c} );
        email.setHtmlBody('Hii Sir/Mam,<br/><br/>https://login.my.salesforce.com/'+lev.Id+
                          '<br/><br/>Regards,<br/>'+'User');
        try{
            Messaging.SendEmailResult [] result = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }catch(System.Exception e){
            system.debug(e);
        }
        return null;
    }
    //home button
    public Pagereference goHome(){
        PageReference pageRef = new PageReference('/apex/HRHome?id='+user[0].id);
        pageRef.setRedirect(true);
        return pageRef;
    }
}

Test class
@isTest
public class HRApplyLeaveControllerTest {
    static testMethod void Test_HRApplyLeaveController() 
    {
        Resource__c res= new Resource__c(Name='Swapnil Joshi',Official_Email__c='abc@xyz.com', Password__c='s123',Emp_ID__c=1);
        insert res;
        
        Leave__c l=new Leave__c();
        l.Resource__c=res.id;
        l.From_Date__c=system.today();
        l.To_Date__c=system.today()+5;
        insert l;
    }
}

Thanks in advance.. :)
Regards,
Anita sodhi
Hello Friends,
Please help me!
I have custom field Zip_Code__c(Number field)
After inserting any value it display 123,456(with comma)
How i convert the Number entered into Zip_code__c into Text Field.
so it will display like 123456(without comma).
Thank you!

Regards
Anita
Hii Friends,'
When i was doing additon of two cutsom Field of type "Time" in formula field of type "Time".
X1__c  +  X2__c 
It shows error like
Error: Incorrect argument type for operator '+'.

Please Help me
Thank you
Hey friends,
I want to set default value as 9 to "Time" Field.
09:00:00
09
09:00
Above values not accepting.
Please tell me how to write it.
Thank you
I have custom object with a field Geolocation type .
How can i create map view of that cities .
I have inserted longitude and latitude values for every city.
how i add it to page layout?
Hii Friends,
Please help me.
The below javascript code on custom detail page button  shows error on click it.
--------------------------------------------------------------------------------------
{!REQUIRESCRIPT("/soap/ajax/47.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/47.0/apex.js")} 

var tempID='{!Offers_Appraisals__c.Id}';
if({!Offers_Appraisals__c.Id}!=Null)
{
sforce.apex.execute("NanoHRSheet","HRSalarySheet",tempID);
}
--------------------------------------------------------------------------------------
Error:
User-added image

What's wrong with code?
Please help me.
Thank you
Hello Guys,

I want to check whether the records is already exist if yes then update it with new data if not insert new record into custom field.


currentRecord = [SELECT ID,Base_Yearly_Package__c FROM  Offers_Appraisals__c WHERE Id = :'a12M000000MMF6k'];

    List<Monthly_Salary__c> SalList = new List<Monthly_Salary__c>();
    SalList=[SELECT ID,Name,From_Date__c FROM Monthly_Salary__c WHERE Resource__c=:currentRecord.Resource__c];
    
                Monthly_Salary__c new_records2=new Monthly_Salary__c();
                                new_records2.Base_Yearly_Package__c=currentRecord.Base_Yearly_Package__c;
                                new_records2.Resource__c=currentRecord.Resource__c;

    for(Monthly_Salary__c s:SalList){
                                        if(s.Name!=new_records3.Name) {
                                            insert new_records3;
                                            break;
                                        } else {update new_records3;}
                           }


Above code working.Not even inserting nor updating the records.
Please help me.
where i am wrong?
Thank you
Hii Guys,
Please help me! I am new to apex code.
I want to access the current Record ID.
and assign that ID to another variable in apex class.

 
public class SampleCode{
    Public Offers_Appraisals__c currentRecord{get; set;}
 
        public SampleCode(ApexPages.StandardController controller) {
        currentRecord = [SELECT ID FROM Offers_Appraisals__c
                                               WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        } 

public static void HRSalarySheet()
    {
        List<Offers_Appraisals__c> OfferList=new List<Offers_Appraisals__c>();
        OfferList=[SELECT ID,Name,
                                              From_Date__c,To_date__c
                                              FROM Offers_Appraisals__c
                                             WHERE ID=:currentRecord.ID];
    }


When i use the above code  it shows error msg 
Variable Does not exist currentRecod.
Please Help me to solve error.
Where my code is going wrong?

Thanks you
Hello 
Please help me out
I have 3 custom object Employee, Payment & Proposal.
Payment have lookup with Employee.
Proposal have lookup with Employee.
Proposal has Year_package__c & From_Date__c custom fileds.

I want to create a custom button(Create Payments) on Proposal detail page.
On click of Create_Payements__c button it will create 12 new record on Payment (Custom obj.) for that Employee.
On Payement The 12 record will be Name like Jan 2020,Feb2020 and so on(as per From_Date__c on Proposal object).
How do I code for it on Custom button??????

Thanks in advance
Hi guys, the quote template has lots of limitations when it comes to styling; I would like to do something custom and need a step-by-step guide. Basically, I would like a "create quote" button on quote pagelayout that references my visualforce page and creates the pdf. 

So I think I need to follow the steps below:
1. Create a custom controller class. Can I do this with standard List controller? Basically, I have to query all the quote and quotelineitems
2. Create a new visual force page using controller from step1, add the proper styling and render as pdf.
3. Create the button on quote with a link to visual force page
Any tips and guides are appreciated. 
Thanks.

Did I miss anything? 
 
Hi All

I am currently working on an implementation of a calendar view in a Visualforce page. Basic idea is to display a schedule on the calendar based on date fields in custom objects. From some searching, I came across this article: http://www.codebycody.com/2013/06/create-calendar-view-in-salesforcecom.html

I tried to follow the code in the working example, but the calendar does not display in the page. Below is the screenshot of the page: 
User-added image

Glady appreciate if someone can guide me through this issue and how best to implement this feature.