💡 Set default values easily.
1. Overview
This interaction sets the default value to the only option if only one option is available in a select field.
2. Example
This example sets the default value for a select field to the only available option. If there's only one option, it sets the default value using the setValue function.
If multiple options are present, the script does nothing.
async function handler(C){
const data=await C.api.fetchSelectData({
recordId:"record-id-of-specified-select-field",
fieldId:"field-internal-id"
})
//If only one option is present
if(data.totalMatchedEntries==1){
return C.setValue("field-internal-id",[`${data.options[0].value}`]);
}
//If multiple options are present
else return ;
}📌 Need Help?
