Greetings Community,
Here is my dilemma.
I am importing raw string data into attributes. Some of these attributes have a pre-set list of allowable values. In order to use:
attribute.setValue(<value>)
<value> has to be an integer. The problem is, I am not sure how I can compare my raw string data to the data in the pre-set list represented by an integer.
The image shows the properties of this one of the attributes. Note the pre-set list of allowable values.
If I am importing a raw string, how do I obtain the pre-set collection from the attribute using Aris Script?
Rick Beddoe
Cargill Aris Technical Analyst
Minneapolis, MN, USA
Hi Rick,
I've created my own function to obtain possible attribute values (for drop-down attribute selection values)
function getAttributeValues(iattrnum)
{
var AttrArray = new Array();
var attValTypes = ArisData.ActiveFilter().AttrValueTypeNums(iattrnum);
for(var a=0;a<attValTypes.length;a++) {
AttrArray.push(ArisData.ActiveFilter().AttrValueType(iattrnum, attValTypes[a]));
}
return AttrArray.sort();
}
It returns an array, if you want to do a quick test to determine if the value that you are importing is part of the pre-defined list you can use the command join to parse the array into a string and search the string for the imported value.
In order to use the setValue() command for above you don't need the integer - if your imported value is part of the pre-defined list you can use setValue with the imported value. for instance setValue("Removed") with update your attribute successfully.
Ciska
Thanks Ciska,
AttrValueTypeNums was the function I was looking for. I can use JSLINQ to easily query the collection for a match without using 'join'. It may sound strange, but I am not a fan of comparing portions of a string.
I tried using the string value as in setValue("Removed") and it does not work. I could only get it to work with an integer.
Rick Beddoe
Cargill Aris Technical Analyst
Minneapolis, MN, USA
Well, I tried using setValue with just text and now it seems to be working fine. Not sure what I did wrong before, but that will be much easier.
Still good to know how to get that info using AttrValueTypeNums. Thanks Ciska :)
Rick Beddoe
Cargill Aris Technical Analyst
Minneapolis, MN, USA