//Set the dimesnion
public static RecId setDimension(RecId _recID,str _DimName,str _DimValue)
{
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
DimensionAttributeValueSetStorage davss;
RecId defaultDimension;
davss = DimensionAttributeValueSetStorage::find(_recID);
dimAttr = DimensionAttribute::findByName(_DimName);
dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, _DimValue, false, true);
if(dimAttrValue)
{
davss.addItem(dimAttrValue);
defaultDimension = davss.save();
}
return defaultDimension;
}
//edit method
[SysClientCacheDataMethodAttribute(true)]
static edit DimensionValue DepartmentMethod(InventJournalTrans _InventJournalTrans,boolean _set,DimensionValue _DimensionValue)
{
DimensionAttribute dimensionAttribute;
DimensionAttributeValueSetItem valueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
DimensionFinancialTag _DimensionFinancialTag;
DimensionAttributeDirCategory dimAttributeDirCategory;
DimensionEntryControl _DimensionEntryControl;
dimensionAttribute = DimensionAttribute::findByName("Department");
if(_set)
{
_InventJournalTrans.DefaultDimension = InventJournalMovement_Extension::setDimension(_InventJournalTrans.DefaultDimension,"Department",_DimensionValue);
}
select * from valueSetItem
where valueSetItem.DimensionAttributeValueSet == _InventJournalTrans.DefaultDimension
join DimensionAttribute, EntityInstance, RecId, HashKey, IsSuspended, ActiveFrom, ActiveTo from dimAttrValue
where dimAttrValue.RecId == valueSetItem.DimensionAttributeValue &&
dimAttrValue.IsDeleted == false
&& dimAttrValue.DimensionAttribute==dimensionAttribute.RecId
join * from dimAttr
where dimAttr.RecId == dimAttrValue.DimensionAttribute
;
return valueSetItem.DisplayValue;
}
//Lookup
[FormControlEventHandler(formControlStr(InventJournalCount, DepartmentMethod), FormControlEventType::Lookup)]
public static void DepartmentMethod_OnLookup(FormControl sender, FormControlEventArgs e)
{
DimensionAttribute dimensionAttribute;
DimensionAttributeDirCategory dimAttributeDirCategory;
Query query = new Query();
SysTableLookup sysTableLookup;
dimensionAttribute = DimensionAttribute::findByName("Department");//Department//Purpose
if (dimensionAttribute.Type == DimensionAttributeType::CustomList)
{
select firstonly DirCategory from dimAttributeDirCategory where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;
sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), sender);
// Add name field to be shown in the lookup form.
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
//sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, RecId));
query = new Query();
query.addDataSource(tableNum(DimensionFinancialTag)).addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).value(queryValue(dimAttributeDirCategory.DirCategory));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
}
No comments:
Post a Comment