• Peace
  • NEWBIE
  • 50 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 14
    Replies

Hi all,

I need a simple help !!

Data in 'Billing City' and 'Shipping City' field of 'Account' object contains line breaks.

eg.  345 Shoreline Park
     Mountain View, CA 94043
     USA

 I want a code to fetch data of these two fields and and format it as below

345 Shoreline Park, Mountain View, CA 94043, USA    (ie.  in a single line and Line breaks to be replaced with comma)

 Thanks in advance !

  • September 12, 2013
  • Like
  • 0

Hi

Please help me in implementing following :

I dynamically create 'Select' query to fetch data from an object, as shown below

Public PageReference FetchObjectContents() {
 
     
      String query = 'SELECT...';

    
       ObjectContents = database.query(query);
    
 system.debug('----ObjectContents-------' +ObjectContents);
 
 
 //Converting Query result to String
 String str = '';

for (SObject a : ObjectContents) {
    
    str += String.valueOf(a) + '\n';
}
}

  OUTPUT  something like :

Account:{Name=Burlington Coat Factory, Id=001T000000pSG6rIAF}
Account:{Name=General Motors, Id=001T000000pSf4cAIR}
...

 I want OUTPUT as follows,  ie. without Object name and Field name  ( only field values )
 
 'Burlington Coat Factory', 001T000000pSG6rIAF  
 'General Motors', 001T000000pSf4cAIR



OR is there any other way to fetch only field values dynamically.

 

Thanks in advance!!

  • August 22, 2013
  • Like
  • 0

Hi,

I am new to apex, please help me implementing following simple scenario:

I have a picklist on VisualForce page and a command button.

 Select Object <apex:selectList required="true" multiselect="false" size="1" label="Type"  value="{!selectedValue}">
    
  <apex:selectOptions value="{!Items}"/>
  </apex:selectList>     
<apex:commandButton action="{!ReadContents}" value="Next" id="theButton" /> 

 Controller:

global class FetchRecords {

public static string selectedValue{get;set;}  //contains the object selected from picklist.

   public List<SelectOption> getItems()
    {
    // Code to populate picklist values, comes here
    return options1;
     }


 webservice static List < SObject > ReadContents() {
 
 List < SObject > ObjectContents; 
 
    query += 'select ...';
       ObjectContents = database.query(query);
    
return ObjectContents;
 }
 }

  
 I am getting Compile Error: The property String selectedValue is referenced by Visualforce Page (FetchRecords) in salesforce.com. Remove the usage and try again
 
 Please help to resolve above error.

 

  • August 12, 2013
  • Like
  • 0


Hi,

I am new to apex, Please help in following scenario.

I select an object name from Picklist and this object name gets stored in a variable.

and then dynamically records are inserted into this object.

After the insertion / updation of these records, i want to fetch value from 'Created By' and 'Last Modified By' system fields of these records and display it on VisualForce page dynamically.

  • July 25, 2013
  • Like
  • 0


Hi,

I am new to apex.  

I am trying to perform upsert operation using an external id
What changes should i make in below code, so that the following error will be resolved.
Error: "Upsert with a field specification requires a concrete SObject type"


List<SObject> accstoupload;
accstoupload = new List<SObject>();


 //Code to fetch external_id Field names for the Selected object
 Schema.SObjectType targetType = Schema.getGlobalDescribe().get(selectedValue); //Selected value is the object name selected from picklist
 Map<String, Schema.SObjectField> M = targetType.getDescribe().fields.getMap();
       
         for (String k : M.keySet())
          {
          if(M.get(k).getDescribe().isExternalID())
           {
            externalIdFields.add(k);
            
           }
            }
         
     // code to upsert
                      
        for( Integer j = 0; j < externalIdFields.size(); j++) {
          
         
 try{
        upsert accstoupload externalIdFields; // Getting error on this line
        }
catch (Exception e)
       {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
           ApexPages.addMessage(errormsg);
        }     
         }

Please help.

  • July 03, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce. Please help me in implementing following

 

In my Apex code, i have name of selected object in a Variable
I need a piece of code which returns name of the fields which are external ids in that selected object.

 

 

  • June 28, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce.  Please help me in implementing upsert functionality:

 

I have implemented functionality to insert records from 'csv file' to 'Salesforce Standard and Custom objects'.

