function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gowdagowda 

How to get the New Leads

I go online log into my developer edition and create a New Lead ,

Now in my client application i need to pull all the New Leads,

Which method i should use to find out all the New Objects like Accounts, Leads etc...

I appreciate any help on this.

regards

gowda

 

benjasikbenjasik
You should use the getUpdated call
gowdagowda

Well i did that below is the code

private GetUpdatedResult updatedLeads = null;

try{
           updatedLeads = binding.getUpdated(descSObjectRslt.getName(), 
                (Calendar)startTime, (Calendar)endTime);
          System.out.println("Length of the Leads =" + updatedLeads.getIds().length);
         }catch(Exception ex){
              System.out.println("couldn't get the updated leads");
         }

Even though i created 3 Leads today i get Null Pointer Exception..

Let me know if i am doing right here..

Regards

GGowda

 

benjasikbenjasik
What line is the null pointer exception on?

I assume you have already logged in and the binding is set up correctly?
gowdagowda

well its in side the try block, i.,e while calling getUpdated

updatedLeads = binding.getUpdated(descSObjectRslt.getName(), 
                (Calendar)startTime, (Calendar)endTime);

By the way i have a login logic once it gets authenticated, I have a code to get all the objects which is assigned to my account, I was able to get the meta information about the Lead Object, And then i have the above code to get all the leads which is where its failing..i.,e getting Null Pointer Exception.

Let me know if i need to do anything before calling this object..

 

benjasikbenjasik
If you are using eclipse, they make it easy to set a breakpoint on a exception and you can see exactly which object is null.

It seems like binding, descsObjectRslt, startTime, or endTime must be null
gowdagowda

I checked all of the above , but i don't get any null there, By the way here is the code...

try{
           updatedLeads = binding.getUpdated("Lead", 
                (Calendar)startTime, (Calendar)endTime);
          System.out.println("Length of the Leads =" + updatedLeads.getIds().length);
         }catch(Exception ex){
              System.out.println("couldn't get the updated leads");
         }

 

         if (updatedLeads.getIds().length > 0) {    //  <----- I am getting Null Pointer at this line
                for (int i=0;i<updatedLeads.getIds().length;i++) {
                  System.out.println("Leads =" + updatedLeads.getIds(i).getValue() + " was updated between " +
                           startTime.getTime().toString() + " and " + endTime.getTime().toString());
                }    
              } else {
                 System.out.println("No updates to accounts in the last 5 minutes.");
             } 
 

Kindly let me know about this, I wasted nearly 4 hours on debugging this.

regards

gowda

benjasikbenjasik
No ids are being returned, so getIds() is null

Try

ID[] ids = updatedLeads.getIds;()
if (ids != null && ids.length > 0) {
gowdagowda

Thanks for your information...

I tried as u said..this is the below code

 ID [] ids = updatedLeads.getIds();
          if (ids != null && ids.length > 0) {
                for (int i=0;i<ids.length;i++) {
                  System.out.println("Leads =" + ids[i].getValue() + " was updated between " +
                           startTime.getTime().toString() + " and " + endTime.getTime().toString());
                }    
              } else {
                 System.out.println("No updates to accounts in the last 5 minutes.");
             }

Now i didn't get any Null Pointer Exception...But it displayed the ELSE part, By the way its getting only the updated Leads taking the time frame in to account ?

Let me know about this