• Soumya sri yarava
  • NEWBIE
  • 30 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 13
    Replies
 hi, guys i have around 50 to 60 callouts with same code only Endpoint will changes in every method,  so how to reuse the same set of http code in all the methods, any solution for this will be apperiacated for the code re useability.. 
 
public void method1(){

  Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
    // Deserialize the JSON string into collections of primitive data types.
    Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
    // Cast the values in the 'animals' key as a list
    List<Object> animals = (List<Object>) results.get('animals');
    System.debug('Received the following animals:');
    for (Object animal: animals) {
        System.debug(animal);
    }
}

}


public void method2(){

  Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/countries');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
    // Deserialize the JSON string into collections of primitive data types.
    Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
    // Cast the values in the 'countries' key as a list
    List<Object> countries= (List<Object>) results.get('countries');
    System.debug('Received the following countries:');
    for (Object country: countries) {
        System.debug(country);
    }
}

}

Note: how to reuse the same code in all the methods arount 50 methods, only the endpoint will changes here .. 

Thanks and regards
Soumya sree 
<apex:page > <apex:outputLink value="{!URLFOR($Action.Attachment.Download, $Resource.test_pdf)}" target="_blank">Click Here to Download Pdf File</apex:outputLink> --> <apex:form > <apex:commandButton value="Downloadpdf"/> <apex:outputLink value="{!URLFOR($Resource.test_pdf)}" >Click Here to Download Pdf File</apex:outputLink> </apex:form> </apex:page>
need a button only , to download the pdf stored in the static Resource
note: instead of viewing need to download the file directly onclicking on the button
, Thanks 
soumya ... 
 
<apex:page >
   
   
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, $Resource.test_pdf)}" target="_blank">Click Here to Download Pdf File</apex:outputLink>
       -->

       <apex:form >
           <apex:commandButton value="Downloadpdf"/>

<apex:outputLink value="{!URLFOR($Resource.test_pdf)}" >Click Here to Download Pdf File</apex:outputLink>

        </apex:form>
        
</apex:page>

hi guys, how to download the pdf file using the static resource in salesforce, instead of viewing need to dowload the file in using the salesforce

thanks and regards
soumya sree
hi guys, i have one  Editable pdf Form with fileds like name,address and other details, and i have loaded the form in the salesforce StaticResource. The requirement is need to map the values form controller to that Editablepdf fileds, so please advice how it can be acheived, any idea will be much appreciated.iam using the online pdfesacpe to get the ids of the fileds to map the values, if any one worked on that will be appreciated.. please share your advice to achieve ..

Thanks and Regards,
Soumya Sree
Hi, i have  uploaded multiple pdfs in StaticResource ,and need to download the pdf depending upon the button click ,
how can i download the file  , iam using the below apexpage , but cant able to download the file, its jst opening in the other page.,


 
<apex:page action="{!URLFOR($Resource.employepdf)}"  >
</apex:page>

Note:It is getting; open in the other page, but the thing is need to download the pdf , how can it done, please let me know 


Thanks and regards,
soumya sree.
 
hi guys, we have a Editable pdf  , need load the pdf  to pdfescape in the pdfescape website,  and find the filed name using the inspect element, and by taking the filed id , need to bind the value from apex controller  and download the file , may i know how it can be  achieved , 
Any one used the  PDFESCAPE in apex controller ???
Online website : https://www.pdfescape.com/open/

Thanks and regards,
Soumya sree
public class OrignContrl {

  public decimal xvalue{get;set;}
  
   public decimal yvalue{get;set;}
   
   public string Totalcost{get;set;}
   
     public OrignContrl(){
      Totalcost ='Testing';
      }


    public void setvalues(){
    xvalue =48.05;
    yvalue =50.06;
   
     }
    
}

visualForce page:

 
<apex:page controller="OrignContrl" >
 <apex:form >
 <apex:commandButton value="Display in selected format" Action="{!setvalues}" />
 <apex:outputLabel >{!Totalcost}</apex:outputLabel>
 </apex:form>
</apex:page>

onclick on the button the values assigned to the particular outputlabel and display

thanks and regards
soumya reddy
Hi, iam working with wrapper class, if i dnt select any checkboxes, the command button should be in disable mode.
1)if selected any one  checkbox, then the command button should have to enable mode.

how to acheive this function using in repeat functionality and wrapper class, please help out.
  can any one explain how to do in javascript, pleaase thanks in advance...!
