• Sandy Gali
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 16
    Questions
  • 24
    Replies
Hi Guys,
              I am trying to find duplicate accounts in the system and trying to merge them based on our filter criteria using apex. The issue is I am hitting the governor limit of 150 DML statements while doing this.
We will have to put the merge statement inside the loop as we need the parent and child as the parameters in the merge statement. I don't think we can bulkify Merge like other DML statements due to the above reason. I am not sure if there is any better way to do it and avoid hitting governor limits.
Any help in this regard would be greatly appreciated.
Hi All, 
         I am getting the below error when I trying to use a
dataloader CLI. I have followed the Salesforce documentation and this blog
http://www.jitendrazaa.com/blog/salesforce/tutorial-of-command-line-dataloader-salesforce/

I am not able to figure out what the issue is  and any help would be greatly appreciated

CONFIG.properties
#Tue Oct 11 2016
sfdc.debugMessages=true

process.encryptionKeyFile=C:\Users\SF\Desktop\CLI\Key.txt
sfdc.debugMessagesFile =C:\Users\SF\Desktop\CLI\logfile.log
sfdc.endpoint=https://test.salesforce.com
sfdc.username=<myusername>
sfdc.password=<encrypted password>
sfdc.proxyUsername=
sfdc.proxyPassword=
sfdc.proxyHost=
sfdc.proxyPort=
sfdc.loadBatchSize=200
sfdc.timeoutSecs=600

process-conf.xml

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="Account"
    class="com.salesforce.dataloader.process.ProcessRunner"
    singleton="false">
        <description>Export Account Data</description>
        <property name="name" value="Account"/>
        <property name="configOverrideMap">
        <map>
            <entry key="sfdc.enableLastRunOutput" value="false"/>
            <entry key="sfdc.debugMessagesFile" value="C:\Users\SF\Desktop\CLI\sfdcSoapTrace.log"/>
            <entry key="sfdc.endpoint" value="https://test.salesforce.com"/>
            <entry key="sfdc.username" value="<username>"/>
            <entry key="sfdc.password" value="<encrypted password>"/>
            <entry key="sfdc.entity" value="Account"/>
            <entry key="process.operation" value="extract"/>
            <entry key="sfdc.extractionRequestSize" value="500"/>
            <entry key="sfdc.extractionSOQL" value="SELECT Id FROM Account"/>
            <entry key="dataAccess.name" value="C:\Users\SF\Desktop\CLI\AccountExport.csv"/>
            <entry key="dataAccess.type" value="csvWrite"/>
            <entry key="dataAccess.writeUTF8" value="true" />
        </map>
        </property>
    </bean>
</beans>


ERROR

2016-10-11 17:00:35,599 INFO  [main] controller.Controller initLog (Controller.j
ava:389) - Using built-in logging configuration, no log-conf.xml in C:\Program F
iles (x86)\salesforce.com\Data Loader\bin\log-conf.xml
2016-10-11 17:00:35,603 INFO  [main] controller.Controller initLog (Controller.j
ava:391) - The log has been initialized
2016-10-11 17:00:35,606 INFO  [main] process.ProcessConfig getBeanFactory (Proce
ssConfig.java:104) - Loading process configuration from config file: C:\Users\sg
387088\Desktop\CLI\process-conf.xml
2016-10-11 17:00:35,656 INFO  [main] support.AbstractApplicationContext prepareR
efresh (AbstractApplicationContext.java:495) - Refreshing org.springframework.co
ntext.support.FileSystemXmlApplicationContext@cd5f8b: startup date [Tue Oct 11 1
7:00:35 EST 2016]; root of context hierarchy
2016-10-11 17:00:35,683 INFO  [main] xml.XmlBeanDefinitionReader loadBeanDefinit
ions (XmlBeanDefinitionReader.java:315) - Loading XML bean definitions from file
 [C:\Users\SF\Desktop\CLI\process-conf.xml]