Now, when i try to insert those records again after few changes, i want that missing records should be inserted and existing records should be updated using the external id,  ie. UPSERT functionality.

 

Please provide me steps to implement this, and apex code if any?

 

Thanks

  • June 25, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce. I have a doubt..

 

Can we fetch only those standard objects which are usually displayed as tabs on home page such as Campaigns, Leads, Contacts, Accounts, Opportunities, Forecasts, etc.  Without hardcoding names of the object in Code.

Is it possible?

 

Please help

  • June 04, 2013
  • Like
  • 0

Hi,

 

Iam new to salesforce. I have a simple query.

 

Below code returns all the custom and standard objects.

 

How should i modify it,  so that it returns all the custom objects and only three standard object (viz.  Accounts, Leads and Contacts)

 

 public List<SelectOption> getItems()

    {
    for ( Schema.SObjectType typ : Schema.getGlobalDescribe().values() )
    {
        String sobjName = String.valueOf(typ);
        if ( sobjName.contains('__c')  || (!sobjName.contains('__c')))
        {
            stdObjectNames.add(sobjName);
            options1.add(new SelectOption(sobjName,sobjName));
           
        }
    }
    
       return options1;

     }

  If i manually add object as below, then it won't fetch actual "Accounts"  object details

     options1.add(new SelectOption('Accounts','Accounts'));

Please help..

  • May 30, 2013
  • Like
  • 0

Hi,

 

I am new to salesforce. i have a simple query. Please help.

 

i have a listbox containing 10 values.  The value i select is stored in 'selectedValue' variabe.

 

now i have to create an object for this selected value in apex.

 

How can i dynamically create objects ?

 

  • May 29, 2013
  • Like
  • 0

Hi.

 

I am new to salesforce.  Please can anyone help me in following issue.

 

My VF page Reads a CSV file and displays its field names on clicking command button

 

 <apex:inputFile value="{!contentFile}" filename="{!nameFile}" />

 <apex:commandButton action="{!ReadFile}" value="Next" id="theButton">

 

Controller:

public string nameFile{get;set;}
 public Blob contentFile{get;set;}
 String[] filelines = new String[]{};
 String[] HeaderXLS = new String[]{};

 public Pagereference ReadFile()
    {
     

        nameFile=contentFile.toString();
        filelines = nameFile.split('\n');
       
    
        for (Integer i=1;i<filelines.size();i++)
        {
            String[] inputvalues = new String[]{};
            inputvalues = filelines[i].split(',');
             HeaderXLS = filelines[0].split(',');
               length = HeaderXLS.size();
         }      
               for(Integer j=0;j<HeaderXLS.size();j++)
               {
                options.add(HeaderXLS[j]);
                
               }
 PageReference page2 = new PageReference('/apex/Mapping'); <!-- Mapping is the page on which field names are displayed -->
     
     page2.setRedirect(false);
      return page2;
    }

 

 It displays all the field names in a single row.   i want it to display one field name per row.

 

Mapping page:

<apex:repeat value="{!list}" rows="{!Number}" var="c">
                                                       
 <apex:outputText value=" {0} ">
       <apex:param value="{!Header}"/>
        </apex:outputText>
</apex:repeat>

 Number of Rows are equal to the number of Fields

 

  • May 28, 2013
  • Like
  • 0

Hi,

 

I am new to salesforce.  Please help me in implementing following requirement

 

There will be one Textbox containing a value (eg. First Name)

And there will be a Picklist which will have certain Values (eg. Name, Age, Current City etc. )

 

Now depending on the value in the Textbox, i want the picklist to show relevant default selected value

( If Textbox has value as 'First Name' then picklist should show default value as ' Name'

 

if Textbox has Value as 'City' then picklist's default value should be 'Current City')

)

 

 

 

 

  • May 27, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce, I have a query,  Please look into following scenario:

I made a VF page containing 'n' number of listboxes.

Each list box shows all the field names from a CSV file, and the first field name remains the default selected value for each list box (ie. All the list boxes are having same default value)

 

Number of list boxes are equal to number of fields in CSV file.

 

I want each list box to have a different field name as default selected value

 

Can anyone please help ?

 

 

 

 

  • May 24, 2013
  • Like
  • 0

Hi,

 