public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<Wrapperclass> containslistcheck{get;set;}

  
  public test3(){
 listSelectedNames = new list<string>();
containslistcheck  = new list<Wrapperclass>(); 
 
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='Samsung';
                   wf.state='AndhraPradesh';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='Oneplus';
                   wf1.state='Telangana';
                                  
          wraplist.add(wf);
          wraplist.add(wf1);
         
         
 }
 
 
   public void duplicatecheck(){
    listSelectedNames.clear();
   
    
    for(wrapperclass wrap: wraplist){
        if(wrap.selected == true){
           
            listSelectedNames.add(wrap.Name);
           
         }  
    }
    
    system.debug(listSelectedNames);
}


 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
        public string state{get;set;}
    }
  
  
}



Visualforce page:;

 
<apex:page controller="test3"  id="pg">
   <apex:form id="fm">
  
  <script>
  
      Disablebtn();
    function Disablebtn(){
    //alert();
    
     //document.getElementById("pg:fm:pb:btn").setAttribute("disabled","disabled");
     //document.getElementById("pg:fm:pb:btn").disabled = disabled ;
     //document.getElementById("pg:fm:pb:btn").disabled = true;
    
     }
  
  </script>     
      
      
      
   <apex:pageBlock id="pb">
      <apex:pageblockTable value="{!wraplist}"  var="a" id="pbt">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"  id="sampletest"/>{!a.name}</apex:column>
        <apex:column >{!a.state}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"  id="btn"/>
       <apex:outputLabel id="two">{!listSelectedNames}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>


thanks in advance
soumya sree
public class jsonresponse{
 
  public string jsonTest{get;set;}
  public wrapperclass wrapperclasswrap{get;set;}
  public list<wrapperclass> wrapperclasswrapnameslst{get;set;}
  public string Totaldata{get;set;}
   public list<string> totallistdata{get;set;}
      public jsonresponse(){
      totallistdata = new list<string>();
      wrapperclasswrap = new wrapperclass();
      wrapperclasswrapnameslst =  new list<wrapperclass>();
jsonTest ='{"$id":"1","data":{"$id":"2","compName":"Big-CMobiles","SalesData":[{"$id":"3","Name":"Sony","purchaseddata":[{"$id":"4","category":"ipads","amount":null},{"$id":"5","category":"Electronics","amount":7000}]},{"$id":"6","Name":"samsung","purchaseddata":[{"$id":"7","category":"","amount":null},{"$ref":"5"}]},{"$id":"8","Name":"Totals","purchaseddata":[{"$id":"9","category":"Electronics","amount":7000},{"$id":"10","category":"Spares","amount":0}]}]}}';  
     
            Map<string, object>  mapobj = (map<string,object>)json.deserializeuntyped(jsonTest);
           Object objj = (object)mapobj.get('data');
          string serilize = system.json.serialize(objj);
         wrapperclasswrap =(wrapperclass)system.json.deserialize(serilize,wrapperclass.class);
   system.debug('=================second ========================');
    Map<string, object>  mapobj2 = (map<string,object>)json.deserializeuntyped(serilize);
   Object objj2 = (object)mapobj2.get('SalesData');
  string serilize2 = system.json.serialize(objj2 );
  
          wrapperclasswrapnameslst =(list<wrapperclass>)system.json.deserialize(serilize2 ,list<wrapperclass>.class);
              system.debug(wrapperclasswrapnameslst[0].Name);
              system.debug(wrapperclasswrapnameslst[0].purchaseddata[0].category);  //iam getting phones
              
              for(wrapperclass wr:wrapperclasswrapnameslst){
              
               Totaldata = wr.name+'\t';
                Totaldata +=wr.purchaseddata[0].category;
                
               //for(purchaseddata p:er.purchaseddata){
               
               //how to bind the subclass data in the for loop any idea
               
                //}  
               
                   
                totallistdata.add(Totaldata);
               }
             
             
                 }
            
      
       
       
       
       public class wrapperclass{
         public string compName{get;set;}
         public string Name{get;set;}
         public integer amount{get;set;}
         public list<purchaseddata> purchaseddata{get;set;}
     
       public wrapperclass(){       
          purchaseddata= new list<purchaseddata>();
        }
    }

     //wrapclass2subwrapper
      public class purchaseddata{
         public string category{get;set;}
         public integer amount{get;set;}
      }

}

Visual force page:

 
<apex:page controller="jsonresponse">

 
   <apex:repeat value="{!totallistdata}" var="a">
   {!a}
   
   </apex:repeat>
