cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get all Cstickets items using FlexibleSearchService and/or FlexibleSearchQuery

0 Likes
390

Hello,

I need your help to know how could I get all Cstickets items and save them in a list<CsTicketModel>, so that, I will be able to know the attibutes for each item using a loop.

I have tried the attached code, but a get an error. It shows "Unable to evalue the expression Method threw 'Java.lang.IllegalArgumentException' exception".

code.jpg

Please your help.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

Hi,

You are supposed to write the query so that you are fetching the PK for the model you need. So in your case the query should be something like:

Select {pk} from {CsTicket}

this should work for you.

Alternatively you can use DefaultGenericDao you should extend your dao with DefaultGenericDao and the constructor and call the find method to get the results.

this should work for you too.

please have a look at the sample code below:

public class DefaultCsTicketDao extends DefaultGenericDao<CsTicketModel> implements CsTicketDao
{


public DefaultCsTicketDao()
{
   super(CsTicketModel._TYPECODE);
}


@Override
public CsTicketModel getNumberSeries(final String csTicketid)
{
   final Map<String, Object> params = new HashMap<>();
   params.put(CsTicketModel.UID, csTicketid);

   final List<CsTicketModel> tickets = this.find(params);
   return CollectionUtils.isNotEmpty(tickets) ? tickets.get(0) : null;
}

}