I have created a new record type to track customer...
# suitescript
w
I have created a new record type to track customer equipment. On this I want to be able to have a drop down list to pick one of the customers locations from the addressbook. After talking with Netsuite support they tell me there is no way to use a Transaction Body Field List/Record to access the addressbook for this. They also said that there is no way to script for it. So I have been trying to come up with a different way to have my end user pick a location after they have picked a customer. Right now I have created a dialog.create that shows all the customer addresses in the addressbook, beside each on the addresses I have an onClick button that brings up an alert to show me the AddressID. The problem is I need to be able to access this AddressID for the rest of my script so I can use it to fill in the Location field. The problem is the script portion to cause the onClick and the alert are inside the HTML of the dialog.create.
Copy code
var customerAddressIDSublistValue = customerRecord.getSublistText({
                    sublistId: 'addressbook',
                    fieldId: 'addressid',
                    line: i
                });

                customerAddress += '<tr><td><button id="' + customerAddressIDSublistValue +'" onClick="reply_click(this.id)">Click me</button></td><td align="right">' + customerAddressIDSublistValue + ' ' + customerAddressSublistValue + '</td></tr>';
            }

            dialog.create({
                title: 'Customer Addresses',
                message: customerAddress + '<script type="text/javascript">function reply_click(clicked_id){alert(clicked_id);rec.setValue({\n' +
                    '                    fieldId: \'custrecord141\',\n' +
                    '                    value: clicked_id\n' +
                    '                });}</script>',
                buttons: [
                {label: 'OK', value: 1},
                {label: 'Update', value: 2},
                ]
            }).then(success).catch(failure);
b
to be clear, i dont think support gave you the correct answer
you can create a custom field which is a list of address books
you can also create a custom field which is a list of entities to use for source filtering
this is not something that even requires scripting
w
But they need to be filtered by customer. Exactly the same as a Sales Orders ship to box where you pick the location based on the customer.
b
that is what the source filtering is for
source filtering limits the choices of the address book select to values where the addres book''s entity matches the entity select
create an entity select field on the custom record
create an address book select field on the custom record
on the address book select, go to the sourcing and filtering subtab and set the source list to the entity select field and the source filter by to Entity
👍 1
You can also use filtering to limit the entities where the type is equal to Customer
w
Ok.. that might be my problem. I have my Entity list as a Customer list. Let me re-do it and try again. Thanks
OMG That was it... I had the wrong type selected for my Customers. Changing it to Entity fixed it. Thank you very much.
👍 1