</apex:page>


Note:  how to use subwrapper clss in in the forloop
for(wrapperclass wr:wrapperclasswrapnameslst){
     Totaldata = wr.name+'\t';
      //Totaldata +=wr.purchaseddata[0].category;  //this is static way
 for(purchaseddata p:er.purchaseddata){
//how to bind the subclass data in the for loop any idea dynamically
totallistdata.add(Totaldata);
 }
}
public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<Wrapperclass> containslistcheck{get;set;}

  
  public test3(){
 listSelectedNames = new list<string>();
containslistcheck  = new list<Wrapperclass>(); 
 
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='Samsung';
                   wf.state='AndhraPradesh';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='Oneplus';
                   wf1.state='Telangana';
                                  
   Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='Lenovo';
                  wf2.state='Chennai';
                
     Wrapperclass   wf3= new Wrapperclass();
                  wf3.selected=false;
                   wf3.name ='Redmi';
                  wf3.state='AndhraPradesh';
                  
                  
                
                
          wraplist.add(wf);
          wraplist.add(wf1);
          wraplist.add(wf2);
          wraplist.add(wf3);
         
 }
 
 
   public void duplicatecheck(){
    listSelectedNames.clear();
   
    
    for(wrapperclass wrap: wraplist){
        if(wrap.selected == true){
           
            listSelectedNames.add(wrap.Name);
           
         }  
    }
    
    system.debug(listSelectedNames);
}


 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
        public string state{get;set;}
    }
  
  
}

v.f page:

 
<apex:page controller="test3">
   <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
        <apex:column >{!a.state}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"/>
       <apex:outputLabel id="two">{!listSelectedNames}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>

User-added image


1)if i have selected the samsung checkbox with andhrapradesh, and 
2)if i select  the Redmicheckbox with andhrapradesh with  same state, it should show an alert and disable the Redmi checkbox, 

Please provide me help how can i achieve this, with links or solution s

Thanks and  Regards
 Soumya Reddy.
Thanks in advance
 
public class jsoncontrltest {
 
  public string jsonTest{get;set;}
  public wrapperclass wrapperclasswrap{get;set;}
  public list<wrapperclass> wrapperclasswrapnameslst{get;set;}
  
      public jsoncontrltest(){
      wrapperclasswrap = new wrapperclass();
      wrapperclasswrapnameslst =  new list<wrapperclass>();
jsonTest ='{"$id":"1","data":{"$id":"2","compName":"Big-CMobiles","SalesData":[{"$id":"3","Name":"Sony","purchaseddata":[{"$id":"4","category":"","amount":null},{"$id":"5","category":"Electronics","amount":7000}]},{"$id":"6","Name":"samsung","purchaseddata":[{"$id":"7","category":"","amount":null},{"$ref":"5"}]},{"$id":"8","Name":"Totals","purchaseddata":[{"$id":"9","category":"Electronics","amount":7000},{"$id":"10","category":"Spares","amount":0}]}]}}';  
     
            Map<string, object>  mapobj = (map<string,object>)json.deserializeuntyped(jsonTest);
            system.debug('the mapped functionality is :::'+ mapobj); 
           
           Object objj = (object)mapobj.get('data');
           system.debug('the data value is :::'+objj);
          
          string serilize = system.json.serialize(objj);
          system.debug('entered till here'+serilize);
                 
        wrapperclasswrap =(wrapperclass)system.json.deserialize(serilize,wrapperclass.class);
        system.debug(wrapperclasswrap.compName); 
   
   system.debug('=================second ========================');
    
        Map<string, object>  mapobj2 = (map<string,object>)json.deserializeuntyped(serilize);
         system.debug('the mapped functionality is :::'+ mapobj2); 
        
        Object objj2 = (object)mapobj2.get('SalesData');
          system.debug('the data value is :::'+objj2);
         
         string serilize2 = system.json.serialize(objj2 );
          system.debug('entered till here'+serilize2);
          
          wrapperclasswrapnameslst =(list<wrapperclass>)system.json.deserialize(serilize2 ,list<wrapperclass>.class);
             
             if(wrapperclasswrapnameslst !=null){
                system.debug(wrapperclasswrapnameslst[0].Name);
                  //system.debug(wrapperclasswrapnameslst[0].purchaselist[0].category);
                 }
            
      
       }
       
       
       public class wrapperclass{
       public string compName{get;set;}
       
        public string Name{get;set;}
        
