Friday, 27 May 2016

Latest Record From Table

JOB:

To get some in between records from a table:

static void LatestInvoiceId()
{
    CustInvoiceJour     custInvoiceJour;
    int i;
   
    while select * from custInvoiceJour
        order by custInvoiceJour.InvoiceDate desc
            where custInvoiceJour.OrderAccount == "A003"  // CustAccount or OrderAccount
    {
        i++;
        if(i<6)
    info(strFmt("%1",custInvoiceJour.InvoiceId));
    }
}
******************************
To get a specific record from a table:

 static void LatestInvoiceId()
{
    CustInvoiceJour     custInvoiceJour;
  
     select * from custInvoiceJour
        order by custInvoiceJour.InvoiceDate desc
            where custInvoiceJour.OrderAccount == "A003" ;// CustAccount or InvoiceAccount or OrderAccount
  
    info(strFmt("%1",custInvoiceJour.InvoiceId));
 
}






Wednesday, 18 May 2016

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;

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.

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

Get ProductMaster based on Product varients

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

 

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

SSRS : Contract Class & Debug it (parameter)

Hi,
Below is the sample code to Develop the contract class.
Here I need to pass the “Date” as the parameter, based on the selected data I need to get the data.

1) [DataContractAttribute]
class SrsRDPContractIndemnity
{
StartDate        tillDate;
}

2)  [DataMemberAttribute(“Date”)]
public StartDate asOfDate(StartDate _tilldate = today())
{
tillDate = _tilldate;
return tillDate;
}

Debug the contact class: 
static void SSRS_ContractclsDEBUG(Args _args)
{
ProdRouteTrans  prodRouteTrans;
//ACWAPIPETotalItemProdPerMonthTmp  acwaPIPETotalItemProdPerMonthTmp;
MZK_PayrollIndemnityTmp payrollIndemnityTmp;
IndemnityRDP dataprovider = new IndemnityRDP();
SrsRDPContractIndemnity    contract    = new SrsRDPContractIndemnity();
;
contract.asOfDate(today());
dataProvider.parmDataContract(contract);
dataProvider.processReport();
payrollIndemnityTmp = dataProvider.getDate();
}

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

Repeat the heading to the next page in SSRS Reports: To repeat the table header in the next page, follow these steps: ⦁    Open the repo...