2016-10-11 17:00:35,711 INFO  [main] support.DefaultListableBeanFactory preInsta
ntiateSingletons (DefaultListableBeanFactory.java:557) - Pre-instantiating singl
etons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15
3c375: defining beans [Account]; root of factory hierarchy
2016-10-11 17:00:35,740 INFO  [Account] controller.Controller initConfig (Contro
ller.java:327) - config dir created at C:\Users\SF\Desktop\CLI
2016-10-11 17:00:35,744 ERROR [Account] config.Config initEncryption (Config.jav
a:732) - Error initializing encryption for key file C:UsersSFDesktopCLIKey
.txt: Cannot Access Key File: C:UsersSFDesktopCLIKey.txt
2016-10-11 17:00:35,745 FATAL [Account] process.ProcessRunner topLevelError (Pro
cessRunner.java:238) - Unable to run process Account
java.lang.RuntimeException: com.salesforce.dataloader.exception.ControllerInitia
lizationException: Error loading config file: C:\Users\SF\Desktop\CLI\conf
ig.properties.  Please make sure that it exists and is readable
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:112)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
Caused by: com.salesforce.dataloader.exception.ControllerInitializationException
: Error loading config file: C:\Users\SF\Desktop\CLI\config.properties.  P
lease make sure that it exists and is readable
        at com.salesforce.dataloader.controller.Controller.initConfig(Controller
.java:360)
        at com.salesforce.dataloader.controller.Controller.<init>(Controller.jav
a:110)
        at com.salesforce.dataloader.controller.Controller.getInstance(Controlle
r.java:212)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:110)
        ... 2 more
Caused by: com.salesforce.dataloader.exception.ConfigInitializationException: Er
ror initializing encryption for key file C:UsersSFDesktopCLIKey.txt: Canno
t Access Key File: C:UsersSFDesktopCLIKey.txt
        at com.salesforce.dataloader.config.Config.initEncryption(Config.java:73
3)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:647)
        at com.salesforce.dataloader.config.Config.load(Config.java:630)
        at com.salesforce.dataloader.config.Config.load(Config.java:606)
        at com.salesforce.dataloader.controller.Controller.initConfig(Controller
.java:354)
        ... 5 more
Hi guys,
My requirement is to update the name of the primary partner on a custom field (lookup to account) on opportunities object.
I tried to create a trigger on partner object but saw that it was not supported. I also tried a combination of process builder and flow to update but that was going to infinite loop as I was triggering it on update or insert ( silly me )
Do you have any suggestions on how this scenario can be handled.
Regards
We have an action of type ‘Custom Visualforce’ on a custom object called Trip. This action is added as a quick action in to the ‘Quick Actions in the Salesforce Classic Publisher’ menu in the page layout of the trip object.
The action is a simple visualforce page with firstname and lastname columns which when entered creates an account and also creates a related record for trip member object (after clicking the create member button). The objective of this VF page was a way for users to quickly create an account if it did not exist and doing it from the quick action on the page would save some time. There is a master detail relationship between trip and trip member and the trip members appear as a related list in the trip page layout.
Code is very similar to this. https://help.salesforce.com/HTViewHelpDoc?id=custom_actions_vf_pages_for_object_actions.htm&langu_3
The issue is we the related list does not get refreshed once an account has been created using the quick action , I know this is not possible with standard sf and we may have to go for a VF page. Issue is users have to refresh the page to see if the trip member has been added to the page.
But I was also wondering if there was a better way of implementing this whole thing.
Any suggestion is much appreciated

Hi,
   I am trying to retrieve hour from a datetime field. I am running a SOQL query and retrieving a set of values in my apex class and looping through them in my visualforce something like
 <apex:repeat var="arr" value="{!arrivals}">
 {!arr.Pickup_Time__c}' where arrivals is my soql querry in apex which retrieves a set of values.
Pickup_Time__c is a datetime field and I want to get only hour out of it.

I dont want to use formula fields as they are other issues of DST, timezone etc.

Can any help me with this.

Thanks

Hi Guys,
       I built a visualforce page for Salesforce1 and want to display the validation error messages on the screen. I am not able to show any error messages/alerts on the screen and as a reason user would not know if the transaction was successful or not.

My VF page looks something like this:

<apex:page standardController="Account" standardStylesheets="false" sidebar="false" applyBodyTag="false" docType="html-5.0" id="mypage">
<apex:pageMessages />
<apex:form >
<apex:pageBlock >
Name: <apex:inputField id="field1" value="{!Account.Start_Time__c}"/>
</apex:pageBlock>
    