        public string category{get;set;}
        
        public integer amount{get;set;}
        
        public list<purchaseddata> purchaselist{get;set;}
     
       public wrapperclass(){       
          purchaselist = new list<purchaseddata>();
        }
    }

     //wrapclass2
      
      public class purchaseddata{
      
       public string category{get;set;}
       
       public integer amount{get;set;}
      }

}

Visualforce page;
 
<apex:page controller="jsoncontrltest" >
   {!wrapperclasswrap.compName}
   <apex:form >
  <table style="width:100%">

  <apex:repeat value="{!wrapperclasswrapnameslst}" var="a">

  <tr>
    <th>{!a.Name}</th>
  </tr>

  <tr>
    <td>categorynames</td>
     <td>amounts</td>
  </tr>

     </apex:repeat>
</table>   
   </apex:form>
</apex:page>

User-added image


Thanks
soumya sree
<apex:page controller="jsoncontrltest" >
   {!wrapperclasswrap.compName}
   <apex:form >
  <table style="width:100%">

  <apex:repeat value="{!wrapperclasswrapnameslst}" var="a">

  <tr>
    <th>{!a.Name}</th>
  </tr>

  <tr>
    <td>categorynames</td>
     <td>amounts</td>
  </tr>

     </apex:repeat>
</table>   
   </apex:form>
</apex:page>
 
public class jsoncontrltest {
 
  public string jsonTest{get;set;}
  public wrapperclass wrapperclasswrap{get;set;}
  public list<wrapperclass> wrapperclasswrapnameslst{get;set;}
  
      public jsoncontrltest(){
      wrapperclasswrap = new wrapperclass();
      wrapperclasswrapnameslst =  new list<wrapperclass>();
jsonTest ='{"$id":"1","data":{"$id":"2","compName":"Big-CMobiles","SalesData":[{"$id":"3","Name":"Sony","purchaseddata":[{"$id":"4","category":"","amount":null},{"$id":"5","category":"Electronics","amount":7000}]},{"$id":"6","Name":"samsung","purchaseddata":[{"$id":"7","category":"","amount":null},{"$ref":"5"}]},{"$id":"8","Name":"Totals","purchaseddata":[{"$id":"9","category":"Electronics","amount":7000},{"$id":"10","category":"Spares","amount":0}]}]}}';  
     
            Map<string, object>  mapobj = (map<string,object>)json.deserializeuntyped(jsonTest);
            system.debug('the mapped functionality is :::'+ mapobj); 
           
           Object objj = (object)mapobj.get('data');
           system.debug('the data value is :::'+objj);
          
          string serilize = system.json.serialize(objj);
          system.debug('entered till here'+serilize);
                 
        wrapperclasswrap =(wrapperclass)system.json.deserialize(serilize,wrapperclass.class);
        system.debug(wrapperclasswrap.compName); 
   
   system.debug('=================second ========================');
    
        Map<string, object>  mapobj2 = (map<string,object>)json.deserializeuntyped(serilize);
         system.debug('the mapped functionality is :::'+ mapobj2); 
        
        Object objj2 = (object)mapobj2.get('SalesData');
          system.debug('the data value is :::'+objj2);
         
         string serilize2 = system.json.serialize(objj2 );
          system.debug('entered till here'+serilize2);
          
          wrapperclasswrapnameslst =(list<wrapperclass>)system.json.deserialize(serilize2 ,list<wrapperclass>.class);
             
             if(wrapperclasswrapnameslst !=null){
                system.debug(wrapperclasswrapnameslst[0].Name);
                  //system.debug(wrapperclasswrapnameslst[0].purchaselist[0].category);
                 }
            
      
       }
       
       
       public class wrapperclass{
       public string compName{get;set;}
       
        public string Name{get;set;}
        
        public string category{get;set;}
        
        public integer amount{get;set;}
        
        public list<purchaseddata> purchaselist{get;set;}
     
       public wrapperclass(){       
          purchaselist = new list<purchaseddata>();
        }
    }

     //wrapclass2
      
      public class purchaseddata{
      
       public string category{get;set;}
       
       public integer amount{get;set;}
      }

}


may i know, how to map the purchased data to the table, with category name and Amount to the table
1)taken purchaseddata as a wrapper, is it corect way? to map the data

Please provide ur valuable solutions

Thanks in Advance
Soumya sree
 
