Wokflow approver name and date time

HI, Below code used to get workflow approve name based on purchase order Id or RecId.

select firstonly workflowTrackingStatusTable
order by RecId desc
where workflowTrackingStatusTable.ContextTableId == tableNum(PurchTable)
&& workflowTrackingStatusTable.ContextRecId == purchTable.RecId
&& workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Completed;
select * from workflowTrackingTable
order by CreatedDateTime desc, RecId desc
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval;

select firstOnly dirPersonUser
order by ValidTo desc
where dirPersonUser.User == workflowTrackingTable.User;

select dirPerson
where dirPerson.RecId == dirPersonUser.PersonParty
join hcmWorker
where hcmWorker.Person == dirPerson.RecId;

select hcmPositionWorkerAssignment
order by ValidTo desc
where hcmPositionWorkerAssignment.Worker == hcmWorker.RecId
join hcmPosition
where hcmPosition.RecId == hcmPositionWorkerAssignment.Position;

name = dirPerson.Name;

select * from workflowTrackingCommentTable where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId;

approvedBy = strFmt(“@SYS3492” + ‘ < %1, %2 – %3 >’, name,
hcmPosition.description(),
DateTimeUtil::applyTimeZoneOffset(workflowTrackingCommentTable.createdDateTime, DateTimeUtil::getCompanyTimeZone()));

notexists Join in X++

HI , Below sample used to get data from same table using 2(A,B) buffer’s.  Ex: Should get data from A which doesn’t have records in B based on catalog condition.

 

while select priceDiscTableSource

where priceDiscTableSource.OCSCatalogueRelation == sourceCatalog
notexists join priceDiscTableDestination
where priceDiscTableSource.ItemRelation == priceDiscTableDestination.ItemRelation
&& priceDiscTableDestination.OCSCatalogueRelation == diaCatalogDestination

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);

 

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