Skip to Content
Author's profile photo m fahim

SAP Crystal Report Dynamic Search Based On Filter

This document provide details as if you would like to search base on filtered records criteria from Data Source. Initially you have to create two parameters. First ‘filter‘ parameter for criteria and second ‘searchInput‘ parameter for searching in receptive criteria.

filter – String (Multiple Values)

searchInput – String


Search Filter.png

Select desire criteria in which you would like to search

Search Filter.png

Go to Report > Select Expert > Record > Formula Editor > Paste Formula


if {?filter} = ‘SO’ AND HASVALUE({?searchInput}) then

    replace({Command.Sales Order#}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else if {?filter} = ‘DO’ AND HASVALUE({?searchInput}) then

    replace({Command.Doc No}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else if {?filter} = ‘PO’ AND HASVALUE({?searchInput}) then

    replace({Command.Customer PO#}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else if {?filter} = ‘Item Code’ AND HASVALUE({?searchInput}) then

    replace({Command.Item Code}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else if {?filter} = ‘Item Description’ AND HASVALUE({?searchInput}) then

    replace({Command.Item Description}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else if {?filter} = ‘Customer Name’ AND HASVALUE({?searchInput}) then

    replace({Command.Customer Name}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else if {?filter} = ‘Invoice No’ AND HASVALUE({?searchInput}) then

    replace({Command.Invoice No}, ‘ ‘, ”) like ‘*’ + totext({?searchInput}) + ‘*’

else

true


Search Filter - 2.png

Save and close Formula Editor

Click on View in the menu bar select Preview

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.