cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks Kushagra and Bogdan! Your responses helped me fix the problem.

Mike

former_member190023
Contributor
0 Kudos

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

kushagra_agrawal
Active Participant
0 Kudos

HI Mike,

As per my understanding from your question, you need to pass the value to the filter prompt of the query via script and get the result set. If that is the case then you can make a filter prompts of type String and pass those values through the Script and write your business logic on the returned result sets.

1. Current MA:

filterPrompts.put("MasterAgreement",doc.getDocumentId());

2. Value:

filterPrompts.put("YourFilter","Value");


P.S: "Value" is of type String.


Correct me if I got your requirement wrong.


Hope it helps!


Best,

Kushagra A