• Rakeeb
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 45
    Replies

HI,when i am uploading csv file in to custom object first it will check whether the data is existing r not in reseller__c object i.e based on the condition "Select Reseller_Region__c, Name, Id From Reseller__c where Reseller_category__c NOT IN('Distributor(T1)')'  "If the condition is satisfied  then it will update the records in Sales_Claim__c object.where i have to apply this condition in my code  i dont know .kindly let me know the solution asap.

apex:

public with sharing class uploadCSVcontroller {

        public String results   { get; set; }
        public Blob contentFile { get; set; }
        public String nameFile  { get; set; }
        public Integer rowCount { get; set; }
        public Integer colCount { get; set; }
 
        public pagereference Results() {
           
            List<List<String>> parsedCSV = new List<List<String>>();
           
          
           
            //Reseller__c Res = [Select Reseller_Region__c, Name, Id From Reseller__c where Reseller_category__c NOT IN('Distributor(T1)')];                 
            //System.debug('Res:'+Res);
           
          
            rowCount = 0;
            colCount = 0;
            if (contentFile != null){
                String fileString = contentFile.toString();
                parsedCSV = parseCSV(fileString, false);
               
                 rowCount = parsedCSV.size();
                System.debug('RowCount:'+rowCount);
               
                List<Sales_Claim__c> recs=new List<Sales_Claim__c>();
                //System.debug('RECS:'+recs);
              
                Integer rowCount=0;
               
               
               
                 for (List<String> row : parsedCSV)
                  {
                   Sales_Claim__c rec=new  Sales_Claim__c();
                  
                   recs.add(rec);
                   System.debug('recs1:'+recs);
                   for (String col : row)
                   {
                     rec.put('Reseller__c', row[0]);
                     rec.put('Quarter__c', row[1]);
                     System.debug('QA:'+row[1]);
                    
                     rec.put('Status__c', row[2]);
                    }
                   
                   }
                    
                     insert recs;
                     ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Successfully Uploaded' );
                     ApexPages.addMessage(myMsg);
                     //System.debug('Successfull Inserted:'+recs);
  
            }
            return null;
        }

      
        public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) {
            List<List<String>> allFields = new List<List<String>>();
            contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
            //System.debug('contents:'+contents);
            contents = contents.replaceAll('""','DBLQT');
            System.debug('contents:'+contents);
            List<String> lines = new List<String>();
            try {
              
                lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
             
            } catch (System.ListException e) {
                System.debug('Limits exceeded?' + e.getMessage());
            }
            Integer num = 0;
            for(String line: lines) {
                // check for blank CSV lines (only commas)
                if (line.replaceAll(',','').trim().length() == 0) break;
              
                List<String> fields = line.split(',');
                List<String> cleanFields = new List<String>();
                String compositeField;
                Boolean makeCompositeField = false;
                for(String field: fields) {
                    if (field.startsWith('"') && field.endsWith('"')) {
                        cleanFields.add(field.replaceAll('DBLQT','"'));
                    } else if (field.startsWith('"')) {
                        makeCompositeField = true;
                        compositeField = field;
                    } else if (field.endsWith('"')) {
                        compositeField += ',' + field;
                        cleanFields.add(compositeField.replaceAll('DBLQT','"'));
                        makeCompositeField = false;
                    } else if (makeCompositeField) {
                        compositeField +=  ',' + field;
                    } else {
                        cleanFields.add(field.replaceAll('DBLQT','"'));
                    }
                }
              
                allFields.add(cleanFields);
            }
            if (skipHeaders) allFields.remove(0);
            System.debug('allFields:'+allFields);
            return allFields;
                
        }

    }

 

Vpage:

<apex:page controller="uploadCSVcontroller" >
<apex:pageBlock >
 <apex:message />
      <apex:form >
      <apex:inputFile value="{!contentFile}" filename="{!nameFile}" /><br/>
      <apex:commandButton value="Upload" action="{!Results}" id="theButton"/>
      </apex:form>
    </apex:pageBlock>
      <apex:outputPanel id="results">
      <p>Filename: {!nameFile}</p>
      <p>TotalRecords: {!rowCount}</p>
     
        <table title="CSV Output" border="1" width="100%">
           <apex:repeat value="{!results}" var="row">
               <tr>
                   <apex:repeat value="{!row}" var="cell">
                       <td> {!cell} </td>
                   </apex:repeat>
               </tr>
           </apex:repeat>
         </table>
      </apex:outputPanel>
     
      </apex:page>