</apex:form>        
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
<script> 
    
    Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel",
        onData:function(e) {
            Sfdc.canvas.publisher.publish({name:"publisher.setValidForSubmit", payload:"true"});
    }});
    Sfdc.canvas.publisher.subscribe({ name: "publisher.post",
        onData: function(e) {
        alert("remote action here");
         getRemoteAccount();     
       Sfdc.canvas.publisher.publish({ name: "publisher.close",
       payload:{ refresh:"true" }});

    }});
    
        function getRemoteAccount() {
            // retrieve values here from the form


           Visualforce.remoting.Manager.invokeAction(  
            '{!$RemoteAction.<apex class>.<method name>}',
             params,
             function(result, event){
                if (event.status) {
                    alert("Inside event"); 
                  
                } else if (event.type === 'exception') {
                     alert(event.message);
                } else {
                      var  msg = result;
                      alert(msg);
                }
            }, 
            {escape: true}
        );
    }
    
    </script>    
    
</apex:page>

and I have catch block in my controller which does Apexpages.addMessage('message');

Any idea on how to display error messages when you are using submit in salesforce1 mobile and not the standard button
Hello All,
             I have an input field in my visualforce page which uses the html 5 input element as type="datetime-local". The value that I capture from the field is of the format "2016-04-09T23:58" . I want to use and save this field on to the database in salesforce and I cant assign the same value to the field directly. Even to parse salesforce expects a different format something like this '09/04/2016 5:10 PM'.

If I can do something like Datetime dt = DateTime.parse('24/11/2011 1:46 PM') then I can assign it to a field in Salesforce but there is nothing where I can use 2016-04-09T23:58 directly. I will have to convert 2016-04-09T23:58 to 09/04/2016 5:10 PM and do it.

Is there any better way to achieve this  or am I missing something here 

Regards,
Sandy
I am trying to use date picker in ligtning design system and and using the idea explained in below link to do it.
http://salesforce.stackexchange.com/questions/102599/lightning-slds-styling-for-calendar

This works fine in the browser on the desktop but when I open it Salesforce1 it doesnot work properly and comes out in a weird way.
User-added image
Any idea on how to solve this
 
I created a formula field in a flow but it errors out.
Using cross object relationships directly in visual flow also did not help.
 For example : If A is my custom object associated with account and I have collection variable in the flow which refers to a column on account it doesnot work like A.Account__r.name fails and gives the below error.

The flow failed to access the value for A.Account__r.name because it hasn't been set or assigned 

I am triggering the flow from a VF page button and I am accessing A.Account__r.name in the VF page.
if I access A.Account__c it works fine.

Is there any one else who is also facing the same problem
Hi Guys,
            I have noticied that VF pages take a long time to load in Salesforce1, roughly around 5-6 secs.
Even a simple 'Hello World' page takes 5-6 secs when it loads for the first time in Salesforce1 and the subsquent loads are little better.

Has any one else faced such issues on VF pages in Salesforce1.
Any tips/pointers in improving the performance would be appreciated.
I have a visualforce page which on click of command button calls a VF remoting function which updates my records in the background
<apex:commandButton value="Submit" action="{!Save}" onclick="updateRecordsDetails('Completed');" />
updateRecordsDetails is my VF remote function which invokes my controller methods which does the update.
Nothing fancy.

The page seemed to work fine without any issues on the salesforce website but when we oepned the VF page in Salesforce1 on IOS it doesnot work.

Has any faced similiar issue and do you know what can be the reason for this behaviour.
I tried to enable inline editing for accounts. Our org has person accounts enabled and according to the documentation we have to include the filter of ' Is Account' = true and also to filter it by a recordtype. I have done both of them and included its an and condition for both the filters. Is account = true record type = 'Our Recordtype'. 
Please let me know how this issue can be rectified.
Hi All,
        I am building a visualforce page (html and css ) also included for chatter.
My first tab should contain all chatter which will be the newsfeed and the second tab is the company tab which contains the information about the company group.
The problem I facing is that I am not able to use <chatter:newsfeed> and <chatter:feed> tags on the same page. The error I get is "Only one Chatter-related component can be specified per page."

This is part of the code 

   <apex:outputPanel id="OP"> 
    <div class="mock-content" id="mock-content">
    <apex:outputPanel id="OP1" rendered="{!IF(!withFollowers,true,false)}">
    <chatter:newsfeed/>
  
    </apex:outputPanel> 
    <apex:outputPanel id="OP2" rendered="{!withFollowers}">
    <chatter:feed id="chatterFeedID" rendered="{!NOT(ISNULL(EntityID))}" entityId="{!EntityID}"/> 
  <!--  <chatter:followers id="chatterFeedID1" rendered="true" entityId="{!EntityID}"/> -->
    </apex:outputPanel> 
    </div> 
    </apex:outputPanel>  


