• Mahesh Babu 187
  • NEWBIE
  • 15 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Hi Team,

I am trying to display all search results in a wrapper class, but there's this error showing up every time I save the controller:

Error: Constructor not defined: [fetchserials.wrapperfetch].<Constructor>(Serial_Number__c)

The error points to this line of code:  serialNumbers.add(new wrapperfetch(a));

APEX CLASS

Public class fetchserials{
    
    Public string OrderID {get; set;}
    Public order OrderInstance {get; set;}
    Public List<OrderItem> OrderItemList {get; set;}
    Public Set<id> ProductIdSet {get; set;} //list to add product Ids
    Public list<Serial_Number__c> SerialList {get; set;}
    Public list<Serial_Number__c> SelectedSerialList {get; set;}
    Public Map<OrderItem,list<Serial_Number__c>> OrderVSerial{get; set;} // list to add OrderItem with their Serial Numbers
    Public List<wrapperfetch> fetchseriallist {get; set;}
    public Integer Counter;
    Public List<Order_Line_Item_Serials__c> insertordersn {get; set;} // list to add the selected orders
    public List<Serial_Number__c> serialNumbers;
    public string fullname{get;set;}
    public string finalSearchValue{get;set;}
   //ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.error,'Enter the List');
// ApexPages.addMessage(myMsg);
       Public fetchserials(){
        OrderItemList = new List<OrderItem>(); // intialize
        OrderVSerial = new Map<OrderItem,List<Serial_Number__c>>();
        fetchseriallist = new List<wrapperfetch>();
        insertordersn = new List<Order_Line_Item_Serials__c>();
        SelectedSerialList = new list<Serial_Number__c>();
        OrderID = ApexPages.currentPage().getParameters().get('Id'); //Getting the id of current order
        OrderInstance = [SELECT Id FROM Order where Id=:OrderID ];
        OrderItemList=[SELECT Id,OrderId,product2Id,PricebookEntry.Product2.Name, Quantity FROM OrderItem where OrderId =:OrderID];
        loadSerials();
    }
    //adding page reference of the current page
    public PageReference step1() {
        loadSerials();
      /*  if(SerialList==null){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 
                                                           'Please select the serial number'));
        } */
        return Page.fetchserials;
    }
    
    public PageReference cancel() {
        PageReference c=new PageReference('/'+OrderID);
        return c;
    }   
    
    Public void loadSerials(){
        ProductIdSet = new set<Id>();
        For(OrderItem items :OrderItemList){
            ProductIdSet.add(items.Product2Id);// order items products add into productidset 
        }
        SerialList = [SELECT Id,Serial_Number__c,Product_Name__c ,Name,Product__c,Status__c
                      FROM Serial_Number__c where Status__c=FALSE And Product__c In:ProductIdSet limit 200 ];
        
        
        /*if(SerialList == NULL)
{
SerialList.addError('There are no values in the Serials List.'); 
}*/
        // add error exception handling
        system.debug('Serialx' +SerialList );
        For(OrderItem item :OrderItemList){
            counter = 0;
            For(Serial_Number__c sn :SerialList ){
                If( sn.Product__c == item.Product2Id && counter < item.Quantity)
                {   SelectedSerialList = new list<Serial_Number__c>();
                    fetchseriallist.add(new wrapperfetch(sn,item));
                    SelectedSerialList.add(sn);
                    counter = counter +1; }
                else{continue;}
            }
            OrderVSerial.put(item,SelectedSerialList);
            /*=====
            try{
                if(SerialList == NULL ){ ApexPages.addMessages(e); }

catch (DMLException e){
    ApexPages.addMessages(myMsg);
    // Code for sending Email
}
            ============*/
        }
    }
    
    public pagereference Search()
    {
        String finalSearchValue = '%' + fullname + '%';
        serialNumbers = [Select Id, Serial_Number__c, Product_Name__c, Status__c FROM Serial_Number__c
                    where Name like :finalSearchValue];
        fetchseriallist = new list<wrapperfetch>();  
        for(Serial_Number__c a: serialNumbers)
        {
            serialNumbers.add(new wrapperfetch(a));
        }
       return null;
   }
    
    Public class wrapperfetch{
        Public Boolean selected {get; set;}
        Public Serial_Number__c sno{get; set;}
        Public string prodname {get; set;}
        Public OrderItem Oitem{get; set;}
        Public string serialno {get; set;}
        Public Boolean status {get; set;}
        Public Id stid {get; set;}
        Public Id opid {get; set;}
        
        Public wrapperfetch(Serial_Number__c sn,OrderItem Oi){
            //this.selected=check;
            this.Oitem= Oi;
            this.opid =Oi.Id;
            this.prodname =sn.Product_Name__c;
            this.sno=sn;
            this.serialno = sn.Serial_Number__c;
            this.status=sn.status__c;
            this.stid=sn.id;
            
            }
    }
    
    Public PageReference AddSerailNumbertoOrder(){
        
        for (wrapperfetch st: fetchseriallist ){
            
            If (st.selected == true ){
                Order_Line_Item_Serials__c ordersn= new Order_Line_Item_Serials__c();
                //Order_Line_Item_Serials__c make it to true
                //make a new Order_Line_Item_Serials__c list and make it to true.
                // put that into   ordersn.Serial_Number__c=st.stid;  a new list 
                ordersn.Serial_Number__c=st.stid;
                ordersn.Order_Product__c=st.opid;
                insertordersn.add(ordersn);
                
                Serial_Number__c  serials = new Serial_Number__c();
                serials.id = st.stid;
                serials.Status__c = TRUE;
                SelectedSerialList.add(serials);
            }
            if(SelectedSerialList == NULL){
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 
                                                           'Please select the serial number'));
            }
        }
        insert  insertordersn;
        update SelectedSerialList;
        PageReference orderpage = new PageReference('/'+OrderID);
        orderpage.setRedirect(true);
        orderpage.getParameters().put('myId', OrderID);
        return orderpage;
       
    }
}
-----------------------------------

