I am having 5 columns in my grid and I have a string edit field and a button in my form. I have a date column in my grid. All i want is to filter the form respective to the date field when i enter a date value in the string edit field and click the button.
This is the code I used for filtering my columns.
public void executeQuery() {
qbr.value(strFmt(’(%1 LIKE “%7”) || (%2 LIKE “%7”) || (%3 LIKE “%7”) || (%4 LIKE “%7”) || (%5 == %8) || (%6 LIKE “%7”)’, fieldStr(LearningCSVTable,CustomerID),fieldStr(LearningCSVTable,CustomerName),fieldStr(LearningCSVTable,Item),fieldStr(LearningCSVTable,VendorName),fieldStr(LearningCSVTable,OrderDate),fieldStr(LearningCSVTable,Status),’’+StringEdit.valueStr()+’’,date2StrXpp(str2date(stringedit.valueStr(),123))));
Hi Wekey,
If you want to filter grid with respective date which is entered in stringedit field (for that you have to set ExtendedDataType property for date) then why you are adding range with the Customer Id. Instead of CustomerId you have to add range of OrderDate filed.
Please refer below code, It may help you.
init method of LearningCSVTable datasource
public void init()
{
LearningCSVTable learningCSVTablefin;
;
super();
Thanks for your reply, But I want to filter values with all the field and not only with date field. That is why I have set range for customer ID and used LIKE keyword in my executequery() method.
The remaining fields will be getting filtered according to the date field we are giving in the the string edit. But what i want is I need to give any values in the string edit field and filter according to it. If i give your code it is only getting filtered according to the date field. If i give any values from other fields in the stingedit it will not work.
The kind of query you are writing in AX, you have to write it as an SQL query. Return unique field you have on that datasource from SQL by executing direct SQL statement in AX.
If customerId is the unique field in your table, return only that field from SQL. Now take all the CustomerIds that you got in response as a comma separated value (either in a string or container) & pass it into you query range on CustomerId field.
str customerIds;
//write the the code here to get customer ids from SQL through code with the required filters.
qbr.value(customerIds);//if customerIds field is a container//qbr.value(con2str(customerIds));
}This solution will definitely work but it might impact the performance. It is recommended to search on a single field at a time. Let the user select which field he wants to search on. It will give faster response.