• yarram
  • NEWBIE
  • 60 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 59
    Replies
HI all,

I have submitted my application code for force.com security scanner and recieved result report with some secutiy SOQL Injection Vulnerability issues. 
below is the one of the example and already i have implemeted escape singlequote also. but it shows again there is SOQL Injection vulnerability issue on below mentioned screen. pleae help me out how to handle this issue.
User-added image

Thanks,
Yarram.
  • August 24, 2016
  • Like
  • 0
Hi all,
I am not able to do the code coverage for catch block of my below code. how can i achive this. please help me on this.
public static void Task_ContactAddressUpdate(List<Task> tsk){
        Map<Id, List<Task>> whoIdsMap = new Map<Id, List<Task>>();
            try {
                for(Task t : tsk){
                    if(t.WhoId != null){
                        if(!whoIdsMap.containsKey(t.WhoId)){
                            List<Task> temp = new List<Task>();
                                temp.add(t);
                                whoIdsMap.put(t.WhoId, temp);
                        }
                        else {
                            whoIdsMap.get(t.WhoId).add(t);
                        }
                    }
                }
                for(Contact con : [Select Id, Name,MailingCity,MailingStreet,MailingState,MailingCountry,MailingPostalCode  from Contact where Id in :whoIdsMap.keySet()]){
                    for(Task t :whoIdsMap.get(con.Id)){
                        t.MailingCity__c = con.MailingCity;
                        t.MailingStreet__c = con.MailingStreet;
                        t.MailingState__c = con.MailingState;
                        t.MailingCountry__c = con.MailingCountry;
                        t.MailingPostalCode__c = con.MailingPostalCode;
                    }
                }
            }catch (exception e) {
                ApplicationDebugLog.customExceptionDetails(e);
                if (tsk.size() == 1)
                    tsk[0].adderror('Request could not be processed.Please contact System Admin');
                else
                    ApplicationDebugLog.customExceptionDetails(e);
            }
    }
Thanks,
Yarram.
  • November 04, 2015
  • Like
  • 0
Hi all,

i have two custon objects (Case_Application__c(master) and Education_Application_Detail__c(detail)) these both has master-detail relation ship. here what i have to do --- if master object record doesn't have the child records then i have to create child(detail) record with master object record data automatically. i have done this but i am not able to do the code coverage for this logic. below is my class code how can i write the test class for this atleast 80% code coverage. Please help me on this.

public with sharing class RecordTypeCtrl {
     public ID eadRecordTypeId {get;set;}
     List<Case_Application__c> caList;

    public RecordTypeCtrl(){   
           
            eadRecordTypeId = Schema.SObjectType.Case_Application__c.RecordTypeInfosByName.get('Education').RecordTypeId;       
            if(eadRecordTypeId!=null){
                    eadDetails();
            }
    }

  
    public void eadDetails(){
        
         caList=[select id,name,recordtype.name,Award__c,
                                 (select id,name,Case_Application__c from Education_Application_Details__r),Case_Application_Status__c,Case_File__c,
                                                                 Course_Type__c,Details_of_Exceptional_Need__c,Exceptional_Needs_Cost__c,
                                                                 Purpose__c,Sign_Language_Interpreting_Cost__c from Case_Application__c
                                                                 where RecordTypeId=:eadRecordTypeId];
          
          List<Education_Application_Detail__c> eadList=new List<Education_Application_Detail__c>();
          
          for(Case_Application__c ca: caList){
               
              if(ca.Education_Application_Details__r.size()==0){ ----------//from here not cover
               
                   Education_Application_Detail__c ead=new Education_Application_Detail__c();
                        ead.Case_Application__c=ca.Id;
                        ead.Course_Type__c=ca.Course_Type__c;
                        ead.Award__c=ca.Award__c;
                         
                        eadList.add(ead);
              }
-------------/// Upto here not cover
          }
          if(eadList.size()>0){
                insert eadList;
         }

    
    }
}

please help me on this

Thanks,
Yarram.
  • April 20, 2015
  • Like
  • 0
Hi All,

i am getting too many soql limt exceed error when my below class executed. Please help me on this. This is very urgent.

public class ProjectUtil{  
   
