Using a radio button in code studio for the Address Lookup widget

Hi,

Can anyone help with a radio button issue ?

I’m trying to add one to the Addressbase Address Lookup widget from the Appshare. It is displaying a choice data-type which has two choice id’s.

So in ‘get_settings’, I have added:

contact_type: {
main_label:‘contact_type’,
base_format:‘choice’,
// choices: cs.build_choices(‘data_type’, {‘base_format’:‘choice’,‘data_type_id’:‘DTP0000119GBJZS1’}),
choices: cs.build_choices(‘data_type’, {‘base_format’:‘choice’}),
},

As you can see, I have tried using the base_format and the ‘data_type_id’.

I’m also binding the input to v-model using v-model=‘picked’ and then using that value to assign a cs reference for the choice type (either ‘agent’ or ‘owner’ to the ‘fetch’ object. However, not getting very far. I keep hitting errors such as:

‘Reference - field_path - No replacement found. (DTC0000246GBJZS1) is not available’

The result is that the radio button option selected is not saved.

Thanks for any help,

Mark

Hi Mark,

You can use the below methods to get data type choice values.

let items = cs.get_choices('DTP00000.....');

or

let items = cs.build_choices('data_type', { 'base_format' : 'choice', 'data_type_id' : 'DTP00000.....'})

The one that you have commented out should be working.

There is another way using component, but there may be a bug which I already raised for investigation

let comp = cs.get_component('DTP00000.....');
let items = comp.get_choices();

What issues are you getting?

Hi Ged, thanks for the reply.

The second one does work. So, I’m getting this in the array in detective:

image

However, when I save the record, the selected option on radio button is not saved and reverts back to blank.

Mark

I’m assuming this is a CS widget? how are you saving your data?

I would probably need to see a bit more code to be able to help.

Hi, the widget is here on the appshare:

https://community.netcall.com/appshare/i/loqate-address-lookup-widget/

In main.js action_save method, have you defined the field path and value for your new radio button?

This is what I have:

So the setting called “contact_type” is the actual setting for picking your choice value that you want to save, right?

You need another setting so that you could define the actual field path where the “contact_type” value should be saved to, same way how the “address_line1” etc are defined.

What does your “data_to_save” array look like?

This is the data_to_save array:

image

So, assuming is :PRO0000360GBJZS1 the field path to the your data type choice and the DTC0000246GBJZS1 is the correct data type choice value, that data should save.

Are you seeing anything in detective log when trying to save? can you look at the event that does the saving and see if the data type choice is being passed in?

:PRO0000360GBJZS1 is the field path for the data type choice, yes.
I’m not seeing any errors in the log. When I change a value and save, this is what detective shows:

If you click yhe “Saved Record 28139…” link that should show a popup with all the values that are being saved, check if it is there.

Thanks (did not know that!). Looks like the new value is being saved:

Have you got something like the Object explorer ? check that record and all the properties to see if they are there, maybe it is being saved but there is an issue elsewhere?

I do yes. I’ll have a look. Thanks for all your help: much appreciated :slight_smile:

Having had a chat with Mark and a look around the widget. The values were being saved correctly into the backend database. Issue was the when the data was pulled on page load for display it was not setting the “current” selection on the radio button.