VISUALFORCE Page

<apex:page controller="fetchserials" lightningstylesheets="true" readonly="true">
    <script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
     return false;
  }  
  </script>
<Apex:form >
<apex:pageBlock >
<apex:pageMessages id="showmsg"></apex:pageMessages>
    <apex:pageBlock>
        <apex:inputText value="{!fullname}" html-placeholder="Search" />
        <apex:commandButton value="search" action="{!Search}" />
    </apex:pageBlock>
  <apex:pageBlockTable value="{!fetchseriallist }" var="u"  style="width:100%">
    
  <apex:column headerValue="Select" > 
                        <Apex:inputcheckbox value="{!u.Selected}"  /> 
                    </apex:column>  
                    <apex:column headerValue="Serial Number" > 
                        <Apex:outputText value="{!u.serialno }"   /> 
                    </apex:column> 
                   <apex:column headerValue="Product Name" > 
                        <Apex:outputText value="{!u.prodname }"  /> 
                    </apex:column> 
                    <apex:column headerValue="Status" > 
                       <Apex:outputText value="{!u.status}"   />
                    </apex:column> 
  </apex:pageBlockTable>                  
  <apex:commandButton value="Add to Order" action="{!AddSerailNumbertoOrder}" style="margin-top: -2pt;" rerender="showmsg"/>
  <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true" id="cancel"/>

</apex:pageBlock>
  </Apex:form>
</apex:page>

Please help me to solve this issue.
Hi Team,

I am new to integration. I need to send PDF files from Salesforce to Netsuite when a checkbox is selected in Salesforce. I just know the approach that I need to convert the pdf to xml format in a restlet. But how to do this. 

Thanks in Advance 
Hi Team,

How to update child record's checkbox field value on parent record deletion using Lightning flow or trigger?
Hi, I got a question. If we upload data from a .csv file through data loader which has 500 rows and due to some error my data is uploaded till 100th row. Now I want to  upload my data from 101st row without again inserting from the starting. How could I do it?
Hi Team,