    public static void beUpdate(List<OpportunityLineItem > listOLIList){
        Project_Assay__c PrjAssay;
for (OpportunityLineItem OppLI: listOLIList) {
            
  PrjAssay=[select id,name,Assay_Number__c,Sales_Price__c, Study_Number__c,OppAssay__c,
                                    from Project_Assay__c where OppAssay__c=:OppLI.OppAssay__c];                   
                           
                            PrjAssay.Assay_Number__c=OppLI.ProductCode;
                            PrjAssay.Quantity__c=OppLI.Quantity;
                            PrjAssay.Study_Number__c=OppLI.Study_Number__c;
                            PrjAssay.OppAssay__c=OppLI.OppAssay__c;
                            PrjAssay.Sales_Price__c=OppLI.UnitPrice;
                            
        }
         update PrjAssay;
    
    }
    
}

Thanks,
Yarram
  • February 02, 2015
  • Like
  • 0
Hi All,

i am getting too many SOQL queries error when my below class executed. i noticed that soql Queries inside the for loop but i don't have the idea HOW can I write the SOQL queries OUTSide the For LOOP as per my requirement. Below is my Util calss for my trigger. Please help me on this 


public class OLIUtil{
     
    public static void createProject(String OppID){
        
    List<Attachment> aList;
        List<Attachment> newAList=new List<Attachment>();
        
        Project__c newProj;
    
    List<Project_LI__c> PrjLIList=new List<Project_LI__c>();
    
    List<OpportunityLineItem> OppProdList=[Select id,TotalPrice,Subtotal,Product2.Name,ProductCode,Product2.Id,Opportunity.Name,
                             from OpportunityLineItem where Opportunity.Id=:newOpp.Id];
        // make sure we don't create duplicates project records
             if ([select count() from Project__c where Project_Name__c = :NewOpp.Id] == 0) 
             {
                 newProj=new Project__c();
                 newProj.Project_Name__c=NewOpp.Id;
                 newProj.Project_Stage__c='In Progress';
                 insert newProj;
                 Project_LI__c newPrjLI;
                     for(OpportunityLineItem oppLI:OppProdList)
                     {
                            newPrjLI=new Project_LI__c();
                            newPrjLI.LI_Name__c=oppLI.Product2.Name;
                            newPrjLI.Project_Name__c=newProj.Id;
                            newPrjLI.LI_Number__c=oppLI.ProductCode;
                            newPrjLI.Quantity__c=oppLI.Quantity;                      
                            
                            PrjLIList.add(newPrjLI);
                     }
                 insert PrjLIList;
        
                 List<Project_LI__c> addedLI=[select id,name,Project_Name__c,LI_Name__c from Project_LI__c where Project_Name__c=:newProj.Id];
                 
         for(Project_LI__c newAddedLI:addedLI){   // In this for Loop I have written 3 SOQL queries. How can I write these 3 SOQL s to Out side?
                    
            Project_LI__c ddd=[Select id,name,LI_Name__c,Project_Name__c from Project_LI__c where id=:newAddedLI.Id];
                    
            Product2 oppProd=[Select id,name from Product2 where name=:ddd.LI_Name__c];
                    
            aList=[Select Id,name,body,ParentId from Attachment where ParentId=:oppProd.Id];
                    
                    if(aList.size()!=0){
                        for(Attachment aa:aList)
                         {
                             Attachment a=new Attachment();
                                 a.name=aa.name;
                                 a.body=aa.body;
                                 a.ParentId=newAddedLI.id;
                                newAList.add(a);
                         }
                    }
                 }
                 insert newAList;
             }
    }
}

Thanks,
Yarram
  • November 21, 2014
  • Like
  • 0
Hi All,

i am using standard Products and Opportunity Objects, 

i have one requirement like while adding the products to opportunity record if any product has attachments those attachments also be copied to the related Opportunity Line Item record.

but i am not able to do copy products attachments to related Opportunity line Item records. because of Opportunity Line Item object it doesn't related with Attachment Object.

how can i add the product related attachments to Opportunity Line Items records?

How can i achive this functionality?

Please help me on this..

Thanks,
Yarram
  • October 29, 2014
  • Like
  • 0
HI All,

how can i use "create quote pdf" functionality on my custom object for crate pdf for my custom object data same as quote pdf.

is this possible?

Any advice to get to this solution?
 
  • September 09, 2014
  • Like
  • 0
Hi All,

i am not able to cover getter method "if " statement code in my test class

how to write test class for this Controller class List variable getter method "if" satatement 