Can any help me in this
Hi Guys,
            I wrote a piece of code which checks few condtions and updates a field in the end but the update is not working.

Below is the code. It goes in to the else block but DevIncidientSubmit__c  is not getting updated.
Any help in this regards is appreciated.


{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!requireScript("/soap/ajax/29.0/apex.js")} 
var SQLu = "Select Id,Drive_Guest_Count__c,Travel_Sector_Count__c,Status__c,DevIncidientSubmit__c from Application__c where id='{!Application__c.Id}'"; 
var flag = false; 
var application = new sforce.SObject("Application__c"); 
result = sforce.connection.query(SQLu); 
records = result.getArray("records"); 
for(i=0; i < result.getArray("records").length; i++) 

if (result.getArray("records")[i].Travel_Sector_Count__c <= 0.0 && result.getArray("records")[i].Drive_Guest_Count__c == "true") 

alert("Please enter at least one travel sector and one drive guest application"); 

else if(result.getArray("records")[i].Drive_Guest_Count__c == "true" ) 

alert("Please enter at least one drive guest application application"); 

else if (result.getArray("records")[i].Travel_Sector_Count__c <= 0.0) 

alert("Please enter at least one travel sector application"); 

else 

alert("In final else"); 
result.getArray("records")[i].DevIncidientSubmit__c = "True"; 




sforce.connection.update(result.getArray("records")); 
alert("The value of getarray is"+result.getArray("records")); 
location.reload();
Hi Guys,
               Is there anyway that we can monitor the apex job queue and send an email alert when the jobs are not processed for more than 5 minutes.
We have observed that the future jobs are queued sometimes and take a long time to process.
It would be good if we can get an email alert in such scenarios.

Regards,
Sandy
Hi All,
         I need to run queries as part of my work which sometimes includes more than say 800 values in 'IN' condition. When I run this query i get an error saying " Unknown Asynchronous State"
I eventually end up doing it in Dataloader where the same query works fine. 
Were any of you succesful in resolving this issue.

My query looks something like this

SELECT name,age FROM Applicant__c where name in ('A1',
'A2',
.
.
.

.
'A850')

 
Hi All, 
         I am getting the below error when I trying to use a
dataloader CLI. I have followed the Salesforce documentation and this blog
http://www.jitendrazaa.com/blog/salesforce/tutorial-of-command-line-dataloader-salesforce/

I am not able to figure out what the issue is  and any help would be greatly appreciated

CONFIG.properties
#Tue Oct 11 2016
sfdc.debugMessages=true

process.encryptionKeyFile=C:\Users\SF\Desktop\CLI\Key.txt
sfdc.debugMessagesFile =C:\Users\SF\Desktop\CLI\logfile.log
sfdc.endpoint=https://test.salesforce.com
sfdc.username=<myusername>
sfdc.password=<encrypted password>
sfdc.proxyUsername=
sfdc.proxyPassword=
sfdc.proxyHost=
sfdc.proxyPort=
sfdc.loadBatchSize=200
sfdc.timeoutSecs=600

process-conf.xml

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="Account"
    class="com.salesforce.dataloader.process.ProcessRunner"
    singleton="false">
        <description>Export Account Data</description>
        <property name="name" value="Account"/>
        <property name="configOverrideMap">
        <map>
            <entry key="sfdc.enableLastRunOutput" value="false"/>
            <entry key="sfdc.debugMessagesFile" value="C:\Users\SF\Desktop\CLI\sfdcSoapTrace.log"/>
            <entry key="sfdc.endpoint" value="https://test.salesforce.com"/>
            <entry key="sfdc.username" value="<username>"/>
            <entry key="sfdc.password" value="<encrypted password>"/>
            <entry key="sfdc.entity" value="Account"/>
            <entry key="process.operation" value="extract"/>
            <entry key="sfdc.extractionRequestSize" value="500"/>
            <entry key="sfdc.extractionSOQL" value="SELECT Id FROM Account"/>
            <entry key="dataAccess.name" value="C:\Users\SF\Desktop\CLI\AccountExport.csv"/>
            <entry key="dataAccess.type" value="csvWrite"/>
            <entry key="dataAccess.writeUTF8" value="true" />
        </map>
        </property>
    </bean>
