Somewhat related to this earlier question on defaulting fields, I'm having an issue using a front-end function to default an empty relationship field before saving the record.
My frontend function is tied to a save and complete button on my call form.
Its referring to a queue relation that has four attributes id, number, name, default.
![](https://community.rei3.de/assets/files/2023-09-19/1695104755-955107-image.png)
![](https://community.rei3.de/assets/files/2023-09-19/1695105057-865093-image.png)
I'm calling a backend function that dynamically returns the queue ID attribute marked as the default fallback (its an INT). This is then passed to set_field_value() as res. However whether I use res, or manually enter an ID (eg:4) it never seems to update the field when the button is clicked. The console logs the id (4) to the console though.
Yet for the set_field_value() above that for the call status relationship the defaulting (using a preset UUID now but used a raw ID previously) works. Tried using ID, number, name with no luck.
My default queue is a preset, but an unprotected one. I don't want to use that as over time the fallback queue will change.
I must be missing something obvious? I'm using a front-end function as I don't want the API affected by back-end triggers, this logic should only be applied to GUI users manually creating records.
//Set status to completed
app.set_field_value({0:nas_calltracker.phonecall.call_status}, app.get_preset_record_id('39413f0b-607c-46e0-9858-a5bdfce9c005'));
//set the completed datetime here in the GUI after the operator saves if its empty
if (app.get_field_value({0:nas_calltracker.phonecall.call_completed}) === null) {
let curr_time = Math.floor(new Date().getTime() / 1000);
app.set_field_value({0:nas_calltracker.phonecall.call_completed}, curr_time);
}
//if the queue is null default it to queue fallback.
if (app.get_field_value({0:nas_calltracker.phonecall.call_queue}) === null) {
app.call_backend({nas_calltracker.get_queue_id_bydefault}).then(
res => {
if (res === null) {
console.log('No default Queue defined');
}
else {
app.set_field_value({0:nas_calltracker.phonecall.call_queue}, res);
console.log(res);
}
},
err => { }
)
}
//save
app.record_save();
app.value_store_set('saveclose_clicked', 1);