I have a custom list with the id of "customlist_my...
# suitescript
e
I have a custom list with the id of "customlist_my_custom_list" I'm trying to load the record with record.load But record.load expects the numeric ID (let's say 555) Since this list is in a bundle, the Numeric ID will be different for each of our clients. Anyone know how I could get back the numeric Id when I only have the "text" id of "cutomlist_my_custom_list"?
e
You're trying to load the Custom List itself?
I wasn't aware you could load custom lists via
record.load()
. When I need to get the options of a Custom List, I usually run a query or search.
e
My end goal is to change the Name of an Option in the custom list. (Have 1 client that insists on a having a different name for one option)
a
unlock the list so clients can name it what they like
e
It's unlocked. The issue is, each bundle update resets it which is (understandably) annoying for them
a
not familiar with bundles vs. suiteapps, if you update the bundle can you not exclude that list from updates if it isn't ever changing?
or does it do a diff with the client data, sees the discrepancy and so overwrites?
sorry, I'm going full stack overflow meme here and not answering the question you asked 😄
e
No, I appreciate the thoughts
a
so are you writing a bundle install script that has a if accountId =xxx condition and then overwrite the dumb list?
e
thats the hope^
a
ugh clients are such a pain 😂
e
An interesting challenge. I acknowledge I have almost no context here and I haven't worked with Bundles in ages, but an idea off the top: Could you convert the List to a Custom Record? You could bundle up only the record definition with no instances. Your
afterInstall
script could build the default instances. The client could rename it once. Future updates shouldn't re-execute
afterInstall
, so the record should be safe from reverting.
That probably makes the list options harder to work with in your code though, so I don't know what that refactor effort looks like
Alternatively: use a
beforeUpdate
to create and store a map of ID to Name for the list options. Use
afterUpdate
to restore the map.
e
Could you convert the List to a Custom Record?
Yes, but it's exactly as you said- a lot of refactoring effort all for one client
e
Another option is to say no 🙂 tell the client you don't support renaming it
💯 2
❤️ 2
e
❤️ Love this idea
a
ok so you should be able to just search for all customlist with a seach type of
customlist
add a filter with your script id
custlist_my_custlist
and then just get the id of the only result... then you can record load with the id?
e
Hmm I didn't think I could search customlists, so I'll give that a try!
a
quick PoC worked in the console
1
e
awesome. really appreciate your efforts here @Anthony OConnor & @erictgrubaugh
a
you're welcome... do I get to be an honorary Eric? 😂
e
I hereby knight you Sir Eric Anthony OConnor. Welcome to the club!
🤭 1
😂 1
e
Pretty sure custom lists have an option to preserve data in bundles.
e
I believe you're right. But if we were to add a new option to that list in the future and it was set to preserve data, I don't believe the new option would be added (please correct me if I'm wrong)
e
In that case you can Merge
e
So Merge would leave the clients existing options (and names) untouched but add any news ones?
e
Hrm, maybe not.
The Merge Data option retains any data added to target account objects after bundle installation and at the same time updating data that was previously installed with the bundle.
Worth a test I guess
e
I was able to create a search on customlists and pass in the script id (customlist_my_custom_list). That got me back the Internal Id, which I could then use to load the Custom List record, loop through the options, and update the one to a different name. Thank you all for the help!
👍 1
e
Whatever your loop condition is, you could probably add that as a Search Filter so that you only get back the result(s) you actually care about
a
he's talking about lopping through the list of values in his custlist, not sure you can search filter for those? maybe you can? custlist searches aren't really something I think anyone has much exp with 😄
e
Right
Could switch to a query like
SELECT id FROM customlist2 WHERE name = '${listOption}'
name
is the field for the label on a custom list
e
I still need to Load the Custom List record in order to change the name of the Option though Essentially the list is: Red Blue Orange Yellow But the client wants it to be Red Blue Burnt Orange Yellow So I could get back the ID of "Orange" like you did in the Query, but in order to change the name to "Burnt Order", I need to load the Custom List called "Colors" then loop the Option List and then update Orange to Burnt Orange
e
ah, makes sense
a
think of the performance savings of removing the i=4 loop tho! 😂
e
Can't forget about those microseconds
e
lol y'all are too much