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
hokie_highhokie_high 

Need help on "Case" Object

Hello, this might sounds very simple to you but I'm new to java, it seems I can't get the "Case" query working. I got the Enterprise sample running and it has samples for "Account", "Contact and "Task" so I know how to work with those objects. But work with "Case" seems different. I can't declear something like: Case myCase = (Case) qr.getRecords()[i]; since java can't resolve Case class.

Could someone post some sample code for "Case" object to get me started? I want to be able to run Case Update/Insert. Thanks a lot!

-Alex

Scott BScott B

I have done many queries of cases.

Are you using the _case object?  In java, when you gen the proxy classes ( assuming you are using axis ), the data type for Case is _case to get around the java keyword.

Given an array of cases coming back from the query method called 'cases'

for ( int i = 0; i < cases.length; i++ ) {

     _case myCase = (_case ) cases[i];
    System.out.println( myCase.getId().getValue();
...

}

hokie_highhokie_high

Scott, thanks for the tip and sample.

It seems I'm having trouble to run this query:

...
myCases = ( (_case) qr.getRecords()[i]);
System.out.println( myCases.getId().getValue());
...

it returns:
Failed to execute query succesfully, error message was:
null

Could someone please point out where I did wrong? Thanks.

Scott BScott B

Are you getting records back ( i.e. your qr.getRecords() is not null?)  Are there errors on the QueryResult obj?  This should be very straight-forward, just like your other queries you said were working...

You have to select the ID field in your query to print it out here.  That might also be the problem.

Might help if you post up your query and some more of the code...

hokie_highhokie_high

Scott, THANK YOU!

It was the ID field, I didn't know I need to query that field.