How to Set Logic Based Product Input Filter
If you need to add a product picker with a pre-filtered product (based on e.g., Sales Organization) somewhere where the product is not a default part of the context (e.g., documents in Agreements & Promotions), you can use the Product Input Filter logic. The overall idea is very similar to the approach used for filtering the customer input described in How to Set Logic Based Customer Input Filter for Quotes. Just select "Product Input Filter" as Nature of the logic (instead of "Customer Input Filter"). You will then call it like this:
api.product​(String attributeName, String sku, String filterFormulaName, Object filterFormulaParam)
But doing per lines is a bit tricky. This api.product call will always create an input for you, meaning that after every recalculation the input selected by the user will "disappear". But creating this input just once might not be as easy as it looks. The following snippet shows one way to do it:
def salesOrg = api.getElement("SalesOrganization")
//Check if you have any product already in the context.
//Calling api.product() without any parameters is the way how to check it and NOT create the product input picker
if(api.product() == null) {
//Create the product picker with the filter logic here. The "ProductInputFilter" is the name of the filter logic, salesOrg is in this example one input parameter.
api.product("sku", null, "ProductInputFilter", salesOrg)
}
//Return the SKU of the product already in the context. FYI this is cached after the first call so you do not need to worry about performance of this call.
return api.product("sku")
Found an issue in documentation? Write to us.
Â