shawleigh17
shawleigh17

Reputation: 1187

Show custom text in a NetSuite drop down without creating separate field?

I already got this working by creating a separate field and then mirroring the information, but is there a way to change what shows up in the text for the drop down? I have a list of locations. Right now, it just shows the location name, but I need it to show the location number, and then the name so, "100 Location A" instead of just "Location A". Is there an easy way to do this? I have fields that have both pieces of information, and I just want to concatenate it. The method I am doing right now to accomplish this is taking a long time to populate the new field, as there are several of these locations. Takes around 5 seconds, I'd say, and I just want to make that faster.

Upvotes: 1

Views: 934

Answers (1)

Todd Grimm
Todd Grimm

Reputation: 544

Unfortunately I think you are going to have to create a new field for this, however not necessarily a 'new' field which could cause confusion. It might sound tricky, but what you will want to do is add a custom field via code and hide the natural location field. In the beforeLoad you could hide the natural Location field, and add a new select field. The nice thing about adding the field via code is you will get to decide what the text values are present, as well as what each value's internal id will be. In your beforeLoad do a search of Locations that will return what you want, Name, ID, etc. Build an object from the results dynamically setting the object's property name to something like "100 Location A", and its value to the internal id of the Location. Once you have your object, you can iterate over it using Object.keys(objName).forEach(function (propertyName) {}) to set the Select options for the new custom List field. Do make sure you account for user permissions in this code, either run the UE as an Admin, or use a SUITElet to run the location search and return your object. You will also need to make sure you are checking to see if the natural location field was already set in your beforeLoad, if it was you want to get its value so that you set the Default selection on your custom list field properly. From there you just need to make sure you set the natural location field to whatever was chosen in your custom field in the beforeSubmit function. I have done something similar in the past and it made no noticeable impact on performance even though it was searching against thousands of transaction records, not just a few locations. A bit of work to get done, but if done right, nobody would be able to tell by interacting with the record that anything was changed. Hope that helps!

Upvotes: 1

Related Questions