Hi,I have one scenario like i want to upload the  csv file (csv contains same fields in custom object)and insert in to custom objects using apex coding how can i do that ?without using dataloader and import wizard.Suppose if it is not possible in apex ,otherwise if you know any app in appexchange kindly let me know the solution asap.

HI,while installing the package, getting this error as follows

"The requested package does not exist or has been deleted. Please contact the package publisher for assistance. If this is a recently uploaded package, please try again soon". Kindly let me know asap.


Hi All,here i have one scenario like ,

i have one custom button like "Approved" and Is enabled (checkbox) in custom object.When the user click the approve buttom then only Is enabled (checkbox) will be checked otherwise it should be in unchecked. so how can i do validation kindly let me know ASAP.

 

Thanks

Hi All,here i have one scenario like ,

i have one custom button like "Approved" and Is enabled (checkbox) in custom object.When the user click the approve buttom then only Is enabled (checkbox) will be checked otherwise it should be in unchecked. so how can i do validation kindly let me know ASAP.

 

Thanks

  Hi Guys, i have one scenario  like ,i have custom object with custom fields and i want insert csv file data in to custom object(with hard code) and how can i do that without using dataloader and documents .Any apps  is available in appexchage?If it available let me know the app. so kindly let me know the solution ASAP .

 

Thanks,

Hi,i have 3 custom objects like produt groups,product sub group and products-

1)Product groups contains multiple product subgroups

2)Product sub groups contains multiple products.

In reports if i select product groups then it should display the list of product sub group details and product details.But it is like heirarichal form and also i should not take a lookup(direct relationship) from product groups in to products

Here how can i create a relationship so kindly let me know ASAP.

 

Thanks,

  Hi Guys, i have one scenario  like ,i have custom object with custom fields and i want insert csv file data in to custom object and how can i do that without using dataloader and documents so kindly let me know ASAP any solution ..

Hi,can any one let me know How to define unique value for picklist ?

HI, i have checkbox and text dataype i.e status and points, if the status is active then it will enable the point textbox otherwise it should be disable the textbox (points) ,so how can i do the validation so kindly let me know ASAP.

HI, i have checkbox and text dataype i.e status and points, if the status is active then it will enable the point text field  otherwise it should be disable the textbox (points) ,so how can i do the validation so kindly let me know ASAP.

I am designing a app for my client which has to capture lot of information which is out of Standard Objects implementation. So I started creating Custom Objects to fulfill the needs. I need a suggestion on whether my approach is correct or wrong - before I design all my Objects. Example:

Requirement: I have Partners Objects which has multiple contacts and each of the contact will have multiple addresses. I have created the following Objects to address the functionality

Partners, Contacts (Used Standard), Address, City, State and Country

--Partners will have Contacts lookup

--Contacts has Address lookup

--Address has City lookup

--City has State and State has Country lookup



How can i enable new button in campaign standard object?i want create new campaign so how can i do that .kindly let me know asap

HI, i want pass uername and password of salesforce and along with details list page of custom object so i can i do that ,here i have example .

PageReference obj1 = new PageReference('https://www.salesforce.com/login.jsp?pw=test&un=test@gmail.com');

return obj1;

But i want to pass  along with this https://ap1.salesforce.com/a00/o so how can i do that kindly let me know asap.

Hi,How many users license we can have in partner portal and also cost, limitations so kindly let me asap.

Hi,i want create managed package in developer edition so how can i change developer setting for managed package  so kindly let me know the solution ASAP.

 

 

 

HI, Can anyone tell me ,why we go to partner portal and how many developers can we create and let me know features of that  ASAP.

 

 

 

 

HI, Can anyone explain  about how salesforce crm works in cloudcomputing and  let me know the solution.

Kindly let me know validation rule for username and password on custom object?

HI, how can i create custom field for password on custom object and the letter should be like * .so kindly let me know with example

HI, i want pass uername and password of salesforce and along with details list page of custom object so i can i do that ,here i have example .

PageReference obj1 = new PageReference('https://www.salesforce.com/login.jsp?pw=test&un=test@gmail.com');

return obj1;

But i want to pass  along with this https://ap1.salesforce.com/a00/o so how can i do that kindly let me know asap.