I am new to integration. I need to send PDF files from Salesforce to Netsuite when a checkbox is selected in Salesforce. I just know the approach that I need to convert the pdf to xml format in a restlet. But how to do this. 

Thanks in Advance 
Hi Team,

I am trying to display all search results in a wrapper class, but there's this error showing up every time I save the controller:

Error: Constructor not defined: [fetchserials.wrapperfetch].<Constructor>(Serial_Number__c)

The error points to this line of code:  serialNumbers.add(new wrapperfetch(a));

APEX CLASS

Public class fetchserials{
    
    Public string OrderID {get; set;}
    Public order OrderInstance {get; set;}
    Public List<OrderItem> OrderItemList {get; set;}
    Public Set<id> ProductIdSet {get; set;} //list to add product Ids
    Public list<Serial_Number__c> SerialList {get; set;}
    Public list<Serial_Number__c> SelectedSerialList {get; set;}
    Public Map<OrderItem,list<Serial_Number__c>> OrderVSerial{get; set;} // list to add OrderItem with their Serial Numbers
    Public List<wrapperfetch> fetchseriallist {get; set;}
    public Integer Counter;
    Public List<Order_Line_Item_Serials__c> insertordersn {get; set;} // list to add the selected orders
    public List<Serial_Number__c> serialNumbers;
    public string fullname{get;set;}
    public string finalSearchValue{get;set;}
   //ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.error,'Enter the List');
// ApexPages.addMessage(myMsg);
       Public fetchserials(){
        OrderItemList = new List<OrderItem>(); // intialize
        OrderVSerial = new Map<OrderItem,List<Serial_Number__c>>();
        fetchseriallist = new List<wrapperfetch>();
        insertordersn = new List<Order_Line_Item_Serials__c>();
        SelectedSerialList = new list<Serial_Number__c>();
        OrderID = ApexPages.currentPage().getParameters().get('Id'); //Getting the id of current order
        OrderInstance = [SELECT Id FROM Order where Id=:OrderID ];
        OrderItemList=[SELECT Id,OrderId,product2Id,PricebookEntry.Product2.Name, Quantity FROM OrderItem where OrderId =:OrderID];
        loadSerials();
    }
    //adding page reference of the current page
    public PageReference step1() {
        loadSerials();
      /*  if(SerialList==null){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 
                                                           'Please select the serial number'));
        } */
        return Page.fetchserials;
    }
    
    public PageReference cancel() {
        PageReference c=new PageReference('/'+OrderID);
        return c;
    }   
    
    Public void loadSerials(){
        ProductIdSet = new set<Id>();
        For(OrderItem items :OrderItemList){
            ProductIdSet.add(items.Product2Id);// order items products add into productidset 
        }
        SerialList = [SELECT Id,Serial_Number__c,Product_Name__c ,Name,Product__c,Status__c
                      FROM Serial_Number__c where Status__c=FALSE And Product__c In:ProductIdSet limit 200 ];
        
        
        /*if(SerialList == NULL)
{
SerialList.addError('There are no values in the Serials List.'); 
}*/
        // add error exception handling
        system.debug('Serialx' +SerialList );
        For(OrderItem item :OrderItemList){
            counter = 0;
            For(Serial_Number__c sn :SerialList ){
                If( sn.Product__c == item.Product2Id && counter < item.Quantity)
                {   SelectedSerialList = new list<Serial_Number__c>();
                    fetchseriallist.add(new wrapperfetch(sn,item));
                    SelectedSerialList.add(sn);
                    counter = counter +1; }
                else{continue;}
            }
            OrderVSerial.put(item,SelectedSerialList);
            /*=====
            try{
                if(SerialList == NULL ){ ApexPages.addMessages(e); }

catch (DMLException e){
    ApexPages.addMessages(myMsg);
    // Code for sending Email
}
            ============*/
        }
    }
    
    public pagereference Search()
    {
        String finalSearchValue = '%' + fullname + '%';
        serialNumbers = [Select Id, Serial_Number__c, Product_Name__c, Status__c FROM Serial_Number__c
                    where Name like :finalSearchValue];
        fetchseriallist = new list<wrapperfetch>();  
        for(Serial_Number__c a: serialNumbers)
        {
            serialNumbers.add(new wrapperfetch(a));
        }
       return null;
   }
    
    Public class wrapperfetch{
        Public Boolean selected {get; set;}
        Public Serial_Number__c sno{get; set;}
        Public string prodname {get; set;}
        Public OrderItem Oitem{get; set;}
        Public string serialno {get; set;}
        Public Boolean status {get; set;}
        Public Id stid {get; set;}
        Public Id opid {get; set;}
        
        Public wrapperfetch(Serial_Number__c sn,OrderItem Oi){
            //this.selected=check;
            this.Oitem= Oi;
            this.opid =Oi.Id;
            this.prodname =sn.Product_Name__c;
            this.sno=sn;
            this.serialno = sn.Serial_Number__c;
            this.status=sn.status__c;
            this.stid=sn.id;
            
            }
    }
    
    Public PageReference AddSerailNumbertoOrder(){
        
        for (wrapperfetch st: fetchseriallist ){
            
            If (st.selected == true ){
                Order_Line_Item_Serials__c ordersn= new Order_Line_Item_Serials__c();
                //Order_Line_Item_Serials__c make it to true
                //make a new Order_Line_Item_Serials__c list and make it to true.
                // put that into   ordersn.Serial_Number__c=st.stid;  a new list 
                ordersn.Serial_Number__c=st.stid;
                ordersn.Order_Product__c=st.opid;
                insertordersn.add(ordersn);
                
                Serial_Number__c  serials = new Serial_Number__c();
                serials.id = st.stid;
                serials.Status__c = TRUE;
                SelectedSerialList.add(serials);
            }
            if(SelectedSerialList == NULL){
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 
                                                           'Please select the serial number'));
            }
        }
        insert  insertordersn;
        update SelectedSerialList;
        PageReference orderpage = new PageReference('/'+OrderID);
        orderpage.setRedirect(true);
        orderpage.getParameters().put('myId', OrderID);
        return orderpage;
       
    }
}
-----------------------------------