i am new to salesforce. i hv a simple doubt:

 

 

 public PageReference GotoCSV() {
 
  if (selectedValue == 'FlatFile')
            {        
  PageReference newpage = new PageReference('/apex/UploadAccounts1');

           newpage.setRedirect(true);
           return newpage; 
}
    }

 

i want to display 'UploadAccounts1' page when user selects 'FlatFile' from the dropdown list and clicks the command button.  however m getting following error in the controller   "Non-void method might not return a value or might have statement after a return statement"

 

 

this is my VF page:

<apex:form >
        &nbsp;&nbsp; <font color='grey'> Connection type &nbsp;&nbsp;  </font><apex:selectList id="chooseColor" value="{!string}" size="1">
         <apex:selectOption itemValue="Any connection type" itemLabel="- - Any connection type - -"/>
         <apex:selectOption itemValue="FlatFile" itemLabel="Flat File"/>
                 <apex:selectOption itemValue="SQLServer2008" itemLabel="SQL Server 2008"/>
            <apex:selectOption itemValue="MsAccess" itemLabel="MS Access"/>
        </apex:selectList>

<apex:commandButton action="{!GotoCSV}" value="Create Connection" id="theBtn1" style="width:100px; height: 25px;"/>     
</apex:form>

 

Can anyone please provide a solution

  • May 22, 2013
  • Like
  • 0

Hi

Please help me in implementing following :

I dynamically create 'Select' query to fetch data from an object, as shown below

Public PageReference FetchObjectContents() {
 
     
      String query = 'SELECT...';

    
       ObjectContents = database.query(query);
    
 system.debug('----ObjectContents-------' +ObjectContents);
 
 
 //Converting Query result to String
 String str = '';

for (SObject a : ObjectContents) {
    
    str += String.valueOf(a) + '\n';
}
}

  OUTPUT  something like :

Account:{Name=Burlington Coat Factory, Id=001T000000pSG6rIAF}
Account:{Name=General Motors, Id=001T000000pSf4cAIR}
...

 I want OUTPUT as follows,  ie. without Object name and Field name  ( only field values )
 
 'Burlington Coat Factory', 001T000000pSG6rIAF  
 'General Motors', 001T000000pSf4cAIR



OR is there any other way to fetch only field values dynamically.

 

Thanks in advance!!

  • August 22, 2013
  • Like
  • 0


Hi,

I am new to apex.  

I am trying to perform upsert operation using an external id
What changes should i make in below code, so that the following error will be resolved.
Error: "Upsert with a field specification requires a concrete SObject type"


List<SObject> accstoupload;
accstoupload = new List<SObject>();


 //Code to fetch external_id Field names for the Selected object
 Schema.SObjectType targetType = Schema.getGlobalDescribe().get(selectedValue); //Selected value is the object name selected from picklist
 Map<String, Schema.SObjectField> M = targetType.getDescribe().fields.getMap();
       
         for (String k : M.keySet())
          {
          if(M.get(k).getDescribe().isExternalID())
           {
            externalIdFields.add(k);
            
           }
            }
         
     // code to upsert
                      
        for( Integer j = 0; j < externalIdFields.size(); j++) {
          
         
 try{
        upsert accstoupload externalIdFields; // Getting error on this line
        }
catch (Exception e)
       {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
           ApexPages.addMessage(errormsg);
        }     
         }

Please help.

  • July 03, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce. Please help me in implementing following

 

In my Apex code, i have name of selected object in a Variable
I need a piece of code which returns name of the fields which are external ids in that selected object.

 

 

  • June 28, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce.  Please help me in implementing upsert functionality:

 

I have implemented functionality to insert records from 'csv file' to 'Salesforce Standard and Custom objects'.

Now, when i try to insert those records again after few changes, i want that missing records should be inserted and existing records should be updated using the external id,  ie. UPSERT functionality.

 

Please provide me steps to implement this, and apex code if any?

 

Thanks

  • June 25, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce. I have a doubt..

 

Can we fetch only those standard objects which are usually displayed as tabs on home page such as Campaigns, Leads, Contacts, Accounts, Opportunities, Forecasts, etc.  Without hardcoding names of the object in Code.

Is it possible?

 

Please help

  • June 04, 2013
  • Like
  • 0

Hi,

 

Iam new to salesforce. I have a simple query.

 

Below code returns all the custom and standard objects.

 