</beans>


ERROR

2016-10-11 17:00:35,599 INFO  [main] controller.Controller initLog (Controller.j
ava:389) - Using built-in logging configuration, no log-conf.xml in C:\Program F
iles (x86)\salesforce.com\Data Loader\bin\log-conf.xml
2016-10-11 17:00:35,603 INFO  [main] controller.Controller initLog (Controller.j
ava:391) - The log has been initialized
2016-10-11 17:00:35,606 INFO  [main] process.ProcessConfig getBeanFactory (Proce
ssConfig.java:104) - Loading process configuration from config file: C:\Users\sg
387088\Desktop\CLI\process-conf.xml
2016-10-11 17:00:35,656 INFO  [main] support.AbstractApplicationContext prepareR
efresh (AbstractApplicationContext.java:495) - Refreshing org.springframework.co
ntext.support.FileSystemXmlApplicationContext@cd5f8b: startup date [Tue Oct 11 1
7:00:35 EST 2016]; root of context hierarchy
2016-10-11 17:00:35,683 INFO  [main] xml.XmlBeanDefinitionReader loadBeanDefinit
ions (XmlBeanDefinitionReader.java:315) - Loading XML bean definitions from file
 [C:\Users\SF\Desktop\CLI\process-conf.xml]
2016-10-11 17:00:35,711 INFO  [main] support.DefaultListableBeanFactory preInsta
ntiateSingletons (DefaultListableBeanFactory.java:557) - Pre-instantiating singl
etons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15
3c375: defining beans [Account]; root of factory hierarchy
2016-10-11 17:00:35,740 INFO  [Account] controller.Controller initConfig (Contro
ller.java:327) - config dir created at C:\Users\SF\Desktop\CLI
2016-10-11 17:00:35,744 ERROR [Account] config.Config initEncryption (Config.jav
a:732) - Error initializing encryption for key file C:UsersSFDesktopCLIKey
.txt: Cannot Access Key File: C:UsersSFDesktopCLIKey.txt
2016-10-11 17:00:35,745 FATAL [Account] process.ProcessRunner topLevelError (Pro
cessRunner.java:238) - Unable to run process Account
java.lang.RuntimeException: com.salesforce.dataloader.exception.ControllerInitia
lizationException: Error loading config file: C:\Users\SF\Desktop\CLI\conf
ig.properties.  Please make sure that it exists and is readable
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:112)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
Caused by: com.salesforce.dataloader.exception.ControllerInitializationException
: Error loading config file: C:\Users\SF\Desktop\CLI\config.properties.  P
lease make sure that it exists and is readable
        at com.salesforce.dataloader.controller.Controller.initConfig(Controller
.java:360)
        at com.salesforce.dataloader.controller.Controller.<init>(Controller.jav
a:110)
        at com.salesforce.dataloader.controller.Controller.getInstance(Controlle
r.java:212)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:110)
        ... 2 more
Caused by: com.salesforce.dataloader.exception.ConfigInitializationException: Er
ror initializing encryption for key file C:UsersSFDesktopCLIKey.txt: Canno
t Access Key File: C:UsersSFDesktopCLIKey.txt
        at com.salesforce.dataloader.config.Config.initEncryption(Config.java:73
3)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:647)
        at com.salesforce.dataloader.config.Config.load(Config.java:630)
        at com.salesforce.dataloader.config.Config.load(Config.java:606)
        at com.salesforce.dataloader.controller.Controller.initConfig(Controller
.java:354)
        ... 5 more