VISUALFORCE Page

<apex:page controller="fetchserials" lightningstylesheets="true" readonly="true">
    <script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
     return false;
  }  
  </script>
<Apex:form >
<apex:pageBlock >
<apex:pageMessages id="showmsg"></apex:pageMessages>
    <apex:pageBlock>
        <apex:inputText value="{!fullname}" html-placeholder="Search" />
        <apex:commandButton value="search" action="{!Search}" />
    </apex:pageBlock>
  <apex:pageBlockTable value="{!fetchseriallist }" var="u"  style="width:100%">
    
  <apex:column headerValue="Select" > 
                        <Apex:inputcheckbox value="{!u.Selected}"  /> 
                    </apex:column>  
                    <apex:column headerValue="Serial Number" > 
                        <Apex:outputText value="{!u.serialno }"   /> 
                    </apex:column> 
                   <apex:column headerValue="Product Name" > 
                        <Apex:outputText value="{!u.prodname }"  /> 
                    </apex:column> 
                    <apex:column headerValue="Status" > 
                       <Apex:outputText value="{!u.status}"   />
                    </apex:column> 
  </apex:pageBlockTable>                  
  <apex:commandButton value="Add to Order" action="{!AddSerailNumbertoOrder}" style="margin-top: -2pt;" rerender="showmsg"/>
  <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true" id="cancel"/>

</apex:pageBlock>
  </Apex:form>
</apex:page>

Please help me to solve this issue.
Hi, I got a question. If we upload data from a .csv file through data loader which has 500 rows and due to some error my data is uploaded till 100th row. Now I want to  upload my data from 101st row without again inserting from the starting. How could I do it?