Hi,I have one scenario like i want to upload the  csv file (csv contains same fields in custom object)and insert in to custom objects using apex coding how can i do that ?without using dataloader and import wizard.Suppose if it is not possible in apex ,otherwise if you know any app in appexchange kindly let me know the solution asap.

HI,while installing the package, getting this error as follows

"The requested package does not exist or has been deleted. Please contact the package publisher for assistance. If this is a recently uploaded package, please try again soon". Kindly let me know asap.


Hi All,here i have one scenario like ,

i have one custom button like "Approved" and Is enabled (checkbox) in custom object.When the user click the approve buttom then only Is enabled (checkbox) will be checked otherwise it should be in unchecked. so how can i do validation kindly let me know ASAP.

 

Thanks

HI, i have checkbox and text dataype i.e status and points, if the status is active then it will enable the point textbox otherwise it should be disable the textbox (points) ,so how can i do the validation so kindly let me know ASAP.

Hello all. I'm having an issue with my Visualforce controller code and was wondering if anyone had any ideas for me.

The error I'm receiving is:
Code:
System.Exception: DML currently not allowed

Class.maExtension.save: line 18, column 13
External entry point
 
My controller code is:
Code:
public class maExtension {

 public scr__c scr {get; private set;}

 public maExtension() {
  scr = new scr__c();
 }

 public pagereference save() {
  scr.market_area__c = getmarket().id;
  system.debug('Market ID: ' + scr.market_area__c);
  system.debug('First Name: ' + scr.first_name__c);
  system.debug('Last Name: ' + scr.last_name__c);
  system.debug('Full Address: ' + scr.street_1__c + 
   ' ' + scr.street_2__c + ' ' + scr.city__c + 
   ' ' + scr.state__c + ' ' + scr.zip_code__c);
  try {
   insert scr;
   system.debug('Insert Successful');
  } catch(System.DmlException e) {
   system.debug(e.getDmlMessage(0));
  }
  return null;
 }

 ma__c market;

 public string getzip() {
  string zip = apexpages.currentpage().getparameters().get('zip');
  return zip;
 }

 public string getaddress() {
  string address = apexpages.currentpage().getparameters().get('street');
  return address;
 }

 public string getcity() {
  string city = getmarket().name;
  return city;
 }

 public string getstate() {
  string state = getmarket().primary_state__c;
  return state;
 }

 public boolean getmarketexists() {
  string zip = getzip();
  integer count = [select count() 
  from ma__c 
  where primary_zip_code__c = :zip 
  limit 1];
  boolean marketexists = count > 0 ? true : false;
  return marketexists;
 }

 public boolean getmarkethascoverage() {
  string zip = getzip();
  integer count = [select count() 
  from ma__c 
  where primary_zip_code__c = :zip 
  and (status__c = 'Partial Coverage' or status__c = 'Full Coverage') 
  limit 1];
  boolean getmarkethascoverage = count > 0 ? true : false;
  return getmarkethascoverage;
 }

 public ma__c getmarket() {
  if (getmarketexists() == true) {
   string zip = getzip();
   market = [select id, name, primary_zip_code__c, primary_state__c, status__c 
   from ma__c 
   where primary_zip_code__c = :zip 
   limit 1];
  } else {
   market = new ma__c();
  }
  return market;
 }

}
 
My Visualforce Page is:
Code:
 <apex:form id="scrform">
  <apex:inputfield id="scrfirstname" value="{!scr.first_name__c}" />First Name<br />
  <apex:inputfield id="scrlastname" value="{!scr.last_name__c}" />Last Name<br />
  <apex:inputfield id="scremail" value="{!scr.email_address__c}" />Email<br />
  <apex:inputfield id="scrstreet1" value="{!scr.street_1__c}" />Street Address 1<br />
  <apex:inputfield id="scrstreet2" value="{!scr.street_2__c}" />Street Address 2<br />
  <apex:inputfield id="scrcity" value="{!scr.city__c}" />City<br />
  <apex:inputfield id="scrstate" value="{!scr.state__c}" />State<br />
  <apex:inputfield id="scrzip" value="{!scr.zip_code__c}" />Zip Code<br />
  <apex:commandbutton action="{!save}" value="Sign Me Up" /><br />
 </apex:form>

When the "Sign Me Up" button invoking the save() method is clicked, I receive the exception. Any help would be greatly appreciated. Thanks!
  • October 21, 2008
  • Like
  • 0