Hi guys,
My requirement is to update the name of the primary partner on a custom field (lookup to account) on opportunities object.
I tried to create a trigger on partner object but saw that it was not supported. I also tried a combination of process builder and flow to update but that was going to infinite loop as I was triggering it on update or insert ( silly me )
Do you have any suggestions on how this scenario can be handled.
Regards
We have an action of type ‘Custom Visualforce’ on a custom object called Trip. This action is added as a quick action in to the ‘Quick Actions in the Salesforce Classic Publisher’ menu in the page layout of the trip object.
The action is a simple visualforce page with firstname and lastname columns which when entered creates an account and also creates a related record for trip member object (after clicking the create member button). The objective of this VF page was a way for users to quickly create an account if it did not exist and doing it from the quick action on the page would save some time. There is a master detail relationship between trip and trip member and the trip members appear as a related list in the trip page layout.
Code is very similar to this. https://help.salesforce.com/HTViewHelpDoc?id=custom_actions_vf_pages_for_object_actions.htm&langu_3
The issue is we the related list does not get refreshed once an account has been created using the quick action , I know this is not possible with standard sf and we may have to go for a VF page. Issue is users have to refresh the page to see if the trip member has been added to the page.
But I was also wondering if there was a better way of implementing this whole thing.
Any suggestion is much appreciated
Hello everybody, I have the class below getting data from a trigger (that seems to be working ok), the problem is, I am getting a "Too many SOQL queries" errors when it executes.  If I comment out "insert opptsToInsert;" then I have no problems, but of course my new opportunity is not created.  I've tryied and regarless of where I put the insert I always get the same error. Any suggestions will be welcome.

Thanks


public class RenewalOpportunities 
{
    public void CreateRenewalOpportunity(Map < Id, Opportunity > oldMap, Map < Id, Opportunity > newMap) 
    {
        System.debug('Renewal starting');    
        List < Opportunity > opptsToInsert = new List < Opportunity > ();
        Opportunity newOppt = new Opportunity();
        //List < Id > OpptyIds = new List < Id > ();
        for (Opportunity o: newMap.Values()) 
        {
            //OpptyIds.add(o.id);
            System.debug('Old ID ' + o.id);
            System.debug('Renewal check ' + o.RenewalCreated__c);

            {
                newOppt.Name = o.Name + ' Renewal Opportunity';
                newOppt.AccountId = o.AccountId;
                newOppt.RecordTypeId = o.RecordTypeId;
                newOppt.CloseDate = Date.Today() + 30;
                newOppt.StageName = 'Renewal Opportunity';
                newOppt.Type = 'Add-On Business';
                newOppt.NextStep = 'Send a invoice for maintenance renewal';
                 newOppt.OwnerId =o.OwnerId;}
                opptsToInsert.add(newOppt);
                System.debug('Account Name ' + newOppt.AccountId);
                System.debug('Opportunity Name ' + newOppt.Name);
                System.debug('Stage Name ' + newOppt.StageName);
                System.debug('Type Name ' + newOppt.Type);
                System.debug('Next Step ' + newOppt.NextStep);
                System.debug('Close Date ' + newOppt.CloseDate);
                System.debug('New Opportunities ' + opptsToInsert);
     

        }   
        
        System.debug('Size ' + opptsToInsert.size());
         if (opptsToInsert.size() > 0){ 
            insert opptsToInsert;}
    }
}
 
global class CaptureLastLoginDate implements Database.Batchable<sObject>{

        //This is the query that is passed to the execute method. .

        String ids = UserInfo.getUserId();
        String query = 'SELECT id,LastLoginDate__c FROM User ';

        global database.queryLocator start(Database.BatchableContext BC) {
             System.debug(query);
             return database.getQueryLocator(query);
        }
        //close start method
        global void execute(Database.BatchableContext BC, List<sObject> scope){
            List<Schema.User> u = new List<Schema.User> ();
            for(sObject s: Scope){
                Schema.User inv = (Schema.User)s;
                inv.LastLoginDate__c= inv.LastLoginDate__c;
                u.add(inv);
                System.debug(u);
            }
            update u;
        }

        global void finish(Database.BatchableContext sc){

        }       
   }
class

global class  BatchClass5 implements  Database.Batchable<sObject> {
   global final string query;
  global  BatchClass5(String q)
      {
         query = q;
      }
      
      global Database.QueryLocator start(Database.BatchableContext BC){
      
         return Database.getQueryLocator(query);
      }
      
      global void execute(Database.BatchableContext BC, List<Account> scope)
      {
          List<Account> accns = new List<Account>();
       List<Contact> lstcon= new List<contact>();
         for(Account a : scope)
         {
                 Account a1 = new Account();
                 contact c = new contact();
                 c.lastname = a1.name;
                 c.accountid = a1.id; 
                  lstcon.add(c);
                  }
          
      insert lstcon;
      }
      global void finish(Database.BatchableContext BC){
        // Get the ID of the AsyncApexJob representing this batch job  
        // from Database.BatchableContext.    
        // Query the AsyncApexJob object to retrieve the current job's information.  
       
      }
}