How should i modify it,  so that it returns all the custom objects and only three standard object (viz.  Accounts, Leads and Contacts)

 

 public List<SelectOption> getItems()

    {
    for ( Schema.SObjectType typ : Schema.getGlobalDescribe().values() )
    {
        String sobjName = String.valueOf(typ);
        if ( sobjName.contains('__c')  || (!sobjName.contains('__c')))
        {
            stdObjectNames.add(sobjName);
            options1.add(new SelectOption(sobjName,sobjName));
           
        }
    }
    
       return options1;

     }

  If i manually add object as below, then it won't fetch actual "Accounts"  object details

     options1.add(new SelectOption('Accounts','Accounts'));

Please help..

  • May 30, 2013
  • Like
  • 0

Hi,

 

I am new to salesforce. i have a simple query. Please help.

 

i have a listbox containing 10 values.  The value i select is stored in 'selectedValue' variabe.

 

now i have to create an object for this selected value in apex.

 

How can i dynamically create objects ?

 

  • May 29, 2013
  • Like
  • 0

Hi.

 

I am new to salesforce.  Please can anyone help me in following issue.

 

My VF page Reads a CSV file and displays its field names on clicking command button

 

 <apex:inputFile value="{!contentFile}" filename="{!nameFile}" />

 <apex:commandButton action="{!ReadFile}" value="Next" id="theButton">

 

Controller:

public string nameFile{get;set;}
 public Blob contentFile{get;set;}
 String[] filelines = new String[]{};
 String[] HeaderXLS = new String[]{};

 public Pagereference ReadFile()
    {
     

        nameFile=contentFile.toString();
        filelines = nameFile.split('\n');
       
    
        for (Integer i=1;i<filelines.size();i++)
        {
            String[] inputvalues = new String[]{};
            inputvalues = filelines[i].split(',');
             HeaderXLS = filelines[0].split(',');
               length = HeaderXLS.size();
         }      
               for(Integer j=0;j<HeaderXLS.size();j++)
               {
                options.add(HeaderXLS[j]);
                
               }
 PageReference page2 = new PageReference('/apex/Mapping'); <!-- Mapping is the page on which field names are displayed -->
     
     page2.setRedirect(false);
      return page2;
    }

 

 It displays all the field names in a single row.   i want it to display one field name per row.

 

Mapping page:

<apex:repeat value="{!list}" rows="{!Number}" var="c">
                                                       
 <apex:outputText value=" {0} ">
       <apex:param value="{!Header}"/>
        </apex:outputText>
</apex:repeat>

 Number of Rows are equal to the number of Fields

 

  • May 28, 2013
  • Like
  • 0

Hi,

 

I am new to Salesforce, I have a query,  Please look into following scenario:

I made a VF page containing 'n' number of listboxes.

Each list box shows all the field names from a CSV file, and the first field name remains the default selected value for each list box (ie. All the list boxes are having same default value)

 

Number of list boxes are equal to number of fields in CSV file.

 

I want each list box to have a different field name as default selected value

 

Can anyone please help ?

 

 

 

 

  • May 24, 2013
  • Like
  • 0

Hi,

 

i am new to salesforce. i hv a simple doubt:

 

 

 public PageReference GotoCSV() {
 
  if (selectedValue == 'FlatFile')
            {        
  PageReference newpage = new PageReference('/apex/UploadAccounts1');

           newpage.setRedirect(true);
           return newpage; 
}
    }

 

i want to display 'UploadAccounts1' page when user selects 'FlatFile' from the dropdown list and clicks the command button.  however m getting following error in the controller   "Non-void method might not return a value or might have statement after a return statement"

 

 

this is my VF page:

<apex:form >
        &nbsp;&nbsp; <font color='grey'> Connection type &nbsp;&nbsp;  </font><apex:selectList id="chooseColor" value="{!string}" size="1">
         <apex:selectOption itemValue="Any connection type" itemLabel="- - Any connection type - -"/>
         <apex:selectOption itemValue="FlatFile" itemLabel="Flat File"/>
                 <apex:selectOption itemValue="SQLServer2008" itemLabel="SQL Server 2008"/>
            <apex:selectOption itemValue="MsAccess" itemLabel="MS Access"/>
        </apex:selectList>

<apex:commandButton action="{!GotoCSV}" value="Create Connection" id="theBtn1" style="width:100px; height: 25px;"/>     
</apex:form>

 

Can anyone please provide a solution

  • May 22, 2013
  • Like
  • 0