public with sharing class listtestCtrl {
public String selectedType{get;set;}
public String selectedLeadSource{get;set;}
 
public List<Opportunity> listOpp{
    get{
        String query='Select id,LeadSource,Name,StageName,Type from Opportunity ';
       
        if((this.selectedLeadSource!='All Sources') && (this.selectedLeadSource!= null)){
            query=query+'Where LeadSource=:selectedLeadSource';
        }

       if((this.selectedType!='All Types') && (this.selectedType!= null)){
            query=query+'AND Type=:selectedType';
        } 

query += ' ORDER BY LeadSource';
         return (List<Opportunity>)database.query(query);  
    }
    set;
}

}

Please help me .
Thanks in advance.
Thanks,
Yarram
HI all,

how to do for loop code coverage? for bleow code............

public Incoice__c invoice;
public List<QuoteLineItem> QLItemsList;
public List<QuoteLineItem> getQLItems()
    {
        QLItemsList=[Select id,TotalPrice,Qty_Sent__c,Comments__c,Subtotal,Product2.Name,Product2.ProductCode,Product2.Id,Quote.Name,
                        Quote.Id,UnitPrice,Quantity,ListPrice,LineNumber,Description,Discount from QuoteLineItem where QuoteId=:currentQuoteID ];
        return QLItemsList;
    }
public PageReference onSave()
    {
                invoice =new Invoice__c();
               
                invoice.Boxes_Shipped__c=boxesShipped;
                invoice.CRF=custRefNo;               
                        try{
                            insert invoice;
                        }
                        catch(exception e){
                            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please Check' + e.getMessage()));
                            return null;
                        }
               
                for(QuoteLineItem qlItem:QLItemsList) {  //from here not coverd                  
                    InvoiceLine_Items__c invLine=new InvoiceLine_Items__c();
                        invLine.Incoice__c=invoice.Id;
                        invLine.Description__c=qlItem.Product2.Name;
                        invLine.Product__c=qlItem.Product2.Id;
                        invLine.Product_Code__c=qlItem.Product2.ProductCode;
                        invLine.Qty_Ordered__c=qlItem.Quantity;
                        invLine.Qty_Sent__c=qlItem.Qty_Sent__c;
                        invLine.Unit_Price__c=qlItem.UnitPrice;
                        invLine.Comments__c=qlItem.Comments__c;
                        try{
                            Insert invLine;
                        }
                        catch(exception e){
                            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please Check' + e.getMessage()));
                            return null;
                        }
                }
//upto here not coverd
               PageReference detailsPage=new PageReference('/apex/invoiceDetails?id='+newDelDktID);
                        detailsPage.setRedirect(true);
                        return detailsPage;
    }



please help me on this .......this is Urgent
Hi,

i want to display my org connected apps list on visualforce page. how can i quried (SOQL) in apex class.


Thanks,
Yarram.

Hi, 
      my requirement is ...... i created one connected app for iOS (Native App with mobile SDK) in my org and it was placed in iTunes. my customers dowload