datetime dtm =system.today();
system.debug(dtm); //getting value as: 2020-07-16 00:00:00
string newdt = dtm.format('MM/dd/yy');
system.debug(newdt);  //getting value as : 07/15/20
after debugiing, i am getting the different values in the string with that date format, can any one solve this issue thank
instead of getting 07/16/20 iam getting 07/15/20.  
may i know the resson,,
need(mm/dd/yy) format only .. 

how can it solved 
thanks
soumya sree
i have a date of format:
   "Join_Date": "2020-06-16T00:00:00",

Datetime joindate ;
trying to convert it , but getting the different date, may i know the reason ,

i have tried with two ways. ho/ to convert to  06/16/2020 in stirng , i have tried differnety ways 
//String dateOutput = joindate.format('dd/MM/yyyy');
 
String myDate = string.valueOf(joindate );
but iam getting 06/15/2020  instead of 06/16/2020 .

please let me know where iam wrong, .. 

thanks
soumya




 
hi all, if i select any two two common names, need not to allow user check other same name, or unselect the other if selected other
Ex: If andhrapradesh is selected , again selected as andhrapradesh, need to unselect  the other andhrapradesh. 
please let me know the how can i proceed..
 or a boolean set to false..! 
Visual force page:
<apex:page controller="test3">
   <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"/>
       <apex:outputLabel id="two">{!listSelectedNames}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>

ApexClass:
 
public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<Wrapperclass> containslistcheck{get;set;}

  
  public test3(){
 listSelectedNames = new list<string>();
containslistcheck  = new list<Wrapperclass>(); 
 
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='AndhraPradesh';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='Telangana';
                                  
   Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='Chennai';
                
     Wrapperclass   wf3= new Wrapperclass();
                  wf3.selected=false;
                  wf3.name ='AndhraPradesh';
                  
                  
     Wrapperclass   wf4= new Wrapperclass();
                  wf4.selected=false;
                  wf4.name ='Karnataka';
                  
                  
     Wrapperclass   wf5 = new Wrapperclass();
                  wf5.selected=false;
                  wf5.name ='Telangana';            
                
          wraplist.add(wf);
          wraplist.add(wf1);
          wraplist.add(wf2);
          wraplist.add(wf3);
          wraplist.add(wf4);
         wraplist.add(wf5);
 }
 
 
   public void duplicatecheck(){
    listSelectedNames.clear();
   
    
    for(wrapperclass wrap: wraplist){
        if(wrap.selected == true){
           
            listSelectedNames.add(wrap.Name);
           
         }  
    }
    
    system.debug(listSelectedNames);
}


 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
    }
  
  
}

User-added image

any suggestions are welcomed.

Thanks 
Soumya sree
 
<img id="companyimage" src="data:image/png;base64,iVBORoC/IERYN;CEIHNFEIERCEIRENFA3xOA5Fv4==">
how to get image value as from above tag: iVBORoC/IERYN;CEIHNFEIERCEIRENFA3xOA5Fv4==
instead of  apex:inputfile, iam using the html image tab , for the  render attribute ,

how can i get the base 64value in the , frm the image tag, if iam calling the image value, iam getting the imagename.png in the javascript.

note:here this scenario not to use the apex:inputfile tag  as iam using the rerender attribute..

thanks 
soumya.
1.if iam not using  rerender, the image  is getting clear off by refreshing the page.
2.if iam using the Rerender attribute, iam getting the below error
apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.

how to handle the issue please givve me a suggestion , thank you..
 
<apex:page controller="InputfileExample">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<apex:form id="one" >
    Entername:<apex:inputText value="{!name}" id="name"/> <br/><br/>
    EnterBranch:<apex:inputText value="{!branch}" id="branch"/><br/><br/>
    ChooseFile:
   <apex:inputFile id="fileUplaod" value="{!uploadedfile}"  filename="{!filename}"  accept=".jpeg,.png,.jpg"> </apex:inputFile><br/><br/>
  
    <script>
      function callme(){
        var addname =$('[id$=name]').val(); 
        var branch =$('[id$=branch]').val();
         if(addname ==''){
            alert('name is required');
          }else if(branch ==''){
            alert('branch is required');
           }else{
              submitcall();
            }
       }
     </script>
  <apex:actionFunction name="submitcall" action="{!submit}"  /><!--reRender="one"-->
  <apex:commandButton value="Submit" onclick="callme(); return false;"  /><!--reRender="two"-->
  </apex:form>
</apex:page>

