Is it possible to add an existing script field to ...
# suitescript
c
Is it possible to add an existing script field to more than one script record? The UI won't let me create another field with the same id so there must be a way of adding an existing field.
d
I don’t think that it is possible for two script records to share a field. Hopefully someone else can prove me wrong. I do know that the is of the field needs to be unique across all the fields. That is why you are getting the duplicate error. Why do you want the scripts to share the field? Maybe there is another way to accomplish the same goal.
c
I want each map/reduce script to hold a field with a the ID of a 'config' custom record.
that way, the same scripts/code can be used by different subsidiaries and different searches etc can be loaded based on the contents of the config records (each sub has its own config record).
A suitescript module looks at the script parameter on each deployment record to decide which config record to load. Having a different parameter name on each script is a pain.
If it's not possible, I will need to rethink the design.
Each script could have a differently named field that holds the config record ID and provide that ID into the custom module as an input upfront so the correct config record is loaded. This is the opposite of lazy loading though which is what I was trying to achieve.
b
laziness is just putting the mapping between script and script parameter in a js file and requiring that file to lookup the mapping
you can do the same thing with a custom record if you want it to be a little more accessible
d
I think a unique field is what I would consider doing, but that might also be my noob showing. 😂
@battk Would you elaborate a little on the custom record? Thank you.
b
make a custom record with 2 fields, one with the script id and another with the script parameter id
c
The basic idea is that the map/reduce script pulls records from an external system, each subsidiary in NS access a different instance of the external system therefore requires different URL, password, and other fields. Each script also has to load different searches. This is why each script must load its own config record.
b
find the matching record in the map reduce to find the id of the script parameter you are supposed to use
c
Each sub in NS has it's own deployment of the map/reduce
@battk that would still require a unique script param ID for each script right?
b
still different script parameter fields, its just a way to lookup which id to use