$p("setRequestFields"): ([String]) -> undefined
Technical documentation
This is technical documentation for the setRequestFields function. For broader context, see our documentation on Editing Fields/Hiding Item.
You may send us any relevant data for your items, but you might not want those fields returned for rendering a recommendation on your side. In that case, you can use the SDK function $p("setRequestFields", FIELD_ARRAY):
//Request fields name, title, and url for returned recommendations
$p("setRequestFields",["name","title","url"])
Invoking this function before fetching the recommendation will make sure that recommendations only have these fields for returned metadata.
In order to make sure that we return only items that have all the request fields you specified, you can run the following before fetching recommendations. Here, AON = all or nothing.
$p("setRequestFieldsAON",true)
If there is a subset of request fields that you want us to always return, but it is not the full set of request fields, then you can separately set the mandatory request fields. Note that the set of mandatory request fields you set must be a subset of the set of request fields, otherwise we will not return anything.
//Mandatory request fields title, and url for returned recommendations
$p("setMandatoryRequestFields",["title","url"])
Only items with the mandatory fields are returned. The remaining (non-mandatory) request fields are returned for the items that have them.
Note that if you run setRequestFieldsAON
that takes precedence over setMandatoryRequestFields
.