Controller:
public class InputfileExample {
 public blob uploadedfile{get;set;}
 public string filename{get;set;}
 public string name{get;set;}
 public string branch{get;set;}
  
   public void submit(){
    system.debug(name);
    system.debug(branch);
    system.debug(uploadedfile);
    system.debug(filename);
  }
}

if iam removing the rerender ,the image is getting clear form the visualforce page, after the page refreshes, can u please suggest me a solution for this.

thanks,
soumya reddy..!

 
hi guys i got below Error:
apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.

 
public class InputfileExample {
 public blob uploadedfile{get;set;}
 public string filename{get;set;}
 public string name{get;set;}
 public string branch{get;set;}
  
   public void submit(){
    system.debug(name);
    system.debug(branch);
    system.debug(uploadedfile);
    system.debug(filename);
  }
}

Visual Froce page:
<apex:page controller="InputfileExample">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<apex:form id="one" >
    Entername:<apex:inputText value="{!name}" id="name"/> <br/><br/>
    EnterBranch:<apex:inputText value="{!branch}" id="branch"/><br/><br/>
    ChooseFile:
   <apex:inputFile id="fileUplaod" value="{!uploadedfile}"  filename="{!filename}"  accept=".jpeg,.png,.jpg"> </apex:inputFile><br/><br/>
  
    <script>
      function callme(){
        var addname =$('[id$=name]').val(); 
        var branch =$('[id$=branch]').val();
         if(addname ==''){
            alert('name is required');
          }else if(branch ==''){
            alert('branch is required');
           }else{
              submitcall();
            }
       }
     </script>
  <apex:actionFunction name="submitcall" action="{!submit}"  reRender="one"/>
  <apex:commandButton value="Submit" onclick="callme();" RERender="T" />
  </apex:form>
</apex:page>
Please provide a solution for this ,
thanks 
soumya.
 
i have a duplicate list, and other list to check the duplicates.
code is correct, but need to check with the logic, can any one fix this issue please.
  //If i selected checkbox  A and B, i should get [false,true] //as A -letter is in the list.
//if selectd A, FALSE.
//if selectd B, TRUE.
public class test4 {

 public list<string>duplicatevalues{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<boolean> Selectedbooleanlist{get;set;}
  public list<string>listSelectedNames{get;set;}
 public test4(){
 listSelectedNames = new list<string>();
  Selectedbooleanlist= new list<boolean>();
  duplicatevalues= new list<string>{'a','c'}; 
  wraplist = new list<Wrapperclass>();
        Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='a';
                   wraplist.add(wf1);
        Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='b';
               wraplist.add(wf2);
               
 }
   public void check(){
  Selectedbooleanlist.clear();
     for(wrapperclass wrap: wraplist){
      if(wrap.selected == true){
        listSelectedNames.add(wrap.name);
        //Selectedbooleanlist.add(wrap.selected);
        }  
      }
   
    for(String s1 : duplicatevalues){
    if(listSelectedNames.contains(s1)){
     boolean  sel = false;
     Selectedbooleanlist.add(sel);
     }
     }
   }
  
  public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
    }
}

Vfpage:
<apex:page controller="test4" >
     <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one" action="{!check}"/>
       <apex:outputLabel id="one">{!Selectedbooleanlist}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
     
</apex:page>

THANKS
SOUMYA SREE
hi, i already have a Duplicate list<string>, with 'A'  and 'C'..,
and dymaniclist<string>'A','B','C' 

1)if i select a and c  list<boolean> should be =[true, true]; // a and c   already in duplicate list 
2)if i select a and b list<bolean> should be =[true, false]; // a is in duplicate list 
3)if i select a and b and  c list<bolean> should be =[true, false,true]; // and c in the duplicate list
 
<apex:page controller="test3">
   <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"/>
      <apex:outputLabel id="one">{!listSelectedNames}</apex:outputLabel>
       <apex:outputLabel id="two">{!Selectedbooleanlist}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>
 
