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

BeanShell: Proper way to set query filter values when using IapiQueryResultSetIfc

Former Member
0 Likes
756

Hello experts,

I am executing queries via the instructions in this excellent blog post: Query IAPIs - A Good Alternative For DbHandle

I've tried many things and have had no luck.

 

What should the XXXXX be here in in the following 2 situations? (#1 is most critical for me.)

1) For data type: ObjectReference?

          filters.put("MasterAgreement", XXXXX);

         

2) For data type: Value List

     Is it okay to write the Display ID string in here like this?

          // Simplay write the "Display Name ID" of the value list value in here.

          filters.put("MyFilterName", "MyFilterValue");

     Or do we have to do something like this?


             ***
Please note this is just untested example code to illustrate the question—not from working code.

// Get value list homeValueListTypeIBeanHomeIfc

valueListHome = IBeanHomeLocator.lookup(session,ValueListTypeIBeanHomeIfc.sHOME_NAME);                       

// Get value list type object ref

vlistTypeCode =  valueListHome.findByExternalId("custom-my_value_list_type").getTypeCode();

// Get value list value home
ValueListValueIBeanHomeIfc valueListValueHome = IBeanHomeLocator.lookup(session,ValueListValueIBeanHomeIfc.sHOME_NAME);

// Get value list value object ref
valuelistvalue = valueListValueHome.findUniqueByNameType("MyFilterValue",vlistTypeCode).getLocalizedObjectReference();

            // Set filter value to value list value object ref

filters.put("MyFilterName", valuelistvalue);

Thanks in advance!

Mike

View Entire Topic
Former Member
0 Likes

Hello Mike,

The general idea is that the same object type in your filter prompts has to be sent within the parameters Map object.

1. for DataType - ObjectReference -> mandatory to send a ObjectReferenceIfc object

  • if your variable is the ibean itself (eg: MA)
    • filters.put("MasterAgreement", doc.getObjectReference()); //if your context has doc variable; if not you'll have your_var_name.getObjectReference()
  • if your variable is actually an ObjectReference you can pass it directly
    • for example on MA, method getIntCatRef() returns an ObjectReferenceIfc, if you want to use it in a query filter: filters.put("InternalCategory", doc.getIntCatRef());

2. for DataType - ValueListValue: the VLV object is actually identical to your regular Ibean; so the rules that apply are identical as for the ObjectReference.

  • the sample code you provided is correct, only the last statement has to be:
    • filters.put("MyFilterName", valuelistvalue.getObjectReference());

Regards,

Bogdan