I have a requirement wherein I have to compare a field value on an item with bunch of values (over 30) to perform an action. As I didn't like the idea of hard coding the values in the script I thought of creating a static picklist and accessing it/its values and accessing it from the script. Is there an API to access a picklist from script?
If there is no API, any other suggestions?
Solved! Go to Solution.
Solved by mpasumarti. Go to Solution.
you can access a multi-select picklist field in an existing item, and access the values use
item.PICKLISTX[0]
item.PICKLISTX[1]
...
as I know there is no script access to picklist manager currently. you have to create an item with the picklist and access it.
I don't think there is a way of doing this either.
You could make your script call API - /api/rest/v1/setups/picklists/{picklistId} to get the values, but this seems a little bit too much.
I would rather create a hidden attribute that is attached to the picklist so that I can easily reference it.
I went ahead and implemented a function as mentioned below with static array to avoid jumping through hoops to get to what I need.
function isProprietaryItem(thisItem) {
var proprietaryDocTypes = ["ALP", "BEP", "DSD", "FDS", "SFS", "FS", "HRS", "PDS", "RFS", "SPP", "SRS", "PDR", "REF", "DSD", "ERW", "PRN", "FDD", "SRS", "HDD", "DVT", "TRS", "TNS", "WCA", "MRD", "PBP", "MCD", "DTM", "PCM", "RTP", "FAP", "FAC", "QTP", "SIP"];
var itemType = thisItem.ITEM_TYPE_PREFIX;
if(itemType !== null) {
var typeIndex = proprietaryDocTypes.indexOf(itemType);
if (typeIndex !== null && typeIndex > -1) {
return true;
}
}
return false;
}