0
votes

I am trying to add formulatext filter with DECODE function in a search in 2.0 Scheduled script.

search.createFilter({
        name: "formulatext:DECODE({custbody_sfdc_comm_id},"+groups+",0)",
        join: null,
        operator: search.Operator.IS,
        values: "1"
 })

groups is an array which is passed to search custbody_sfdc_comm_id field values in that array. But when executed, it is throwing invalid search criteria

1

1 Answers

0
votes

When using a formula in the search.createFilter() constructor, you should specify the formula in the formula parameter rather than as part of the name:

search.createFilter({
    name: "formulatext",
    formula: "DECODE({custbody_sfdc_comm_id},"+groups+",0)",
    join: null,
    operator: search.Operator.IS,
    values: "1"
})