Month: December 2015

Build query range on Multiple Tables

str qvalue;

qvalue = strFmt(‘((%1 like “%5”) || (%2 like “%5”) || (%3 like “%5”) || (%4 like “%5”) || (%6 like “%5”) || (%7 like “%5”) || (%8 like “%5”))’,
fieldStr(ProductsAndVariants, ItemId),
fieldStr(ProductsAndVariants, ItemName),
fieldStr(ProductsAndVariants, VariantDescription),
fieldStr(ProductsAndVariants, ItemSearchName),
_searchText,
fieldStr(CustVendExternalItem, ExternalItemId ),
fieldStr(CustVendExternalItem, ExternalItemTxt),
fieldStr(InventItemBarcode, itemBarCode));

 

qbs = query.addDataSource(tableNum(ProductAndVariantSearch));
qbr = qbs.addRange(fieldNum(ProductAndVariantSearch, DataAreaId));
qbr.value(qvalue);

 

Advertisements

Auto build query based on query

Apply the ranges from query :

 

public void executeQuery()
{
if(call)
{
if(element.args().caller())
{
q = inventLookup.getQuery();
for(i = 1; i <= q.dataSourceCount(); i++)
{
rangeCount = q.dataSourceNo(i).rangeCount();
for(j = 1; j <= rangeCount; j++)
{
QBR = q.dataSourceNo(i).range(j);
dictField = new DictField(QBR.table(),fieldname2id(QBR.table(),QBR.name()));
fieldLabel = dictField.label();
if(QBR.value())
{
ProductAndVariantSearch_q.dataSourceTable(QBR.table()).addRange(fieldname2id(QBR.table(),QBR.name())).value(QBR.value());
}
}
}
}
}

super();
}

Adding field in Dialog

  1. ClassDeclaration:

DialogField confirmMessage;

boolean confirm;

2) Dialog :

confirmMessage = dialog.addFieldValue(extendedTypeStr(NoYesId),Confirm, “Test”);

3) get from Dialog:

confirm = confirmMessage.value();

4) ValidateValue:

if(OSSTmpProfileField.DataConfirmationMessage == NoYes::Yes && !_Check)
    {
        throw error("value missing"); 
    }

Get ProductMaster based on Product varients

HI, Below is the sample code used to get Product number based on product variants.

Since while trying to get product number directly we will get like “140 :: varient”, we wont be able to get product “140” and further difficult fetch data based on product.

 

ecoResProduct = EcoResProduct::find(this.Product);
ecoResDistinctProductVariant = EcoResDistinctProductVariant::find(this.Product);

EcoResProductMaster::find(ecoResDistinctProductVariant.ProductMaster).DisplayProductNumber

Moving attachment from one table to other table. Source:DocuRef

HI, Here is requirement to move one table attachment data to other table attachment data., below is sample code:

while select Name, typeid from docuSerach
where docuSerach.RefCompanyId == PurchParmLine.dataAreaId
&& docuSerach.RefRecId == PurchParmLine.RecId
{
docuinsert.RefRecId = this.RecId;
docuinsert.RefTableId = this.TableId;
docuinsert.RefCompanyId = this.dataAreaId;
docuinsert.Name = docuSerach.Name;
docuinsert.TypeId = docuSerach.typeid;
docuinsert.insert();
}

PurchParmTable field data update

HI, when we create new fields in PurchParmTable and need to fill the data when doing product receipt, we need to use PurchFormLetterParmData class to get it done.

we need to create same fields in VendDocumentTableMap  and after restore need to give corresponding field mapping in relation. Use createParmTable method to get data.

 

InventDim getting and updating data

HI, below is sample code to update(kind of update) InventDim table and get required data. Get wmslocation from below code and assign inventDIm

inventDimLoc.InventLocationId = SalesTable.InventLocationId;
inventDimLoc.InventSiteId = SalesTable.InventSiteId;
inventDimLoc.wMSLocationId =VendTable::find(InventTable::find(salesLine.itemid).PrimaryVendorId).ReturnLocation;
inventDimLoc = InventDim::findOrCreate(inventDimLoc);
salesLine.InventDimId = inventDimLoc.inventDimId;