Answered

Filter expression, exclude records that have a specific attribute t which ends with a certain letter

I have a table that contains invoices. I want to filter Invoices out with an invoice number that ends with a C or D. I've tried several options but so far did not succeed. I have added a Rule Expression on the table.

When I try the following:

var c1 = "(invoiceNo LIKE '%C')"

FilterString = c1

FilterString;

I do get only invoice with invoiceNo's that ends with C. But I want the opposite. I've tried to change LIKE to NOT LIKE

var c1 = "(invoiceNo NOT LIKE '%C')"

FilterString = c1

FilterString;

That results in a syntax error. I've also tried with !=

var c1 = "(invoiceNo != '%C')"

FilterString = c1

FilterString;

Then it just shows every invoice.

Does anybody have an idea how to do this?

Comments (4)

photo
1

Dear Theo

In order to help you with this issue, please attach your complete script/expression.

We look forward to hearing from you.

Best Regards

photo
1

This is the complete script. Not sure what you are looking for?

photo
1

Dear Theo

As we understand you have a collection of invoices that you would like to display on the form and filter out the ones where the InvoiceNumber ends with 'C' or 'D'.

In this case, an alternative approach could be to have an expression "On Enter" of the task to do the filtering as below (as an example). You can modify it as per your needs.

var allResults =<XPath of your collection>;

for (var i=0; i<allResults.size(); i++) {

var thisResult = allResults.get(i);

var invoiceNo= thisResult.getXPath("invoiceNo");

var len = invoiceNo.length;

if(invoiceNo.charAt(len - 1) == 'C'){

Me.detachCollectionItem("XPath of your collection", thisResult)

}

}

Above script is using the function detachCollectionItem() to remove the item from the collection. It does not delete it from the database.

Hope this helps!

Best Regards

photo
1

Thanks for your response!

I don't want the invoices to be removed from the collection. Why does the scripting not work? As I understand it should be possible to use SQL statements. (https://help.bizagi.com/bpm-suite/en/index.html?filter_with_expressions.htm). See also attached file for what I'm trying to do.