1. Validate an enum
if(NetOccupied.valueStr() == enum2str(NetOccupied::Vacant))
CreateReservation.enabled(true);
else
CreateReservation.enabled(false);
2. Loop Enum :
DictEnum DEnum;
int i;
DEnum = new DictEnum(enumName2Id("GrossMarginGroup"));
for (i=1; i < DEnum.values(); i++)
{
switch(i)
{
case 1:
{
grossMarginByJobTmp.MachinePO = "MAC";
break;
}
case 2:
{
grossMarginByJobTmp.MachinePO = "PAR";
break;
}
case 3:
----
}
}
3. Issue with Enum Filtering :
In table enum text is stored. But Enum is getting as Lookup , when we select it is passing EnumID.
When you select Enum value in multi select ctrl, it brought index. But when u store Enum text in table. Then in order to filter the table, from enum we need to change in to text and then filter.
EnumId _transtypeid;
DictEnum _transtype = new DictEnum(100729);
allPackIds2 = _transtype.index2Label(conPeek(v2,i));
4. Get values of base enums using code in x++ :
static void getEnumValues(Args _args)
{
int counter,c;
DictEnum dictEnum;
String255 enum;
EnumId enumId = enumNum(NQ_VehicleStatus);
dictEnum = new DictEnum(enumId);
counter = dictEnum.values();
enum = enum2str(NQ_VehicleStatus::Maintenance);
print dictEnum.name2Value(enum);
/*
for(c = 0; c < counter; c++)
{
print dictEnum.name();
print c;
print dictEnum.index2Value(c);
print dictEnum.index2Symbol(c) ;
print dictEnum.index2Label(c);
}*/
pause;
}
No comments:
Post a Comment