Test class

@isTest
private class BatchClass5_Test5 
{
    static testmethod void m1()
    {
        
        Test.startTest();
        Account a = new Account(Name='saikumar');
            insert a;
        contact c = new Contact();
        c.LastName =a.Name;
        c.AccountId= a.Id;
        insert c;
                system.assertEquals('saikumar',c.LastName);

        BatchClass5 sync = new batchclass5('select id,name from Account');
        ID batchprocessid = Database.executeBatch(sync);
        Test.stopTest();
    }

}
The query
[SELECT Id FROM Contact] 

is returning zero rows in a test class.
I have tried everything I can think of. Why won't it return all records?

When I run the test I am seeing this line in the log.
SOQL_EXECUTE_BEGIN [4]|Aggregations:0|SELECT Id FROM Contact
SOQL_EXECUTE_END     [4]|Rows:0
 

Hi,
   I am trying to retrieve hour from a datetime field. I am running a SOQL query and retrieving a set of values in my apex class and looping through them in my visualforce something like
 <apex:repeat var="arr" value="{!arrivals}">
 {!arr.Pickup_Time__c}' where arrivals is my soql querry in apex which retrieves a set of values.
Pickup_Time__c is a datetime field and I want to get only hour out of it.

I dont want to use formula fields as they are other issues of DST, timezone etc.

Can any help me with this.

Thanks

Hello All,
             I have an input field in my visualforce page which uses the html 5 input element as type="datetime-local". The value that I capture from the field is of the format "2016-04-09T23:58" . I want to use and save this field on to the database in salesforce and I cant assign the same value to the field directly. Even to parse salesforce expects a different format something like this '09/04/2016 5:10 PM'.

If I can do something like Datetime dt = DateTime.parse('24/11/2011 1:46 PM') then I can assign it to a field in Salesforce but there is nothing where I can use 2016-04-09T23:58 directly. I will have to convert 2016-04-09T23:58 to 09/04/2016 5:10 PM and do it.

Is there any better way to achieve this  or am I missing something here 

Regards,
Sandy
I am trying to use date picker in ligtning design system and and using the idea explained in below link to do it.
http://salesforce.stackexchange.com/questions/102599/lightning-slds-styling-for-calendar

This works fine in the browser on the desktop but when I open it Salesforce1 it doesnot work properly and comes out in a weird way.
User-added image
Any idea on how to solve this
 
I have a visualforce page which on click of command button calls a VF remoting function which updates my records in the background
<apex:commandButton value="Submit" action="{!Save}" onclick="updateRecordsDetails('Completed');" />
updateRecordsDetails is my VF remote function which invokes my controller methods which does the update.
Nothing fancy.

The page seemed to work fine without any issues on the salesforce website but when we oepned the VF page in Salesforce1 on IOS it doesnot work.

Has any faced similiar issue and do you know what can be the reason for this behaviour.
Hi,
My scenario is,
I have to get the details by location(State or Country).1st preference is State.
My output will be,
User-added image
The input fields are Standard Country and State picklist .
The state or country (input) has  pass to the apex controller.
[ Eg:
1.country :USA State: NY---- input will be NY(State)
 2. country:Iceland  State : No States ,------ input will be  Iceland(Country) 
]
I dont know how to pass theat selected state picklist value to apex controller.

But i written some piece of codes.Please verify it and correct it. If anyone knows please tell me.

My Apex Code:

Public with sharing class SOSLController{
 Public List<loc__c> location {get;set;} // location
    public String imageURL{get;set;} // display a image
 Public String searchStr{get;set;} // find a string
 private ApexPages.StandardController stdController;
  /* display a image -method*/
 public  SOSLController(ApexPages.StandardController stdController)
  {
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
    /* find a string and  run the sosl query*/
  Public void soslDemo_method(){
   location = New List<loc__c>();
   if(searchStr.length() > 1){
   String searchStr1 = searchStr;
     //  System.debug('message');
       String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  loc__c(Comp__c, Type__c,Client__c, Competitor__c,Event_Name__c, evt_Des__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c )';
   List<List <sObject>> searchList = search.query(searchQuery);
   location = ((List<loc__c>)searchList[0]);
       /* Message */
   if(location.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, Type the location correctly or There is no details of the requested location found'));
       return;
   }}
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter the location..'));
   return;
   }}}

My VFP:

<apex:page standardController="Contact"  extensions="SOSLController"  sidebar="false" showHeader="false">
  <apex:form >
       <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Enter a location" id="acct1">
          <apex:outputLabel value="Country" />
          <apex:inputField value="{!contact.MailingCountryCode}" />
            <apex:outputLabel value="State" />
          <apex:inputField value="{!contact.MailingStateCode}" />
    <apex:commandButton value="Submit" action="{!soslDemo_method}"  reRender="acct,error,acct1" />
    <apex:outputPanel title="" id="error">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
  </apex:pageBlock>
    <apex:pageBlock title="Details of technical events" id="acct">
    <apex:pageblockTable value="{!location }" var="acc">
           <apex:column value="{!acc.Comp__c}"/>
         <apex:column value="{!acc.Type__c}"/>
          <apex:column value="{!acc.Client__c}"/>
        <apex:column value="{!acc.Competitor__c}"/>
        <apex:column value="{!acc.Event_Name__c}"/>
          <apex:column value="{!acc.evt_Des__c}"/>
        <apex:column value="{!acc.Et_Addr__c}"/>
          <apex:column value="{!acc.Dt_Ti__c}"/>
        <apex:column value="{!acc.Ct_Person__c}"/>
          <apex:column value="{!acc.Ph_Num__c}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>


Thanks and Regards,
Sivasankari.M
Hi Community,
I building a table in VF and I'm using repeat to build it, when doing it I'm getting the values with no problem however the Headers don't apper

My vf is:
<apex:pageBlock >
<apex:pageblocktable id="SLACube" value="{!KPICube}" var="record" rendered="true">

<apex:column >
<apex:facet name="header">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:facet>
<apex:outputText value="{!record.UserName}" />
</apex:column>

<apex:repeat value="{!record.amountPerScore}" var="key">
<apex:column >
<apex:facet name="header"># of {!key}</apex:facet>
<apex:outputText value="{!record.amountPerScore[key]}" />
</apex:column>
</apex:repeat>

</apex:pageblocktable>
</apex:pageBlock>

Any idea how to solve it?

Thanks!
Hi,

This is my VF page code. But related list showing all contacts though I am using pageSize="1".

<apex:page standardController="Account">
       <apex:pageBlock>
       <apex:pageBlockSection>
       <apex:detail relatedList="false"/>
            <apex:relatedList list="Contacts" pageSize="1"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
 </apex:page>
I've got an Sobject collection variable in a flow, and I would like to display a list of values from the collection in a display text field.

If I use the varaible resource, it displays the IDs, along the lines of [Id1, Id2, Id3].

Is there any way to get the flow to produce something along the lines of:

Name1, Value1
Name2, Value2,
Name3, Value3,

in a display text field?

If not possible in the flow itself, I'm guessing if I embed the flow in a visualforce page I could pull it off, but would appreciate any tips on going about that.

Thanks

(Cross post from success: https://success.salesforce.com/answers?id=90630000000Cr4J)
I've done a lot of reading about database.dmloptions, assignmentruleheader, etc. the past week or so, but am unable to find a simple answer to a few questions that continue to linger:

1) I have some apex logic built to facilitate lead assignment. I would like for this logic to respect if the user checks "assign using active assignment rules", and to possibly not fire (i.e. return;) when this is the case. How can I check whether this option was enabled by the user on lead insert/update in apex?

2) After getting an affirmative result from #1, I would like to evaluate whether the lead would actually be assigned by the assignment rule after evaluation. This is an important step as I will still want my logic to fire if the assignment rules all evaluate to be false. How can I perform this check? I suppose I could insert a test lead using the assignment rule, query the result, then delete the test lead, but this seems perhaps more DML-intensive than it needs to be...

3) Additionally, if I did decide in certain cases that after detecting this option, I wanted to undo/disable this (despite the user's preference), how could this be done? I have attempted to use this segment on a before trigger, which has no effect:

for (lead l : trigger.new)
{
    database.dmloptions dmo = new database.dmloptions();
    dmo.assignmentRuleHeader.useDefaultRule = false; // (attempt 1)
    dmo.assignmentRuleHeader.assignmentRuleId = null; // (attempt 2)
    l.setOptions(dmo);
}

Any and all help appreciated!

Thanks much.
How to get rid of the issue in visualforce page - Maximum Continuation state size limit (80KB) excceded?