public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<boolean> Selectedbooleanlist{get;set;}
 public list<string>duplicatevalues{get;set;}
  
  public test3(){
 listSelectedNames = new list<string>();
 Selectedbooleanlist= new list<boolean>();
 duplicatevalues= new list<string>{'a','c'}; //duplicated to filter
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='a';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='b';
                                  
   Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='c';
                
          wraplist.add(wf);
          wraplist.add(wf1);
          wraplist.add(wf2);
 }
 
 
   public void duplicatecheck(){
   listSelectedNames.clear();
   Selectedbooleanlist.clear();
    for(wrapperclass wrap: wraplist){
      if(wrap.selected == true){
    listSelectedNames.add(wrap.name);
    Selectedbooleanlist.add(wrap.selected);
        }  
      }
     
     //to check duplicate
     for(String s1 : duplicatevalues){
      if(listSelectedNames.contains(s1)){
         boolean selected =true;
    // Selectedbooleanlist.add(selected);
      //add logic 
       }
    } 
        
        }
 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
    }
  
  
}

 
<apex:page > <apex:outputLink value="{!URLFOR($Action.Attachment.Download, $Resource.test_pdf)}" target="_blank">Click Here to Download Pdf File</apex:outputLink> --> <apex:form > <apex:commandButton value="Downloadpdf"/> <apex:outputLink value="{!URLFOR($Resource.test_pdf)}" >Click Here to Download Pdf File</apex:outputLink> </apex:form> </apex:page>
need a button only , to download the pdf stored in the static Resource
note: instead of viewing need to download the file directly onclicking on the button
, Thanks 
soumya ... 
 
<apex:page >
   
   
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, $Resource.test_pdf)}" target="_blank">Click Here to Download Pdf File</apex:outputLink>
       -->

       <apex:form >
           <apex:commandButton value="Downloadpdf"/>

<apex:outputLink value="{!URLFOR($Resource.test_pdf)}" >Click Here to Download Pdf File</apex:outputLink>

        </apex:form>
        
</apex:page>

hi guys, how to download the pdf file using the static resource in salesforce, instead of viewing need to dowload the file in using the salesforce

thanks and regards
soumya sree
Hi, i have  uploaded multiple pdfs in StaticResource ,and need to download the pdf depending upon the button click ,
how can i download the file  , iam using the below apexpage , but cant able to download the file, its jst opening in the other page.,


 
<apex:page action="{!URLFOR($Resource.employepdf)}"  >
</apex:page>

Note:It is getting; open in the other page, but the thing is need to download the pdf , how can it done, please let me know 


Thanks and regards,
soumya sree.
 
public class OrignContrl {

  public decimal xvalue{get;set;}
  
   public decimal yvalue{get;set;}
   
   public string Totalcost{get;set;}
   
     public OrignContrl(){
      Totalcost ='Testing';
      }


    public void setvalues(){
    xvalue =48.05;
    yvalue =50.06;
   
     }
    
}

visualForce page:

 
<apex:page controller="OrignContrl" >
 <apex:form >
 <apex:commandButton value="Display in selected format" Action="{!setvalues}" />
 <apex:outputLabel >{!Totalcost}</apex:outputLabel>
 </apex:form>
</apex:page>

onclick on the button the values assigned to the particular outputlabel and display

thanks and regards
soumya reddy
datetime dtm =system.today();
system.debug(dtm); //getting value as: 2020-07-16 00:00:00
string newdt = dtm.format('MM/dd/yy');
system.debug(newdt);  //getting value as : 07/15/20
after debugiing, i am getting the different values in the string with that date format, can any one solve this issue thank
instead of getting 07/16/20 iam getting 07/15/20.  
may i know the resson,,
need(mm/dd/yy) format only .. 

how can it solved 
thanks
soumya sree
hi all, if i select any two two common names, need not to allow user check other same name, or unselect the other if selected other
Ex: If andhrapradesh is selected , again selected as andhrapradesh, need to unselect  the other andhrapradesh. 
please let me know the how can i proceed..
 or a boolean set to false..! 
Visual force page:
<apex:page controller="test3">
   <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"/>
       <apex:outputLabel id="two">{!listSelectedNames}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>

ApexClass:
 
public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<Wrapperclass> containslistcheck{get;set;}

  
  public test3(){
 listSelectedNames = new list<string>();
containslistcheck  = new list<Wrapperclass>(); 
 
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='AndhraPradesh';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='Telangana';
                                  
   Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='Chennai';
                
     Wrapperclass   wf3= new Wrapperclass();
                  wf3.selected=false;
                  wf3.name ='AndhraPradesh';
                  
                  
     Wrapperclass   wf4= new Wrapperclass();
                  wf4.selected=false;
                  wf4.name ='Karnataka';
                  
                  
     Wrapperclass   wf5 = new Wrapperclass();
                  wf5.selected=false;
                  wf5.name ='Telangana';            
                
          wraplist.add(wf);
          wraplist.add(wf1);
          wraplist.add(wf2);
          wraplist.add(wf3);
          wraplist.add(wf4);
         wraplist.add(wf5);
 }
 
 
   public void duplicatecheck(){
    listSelectedNames.clear();
   
    
    for(wrapperclass wrap: wraplist){
        if(wrap.selected == true){
           
            listSelectedNames.add(wrap.Name);
           
         }  
    }
    
    system.debug(listSelectedNames);
}


 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
    }
  
  
}