this App and logging into this app with their credentials and did some operations (like task creation, updations and users creation).
when my customer logged into this iOS App  i need to get and display my customers org information (#active users, #inactive users, #open tasks & #closed tasks) on my Org.

Is it POSSIBLE in salesforce?

thanks,
yarram. 
i am using Dynamic comonent feature in my visualforce page for displaying two  "PageBlockTables"  like Pathologist 1 and Pathologist 2(From Pathologist Object) each Pathologist table having  4 Patients(Patient Object) . My requirement is i need to do move (up and down) and drag n drop records with in the table and in between two tables. IS IT possible in salesforce?

Hi,

 

How to write a trigger for below Trigger.

 

trigger creatingPathRecordsusingcontacts on Contact (after insert, after update) {
        for (Contact cont: Trigger.new){ 
            if(cont.Due_Date__c!=null){       
                
                Contact NewContact=[Select id,name,Account.id,Account.name from Contact where id=:cont.id];
                
                Path__c newPath=new Path__c();
                newPath.Name=NewContact.Account.name;
                newPath.AccountName__c=NewContact.Account.id;
                newPath.Path_Type__c='Evaluation';
                newPath.Product__c='REDACTED';                 
                insert newPath;                
                Path__c  PathExpDate=[Select id,name,CreatedDate from Path__c  where id=:newPath.id];
                    Datetime expdate=PathExpDate.CreatedDate;
                    expdate=expdate.addDays(14);
                    newPath.Expiration_Date__c=expdate;
                    update newPath;
           }
    
        }
}

 please help me out this.

 

Thanks,

Yarram.

  • December 16, 2013
  • Like
  • 0

Hi,

 

How to create custom object and custom object fields using Apex code.

 

Is this possible?

 

Thanks,

Yarram.

  • December 11, 2013
  • Like
  • 0

Hello,

 

I create a apex class, which contains some dynamic SOQLs. The function used for custom pagination and custom search functionality.

 

All of them works fine. But I tried the security check marx in my account and found dynamic SOQL caused security Issues.like SOQL Injection.

 

Error : Severity - Critical


 public List<Branch__c> getRecords()

{
return (List<Branch__c>)database.query(FetchBranchRecordsQry+' LIMIT '+PaginationForBranch.queryLimit+' OFFSET' +PaginationForBranch.offset);

}

 

string  FetchBranchRecordsQry='Select id, Name, CreatedBy.Name,Branch__c.CreatedDate,BranchName__c, BranchAdmin__r.Name, BranchEstDate__c, Active__c FROM Branch__c Order by Name DESC';

 

 

Any one can help me how to use dynamic SOQL.

 

 

Thanks,

Yarram

 

 

  • November 26, 2013
  • Like
  • 0

Hi...

     How do i convert image body/attachment object image to byte array and viceversa. give me one example.

 

Plz help me.

 

Thanks,

Yarram

 

 

  • February 04, 2013
  • Like
  • 0

Hi All,

 


i have two string values like Blockno[ (1,2,3) ] and BlockNo1[ (1,3,4) ]. while comparing these two strings '3' is common value , so when matching the value it should display error message.

 

below mentioned code is not working for me .....

 

So , i want to compare Two string Arrays...How can i achive this ?

 

 

        for(SpecimenTest__c boxes : testlist)
        {
         
                String blkno=boxes.BlockNo__c;//here the value like[ (1,2,3) ]
                String blkno1=speci.BlockNo__c; //here the value like[ (1,3,4) ]               
                String[] st = blkno.split(' , ');
                String[] st1 = blkno1.split(' , ');
                for(integer i=1;i<=st.size();i++)
                {
                    for(integer j=1;j<=st1.size();j++)
                    {
                    Integer resultb =st1[0].compareTo(st[0]);
                     
                        if(resultb ==0)
                        {
                            error code;
                        }
                    }
                }

        }

 

Please help me ...

Thanks,

Yarram

  • September 06, 2012
  • Like
  • 0

Hi All,

 

I have one VF Page, That contains 30 Checkboxes(Check Boxes List), I select first 3  Check Boxes and Click on save Button on VF page.

 

Values of 3 check boxes are 1,2 and 3 are saved into one Texed Field.

 

Like...Text Field is  Blocks : 1,2,3

 

 

public Blocks__c Block= new Blocks__c(); 

Public Void blockSave()

{

       Insert Block;

}

 

public String Boxes{get;set;}
public List<SelectOption> getCheckBoxes()
{
List<SelectOption> CheckboxLists = new List<SelectOption>();
for(Integer i=1;i<=30;i++)
{
CheckboxLists.add(new SelectOption(String.valueOf(i),String.valueOf(i)));
}
return CheckboxLists;
}

 

 

// VF Page Code----------------
<apex:selectCheckboxes value="{!Boxes}">
<apex:selectOptions value="{!BlocknoLists}"/>
</apex:selectCheckboxes>

 

Please give help, How can I Achive.

 

Thanks,

Yarram.

  • August 10, 2012
  • Like
  • 0

Hi All,

 

I have Check Box List, Size of that List is 30 and Those List of Check Boxes are displayed in VF page. Check Boxes are OVERFLOW of that page.

 

How can I split Check Boxes into Three Lines each line 10 check boxes.

 

Below is my code.............

// Controller Code...............

 

 

public String Blocks {get;set;}
public List<SelectOption> getCheckboxes()
{
List<SelectOption> CheckboxLists = new List<SelectOption>();
for(Integer i=1;i<=30;i++)
{
CheckboxLists.add(new SelectOption(String.valueOf(i),String.valueOf(i)));
}
return CheckboxLists;
}

 

//VF Code........................
<apex:selectCheckboxes value="{!Blocks }">
<apex:selectOptions value="{!Checkboxes}"/>
</apex:selectCheckboxes>

 

Please give me the help. How to Split those.

 

Thanks.

Yarram.

 

 

  • August 10, 2012
  • Like
  • 0

Hi,


Ihave created one Product Custom Object with some fields(one of the field is Country Pick list).I have one picklist and values of the picklist like  Country--> US,Canada,China. and

I have Three Users Like US User,Canada User and China User.

Login with US User-->Click on Product Object tab-->Click on New Button-->Product Page Layout Displayed all fileds and Country Picklist also Three values(US, Canada and China).

My question is How to Restrict the Canada and China values in the US User(Login Time) Country Picklist?

 
I want to display only "US"  Value in Country Picklist(US User Login time).

How can i achive this one .

Please give me Suggestions.

Thanks.
Yarram.

Hi all,
I am not able to do the code coverage for catch block of my below code. how can i achive this. please help me on this.
public static void Task_ContactAddressUpdate(List<Task> tsk){
        Map<Id, List<Task>> whoIdsMap = new Map<Id, List<Task>>();
            try {
                for(Task t : tsk){
                    if(t.WhoId != null){
                        if(!whoIdsMap.containsKey(t.WhoId)){
                            List<Task> temp = new List<Task>();
                                temp.add(t);
                                whoIdsMap.put(t.WhoId, temp);
                        }
                        else {
                            whoIdsMap.get(t.WhoId).add(t);
                        }
                    }
                }
                for(Contact con : [Select Id, Name,MailingCity,MailingStreet,MailingState,MailingCountry,MailingPostalCode  from Contact where Id in :whoIdsMap.keySet()]){
                    for(Task t :whoIdsMap.get(con.Id)){
                        t.MailingCity__c = con.MailingCity;
                        t.MailingStreet__c = con.MailingStreet;
                        t.MailingState__c = con.MailingState;
                        t.MailingCountry__c = con.MailingCountry;
                        t.MailingPostalCode__c = con.MailingPostalCode;
                    }
                }
            }catch (exception e) {
                ApplicationDebugLog.customExceptionDetails(e);
                if (tsk.size() == 1)
                    tsk[0].adderror('Request could not be processed.Please contact System Admin');
                else
                    ApplicationDebugLog.customExceptionDetails(e);
            }
    }
Thanks,
Yarram.
  • November 04, 2015
  • Like
  • 0
Hi all,

i have two custon objects (Case_Application__c(master) and Education_Application_Detail__c(detail)) these both has master-detail relation ship. here what i have to do --- if master object record doesn't have the child records then i have to create child(detail) record with master object record data automatically. i have done this but i am not able to do the code coverage for this logic. below is my class code how can i write the test class for this atleast 80% code coverage. Please help me on this.

public with sharing class RecordTypeCtrl {
     public ID eadRecordTypeId {get;set;}
     List<Case_Application__c> caList;

    public RecordTypeCtrl(){   
           
            eadRecordTypeId = Schema.SObjectType.Case_Application__c.RecordTypeInfosByName.get('Education').RecordTypeId;       
            if(eadRecordTypeId!=null){
                    eadDetails();
            }
    }

  
    public void eadDetails(){
        
         caList=[select id,name,recordtype.name,Award__c,
                                 (select id,name,Case_Application__c from Education_Application_Details__r),Case_Application_Status__c,Case_File__c,
                                                                 Course_Type__c,Details_of_Exceptional_Need__c,Exceptional_Needs_Cost__c,
                                                                 Purpose__c,Sign_Language_Interpreting_Cost__c from Case_Application__c
                                                                 where RecordTypeId=:eadRecordTypeId];
          
          List<Education_Application_Detail__c> eadList=new List<Education_Application_Detail__c>();
          
          for(Case_Application__c ca: caList){
               
              if(ca.Education_Application_Details__r.size()==0){ ----------//from here not cover
               
                   Education_Application_Detail__c ead=new Education_Application_Detail__c();
                        ead.Case_Application__c=ca.Id;
                        ead.Course_Type__c=ca.Course_Type__c;
                        ead.Award__c=ca.Award__c;
                         
                        eadList.add(ead);
              }
-------------/// Upto here not cover
          }
          if(eadList.size()>0){
                insert eadList;
         }

    
    }
}

please help me on this

Thanks,
Yarram.
  • April 20, 2015
  • Like
  • 0
Hi All,

i am getting too many soql limt exceed error when my below class executed. Please help me on this. This is very urgent.

public class ProjectUtil{  
   
    public static void beUpdate(List<OpportunityLineItem > listOLIList){
        Project_Assay__c PrjAssay;
for (OpportunityLineItem OppLI: listOLIList) {
            
  PrjAssay=[select id,name,Assay_Number__c,Sales_Price__c, Study_Number__c,OppAssay__c,
                                    from Project_Assay__c where OppAssay__c=:OppLI.OppAssay__c];                   
                           
                            PrjAssay.Assay_Number__c=OppLI.ProductCode;
                            PrjAssay.Quantity__c=OppLI.Quantity;
                            PrjAssay.Study_Number__c=OppLI.Study_Number__c;
                            PrjAssay.OppAssay__c=OppLI.OppAssay__c;
                            PrjAssay.Sales_Price__c=OppLI.UnitPrice;
                            
        }
         update PrjAssay;
    
    }
    
}

Thanks,
Yarram
  • February 02, 2015
  • Like
  • 0
Hi All,

i am getting too many SOQL queries error when my below class executed. i noticed that soql Queries inside the for loop but i don't have the idea HOW can I write the SOQL queries OUTSide the For LOOP as per my requirement. Below is my Util calss for my trigger. Please help me on this 


public class OLIUtil{
     
    public static void createProject(String OppID){
        
    List<Attachment> aList;
        List<Attachment> newAList=new List<Attachment>();
        
        Project__c newProj;
    
    List<Project_LI__c> PrjLIList=new List<Project_LI__c>();
    
    List<OpportunityLineItem> OppProdList=[Select id,TotalPrice,Subtotal,Product2.Name,ProductCode,Product2.Id,Opportunity.Name,
                             from OpportunityLineItem where Opportunity.Id=:newOpp.Id];
        // make sure we don't create duplicates project records
             if ([select count() from Project__c where Project_Name__c = :NewOpp.Id] == 0) 
             {
                 newProj=new Project__c();
                 newProj.Project_Name__c=NewOpp.Id;
                 newProj.Project_Stage__c='In Progress';
                 insert newProj;
                 Project_LI__c newPrjLI;
                     for(OpportunityLineItem oppLI:OppProdList)
                     {
                            newPrjLI=new Project_LI__c();
                            newPrjLI.LI_Name__c=oppLI.Product2.Name;
                            newPrjLI.Project_Name__c=newProj.Id;
                            newPrjLI.LI_Number__c=oppLI.ProductCode;
                            newPrjLI.Quantity__c=oppLI.Quantity;                      
                            
                            PrjLIList.add(newPrjLI);
                     }
                 insert PrjLIList;
        
                 List<Project_LI__c> addedLI=[select id,name,Project_Name__c,LI_Name__c from Project_LI__c where Project_Name__c=:newProj.Id];
                 
         for(Project_LI__c newAddedLI:addedLI){   // In this for Loop I have written 3 SOQL queries. How can I write these 3 SOQL s to Out side?
                    
            Project_LI__c ddd=[Select id,name,LI_Name__c,Project_Name__c from Project_LI__c where id=:newAddedLI.Id];
                    
            Product2 oppProd=[Select id,name from Product2 where name=:ddd.LI_Name__c];
                    
            aList=[Select Id,name,body,ParentId from Attachment where ParentId=:oppProd.Id];
                    
                    if(aList.size()!=0){
                        for(Attachment aa:aList)
                         {
                             Attachment a=new Attachment();
                                 a.name=aa.name;
                                 a.body=aa.body;
                                 a.ParentId=newAddedLI.id;
                                newAList.add(a);
                         }
                    }
                 }
                 insert newAList;
             }
    }
}

Thanks,
Yarram
  • November 21, 2014
  • Like
  • 0
Hi All,

i am not able to cover getter method "if " statement code in my test class

how to write test class for this Controller class List variable getter method "if" satatement 

public with sharing class listtestCtrl {
public String selectedType{get;set;}
public String selectedLeadSource{get;set;}
 
public List<Opportunity> listOpp{
    get{
        String query='Select id,LeadSource,Name,StageName,Type from Opportunity ';
       
        if((this.selectedLeadSource!='All Sources') && (this.selectedLeadSource!= null)){
            query=query+'Where LeadSource=:selectedLeadSource';
        }

       if((this.selectedType!='All Types') && (this.selectedType!= null)){
            query=query+'AND Type=:selectedType';
        } 

query += ' ORDER BY LeadSource';
         return (List<Opportunity>)database.query(query);  
    }
    set;
}

}

Please help me .
Thanks in advance.
Thanks,
Yarram
Hi,

i want to display my org connected apps list on visualforce page. how can i quried (SOQL) in apex class.


Thanks,
Yarram.

Hi,

 

How to write a trigger for below Trigger.

 

trigger creatingPathRecordsusingcontacts on Contact (after insert, after update) {
        for (Contact cont: Trigger.new){ 
            if(cont.Due_Date__c!=null){       
                
                Contact NewContact=[Select id,name,Account.id,Account.name from Contact where id=:cont.id];
                
                Path__c newPath=new Path__c();
                newPath.Name=NewContact.Account.name;
                newPath.AccountName__c=NewContact.Account.id;
                newPath.Path_Type__c='Evaluation';
                newPath.Product__c='REDACTED';                 
                insert newPath;                
                Path__c  PathExpDate=[Select id,name,CreatedDate from Path__c  where id=:newPath.id];
                    Datetime expdate=PathExpDate.CreatedDate;
                    expdate=expdate.addDays(14);
                    newPath.Expiration_Date__c=expdate;
                    update newPath;
           }
    
        }
}

 please help me out this.

 

Thanks,

Yarram.

  • December 16, 2013
  • Like
  • 0

Hello,

 

I create a apex class, which contains some dynamic SOQLs. The function used for custom pagination and custom search functionality.

 

All of them works fine. But I tried the security check marx in my account and found dynamic SOQL caused security Issues.like SOQL Injection.

 

Error : Severity - Critical


 public List<Branch__c> getRecords()

{
return (List<Branch__c>)database.query(FetchBranchRecordsQry+' LIMIT '+PaginationForBranch.queryLimit+' OFFSET' +PaginationForBranch.offset);

}

 

string  FetchBranchRecordsQry='Select id, Name, CreatedBy.Name,Branch__c.CreatedDate,BranchName__c, BranchAdmin__r.Name, BranchEstDate__c, Active__c FROM Branch__c Order by Name DESC';

 

 

Any one can help me how to use dynamic SOQL.

 

 

Thanks,

Yarram

 

 

  • November 26, 2013
  • Like
  • 0

public class newuser {

    public HR__c rec {set;get;}
    public HR__c hr {set;get;}
    public User myNewUser {set;get;}    
          
       
    public newuser(ApexPages.StandardController controller) {
            myNewUser = new User();
            rec = (HR__c) controller.getRecord();
            hr  = [Select Id, Job_Code__c, Job_Title__c,Employee_Number__c, User__c From HR__c where Id =: rec .Id];
            myNewUser.EmployeeNumber = hr.Employee_Number__c;
            myNewUser.Title= hr.Job_Title__c;
            myNewUser.JobCode__c=hr.Job_Code__c;                 
   }
    
    public PageReference saveUser(){
    
            insert myNewUser;
            hr.User__c = myNewUser.Id;
            update hr;
            PageReference pageRef= new PageReference('/'+ hr.Id);
            return pageRef ;           
         }
    }

Hi All,

 

I have developed a vf page in which once a user chooses a pricebook , he will be able to see the list of products tied to that pricebook in a pageblock table. In order to accomplish this I have used the wrapper class which has a checked field and some input field along with fields from PRoduct2 object.

 

I have two options to write a validation to check the quqntity is not 0 if the product checkbox is checked .

 

1) From javascript ---client side validation:

 

I want to write a validation in javascript , when the checkbox is checked i.e that product is selected, I need to validate the quantity column in th table and alert if the quantity is 0.

 

When I read the checkbox field from javascript though it is checked or unchecked I am getting  a value of null always :

 

alert(document.getElementById('{!$Component.theForm.ProductDetail.ProductDetails.table.selectLine1}'));----returns null
and  alert(document.getElementById('{!$Component.selectLine1}')); ------retruns null

 

 

2) From Apex controller ---server side validation

 

I ama ble to read the values from the apex class perfectly fine i.e, checked as false initially and once user selects the product it is true.

 

And if the product is checked and the quantity field is 0 I am displaying a error message like below:

 

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please Enter Quantity  for the Product Selected!!') );
                     return null; ---------> When I return this pagereference  all the information enters by the user disappears and the page is clear of all the user inputted data.

 

How can I retain the information entered by the user and display a validation message .

 

Any help on client side or server side validation is highly appreciated.

 

 

Thanks

 

 

  • April 30, 2013
  • Like
  • 0