How do you set the externalid for a folder?
# suitescript
t
How do you set the externalid for a folder?
b
unusual request
t
It is something the docs say I can search by, but there is no option to set it. I'm trying to dynamically get a folder to save documents in
b
there are 2 ways you can set it
first is load the record using N/record, set the externalid using setValue, and then save the record
second is to submit the field using N/record
t
Ok, I was thinking it would need to be something like that. Is that possible to do from an install script as well? Or is there a better way to dynamically get a folder?
b
for suitescript, its rare to set the externalid since it cannot be used in the way csv import or suitetalk can
you can do it from an install script, but i don't know why you simply can't search for the folder without using external id
t
I can, I just get multiple folders back if I'm searching by name if we have a generic folder name like 'Images' or anything like that
I was thinking of doing it by parent folder and folder name, but then I saw externalid and thought just having one unique identifier would just be the best shortcut
b
im not sure where you are getting the name from, but it might work out better if you get the folder's internal id instead.
t
I'll try to make this a bit clearer cause there might be a better way to do it. I'm trying to save images to a folder after getting them from an external api call. As of right now I am just using the folder internal ID that is hard coded to specify where to save it, but I didn't think that would stay the same after bundling and installing on a different account
n
@Tyler Bobik What I've done in the past is add a parameter to the script that is the internal id of the folder I want to put images in. Create the folder in the environment(s), when you deploy to that environment just update the parameter. When the script runs, pick up the parameter and you're golden. I've also sometimes, if no param has been set and I know what I want the folder to be called, searched for the folder by name, if it doesn't exist, create it if it does, well I now have the folder id. Would that work for you?
t
That could work, my only issue would be that if it's a folder named shared by other bundles installed on an account. But I was just thinking of using the parent folder as well in the search since that will be unique to the app