Given just the item Id, find or create the inventory dimension.
Friday, 17 April 2015
Get Inventory Dimension
Given just the item Id, find or create the inventory dimension.
Thursday, 12 March 2015
Find BatchId with a KanbanCardId
Public InventBatchId findByKanBanCardId(KanbanCardId _kanbanCardId)
{
Kanban kanban;
KanbanCard kanbanCard;
KanbanJob kanbanJob;
InventTransOrigin inventTransOrigin;
InventTrans inventTrans;
InventDim inventDim;
// Obviously for Batches of ONE
select firstOnly InventBatchId from inventDim
join inventTrans
where inventDim.inventDimId == inventTrans.inventDimId
join inventTransOrigin
where inventTrans.InventTransOrigin == inventTransOrigin.RecId
join kanbanJob
where inventTransOrigin.InventTransId == kanbanJob.InventTransId
&& inventTransOrigin.dataAreaId == kanbanJob.InventTransDataAreaId
join kanbanCard
where kanbanJob.RecId == kanbanCard.kanban
&& kanbanCard.CardId == _kanbanCardId;
return inventDim.InventBatchId;
}
Attach a document
static void attachDoc(RefTableId _refTableId, RefRecId _refRecId, selectableDataArea _refCompanyId,
FileName _name)
{
DocuRef docuRef;
DocuActionArchive archive;
;
docuRef.clear();
docuRef.RefRecId = _refRecId;
docuRef.RefTableId = _refTableId;
docuRef.RefCompanyId = _refCompanyId;
docuRef.Name = _name;
docuRef.TypeId = 'File';
docuRef.insert();
archive = new DocuActionArchive();
archive.add(docuRef, _name);
}
Thursday, 19 February 2015
Query Build Range in Forms
Override the executeQuery() method the data source (on the Form/Data Sources/data source) to set the query. Note that the ranges are cleared before setting as they are persistent.
This example assumes that there is one datasource table, to make it easier;
public void executeQuery()
{
<variable definitions here>
QueryBuildRange qbr;
<dataNameOne> = element.design().controlName("<controlNameOne>").valueStr();
<dataNameTwo> = str2enum(prodStatus,element.design().controlName("<controlNameTwo>").valueStr());
<dataNameThree = str2enum(calcType,element.design().controlName("<controlNameThree>").valueStr());
<dataNameFour> = str2enum(bomCalc,element.design().controlName("<controlNameFour>").valueStr());
this.query().dataSourceTable(tableNum(<datasourceTable>)).clearRanges();
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameOne>));
qbr.value(<dataNameOne>);
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameTwo>));
qbr.value(strFmt("%1",<dataNameTwo>));
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameThree>));
qbr.value(strFmt("%1",<dataNameThree>));
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameFour>));
qbr.value(strFmt("%1",<dataNameFour>));
super();
}
Then change the trigger, in this case a click event, to run the execute the query above. Note the _ds extension, which denotes a datasource object.
void clicked()
{
super();
<datasourceTable>_ds.executeQuery();
}
This is not best practice, as you can build the range as a global object and add the values in the ranges in the executeQuery() method.
This example assumes that there is one datasource table, to make it easier;
public void executeQuery()
{
<variable definitions here>
QueryBuildRange qbr;
<dataNameOne> = element.design().controlName("<controlNameOne>").valueStr();
<dataNameTwo> = str2enum(prodStatus,element.design().controlName("<controlNameTwo>").valueStr());
<dataNameThree = str2enum(calcType,element.design().controlName("<controlNameThree>").valueStr());
<dataNameFour> = str2enum(bomCalc,element.design().controlName("<controlNameFour>").valueStr());
this.query().dataSourceTable(tableNum(<datasourceTable>)).clearRanges();
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameOne>));
qbr.value(<dataNameOne>);
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameTwo>));
qbr.value(strFmt("%1",<dataNameTwo>));
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameThree>));
qbr.value(strFmt("%1",<dataNameThree>));
qbr = this.query().dataSourceTable(tableNum(<datasourceTable>)).addRange(fieldNum(<datasourceTable>,<fieldNameFour>));
qbr.value(strFmt("%1",<dataNameFour>));
super();
}
Then change the trigger, in this case a click event, to run the execute the query above. Note the _ds extension, which denotes a datasource object.
void clicked()
{
super();
<datasourceTable>_ds.executeQuery();
}
This is not best practice, as you can build the range as a global object and add the values in the ranges in the executeQuery() method.
Tuesday, 17 February 2015
Product Attribute Value
Feed the method with an itemid and the attribute name and get back the value of the attribute (if it exists)
{
inventTable InventTable;
EcoResProductAttributeValue ecoResProductAttributeValue;
EcoResAttribute ecoResAttribute;
EcoResValue ecoResValue;
select InventTable where InventTable.itemid == _itemId
join RecId from ecoResProductAttributeValue
where ecoResProductAttributeValue.Product == InventTable.Product
join Name from ecoResAttribute
where ecoResProductAttributeValue.Attribute == ecoResAttribute.RecId &&
EcoResAttribute.Name == _attributeName
join ecoResValue
where ecoResValue.RecId == ecoResProductAttributeValue.Value;
return ecoResValue.value();
}
Thursday, 11 December 2014
Get Inventory On Hand
static void InventoryOnHand(Args _args)
{
InventDim inventDim;
InventDimParm inventDimParm;
InventOnHand inventOnHand;
InventTable inventtable;
ItemId itemId;
;
itemId = '28-010020';
inventDim.InventSiteId = "1"; // For site # 1
inventDimParm.initFromInventDim(inventDim);
inventOnHand = InventOnHand::newItemDim(itemId, inventDim, inventDimParm);
if (inventOnHand.availPhysical())
{
info(strfmt("Item Id %1 Available Physical %2",
inventtable.ItemId,inventOnHand.availPhysical()));
}
}
Friday, 28 November 2014
Query Object Not Initialised On RDP
The error (in this case, printing the External Customer Account Statement)
Query object not initialised.
Stack trace
(C)\Classes\CustAccountStatementExtController\prePromptModifyContract - line 4
(C)\Classes\SrsReportRunController\startOperation - line 7
(C)\Classes\SrsPrintMgmtController\startOperation - line 14
(C)\Classes\SrsPrintMgmtFormLetterController\startOperation - line 14
(C)\Classes\CustAccountStatementExtController\main - line 6
Stack trace
(C)\Classes\CustAccountStatementExtController\prePromptModifyContract - line 4
(C)\Classes\SrsReportRunController\startOperation - line 7
(C)\Classes\SrsPrintMgmtController\startOperation - line 14
(C)\Classes\SrsPrintMgmtFormLetterController\startOperation - line 14
(C)\Classes\CustAccountStatementExtController\main - line 6
The cause
[
SRSReportQueryAttribute(queryStr(CustAccountStatementExtBaseData)),
SRSReportParameterAttribute(classStr(CustAccountStatementExtContract))
]
public class CustAccountStatementExtDP extends SrsReportDataProviderPreProcess
{
CustAccountStatementExtTmp custAccountStatementExtTmpNew;
boolean giroCreated;
}
SRSReportQueryAttribute(queryStr(CustAccountStatementExtBaseData)),
SRSReportParameterAttribute(classStr(CustAccountStatementExtContract))
]
public class CustAccountStatementExtDP extends SrsReportDataProviderPreProcess
{
CustAccountStatementExtTmp custAccountStatementExtTmpNew;
boolean giroCreated;
}
The Solution
In Visual Studio, select the dataset that the report uses (CustAccountStatementExtDS) and set the property 'Dynamic Filters' to false. This will cause the data map to be re-read.
Then rebuild and redeploy the report.
Subscribe to:
Posts (Atom)