User-added image

any suggestions are welcomed.

Thanks 
Soumya sree
 
hi guys i got below Error:
apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.

 
public class InputfileExample {
 public blob uploadedfile{get;set;}
 public string filename{get;set;}
 public string name{get;set;}
 public string branch{get;set;}
  
   public void submit(){
    system.debug(name);
    system.debug(branch);
    system.debug(uploadedfile);
    system.debug(filename);
  }
}

Visual Froce page:
<apex:page controller="InputfileExample">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<apex:form id="one" >
    Entername:<apex:inputText value="{!name}" id="name"/> <br/><br/>
    EnterBranch:<apex:inputText value="{!branch}" id="branch"/><br/><br/>
    ChooseFile:
   <apex:inputFile id="fileUplaod" value="{!uploadedfile}"  filename="{!filename}"  accept=".jpeg,.png,.jpg"> </apex:inputFile><br/><br/>
  
    <script>
      function callme(){
        var addname =$('[id$=name]').val(); 
        var branch =$('[id$=branch]').val();
         if(addname ==''){
            alert('name is required');
          }else if(branch ==''){
            alert('branch is required');
           }else{
              submitcall();
            }
       }
     </script>
  <apex:actionFunction name="submitcall" action="{!submit}"  reRender="one"/>
  <apex:commandButton value="Submit" onclick="callme();" RERender="T" />
  </apex:form>
</apex:page>
Please provide a solution for this ,
thanks 
soumya.
 
hi, my code is working, fine. to check duplicates used contains method , 
if  exists iam getting true value, but i need to get the false value also if not in list , how can  i solve this issue ..

User-added image

need to add : false ,for the 'b' as it wont exists
Apex class:
public class test3{
 public list<string>listSelectedNames{get;set;}
 public list<Wrapperclass>wraplist{get;set;}
 public list<boolean> Selectedbooleanlist{get;set;}
 public list<string>duplicatevalues{get;set;}
  
  public test3(){
 listSelectedNames = new list<string>();
 Selectedbooleanlist= new list<boolean>();
 duplicatevalues= new list<string>{'a','c'}; //duplicated to filter
 wraplist = new list<Wrapperclass>();
   Wrapperclass   wf = new Wrapperclass();
                  wf.selected=false;
                  wf.name ='a';
                 
    Wrapperclass   wf1 = new Wrapperclass();
                  wf1.selected=false;
                  wf1.name ='b';
                                  
   Wrapperclass   wf2 = new Wrapperclass();
                  wf2.selected=false;
                  wf2.name ='c';
                
          wraplist.add(wf);
          wraplist.add(wf1);
           wraplist.add(wf2);
        
 }
 
 
   public void duplicatecheck(){
   listSelectedNames.clear();
   Selectedbooleanlist.clear();
    for(wrapperclass wrap: wraplist){
      if(wrap.selected == true){
    listSelectedNames.add(wrap.name);
        }  
      }
     
     //to check duplicate
     for(String s1 : duplicatevalues){
      if(listSelectedNames.contains(s1)){
        boolean selected =  true;
        Selectedbooleanlist.add(selected);
         
   
      //add logic 
       }
    } 
        
        }
 //wrapper classs
    public class Wrapperclass{
       public boolean selected{get;set;}
       public string Name{get;set;}
    }
  
  
}


Visualforce Page:

 
<apex:page controller="test3">
   <apex:form >
   <apex:pageBlock >
      <apex:pageblockTable value="{!wraplist}"  var="a">
       <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column>
       </apex:pageblockTable>
    <apex:commandButton value="OrderSelected"  reRender="one,two" action="{!duplicatecheck}"/>
      <apex:outputLabel id="one">{!listSelectedNames}</apex:outputLabel>
       <apex:outputLabel id="two">{!Selectedbooleanlist}</apex:outputLabel>
    </apex:pageBlock>
   </apex:form>
</apex:page>
//as it contains iam getting true, but to get false also if it dnt contains in the list of boolean
please help in this issue iam stucked
advance thanks
soumya yerava .