Month: May 2018

Posting Product receipt for PO

Hi, Below sample code used to post product receipt for specific PO.

purchTable = PurchTable::find(‘PO0012555’);
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchformLetter.getLast();
purchFormLetter.transDate(transDate);
numberSeq  = NumberSeq::newGetNum(PurchParameters::numRefPurchPackingSlipId()).num();
purchFormLetter.update(purchTable,
“14”,// numberSeq, //this is coming out blank
transDate,
PurchUpDate::All,
AccountOrder::None,
false,
false);

Advertisements

COC for Close method on Form

HI, From Update12, its possible to write COC for forms as well!

[ExtensionOf(formStr(StageUpdate))]
final class StageUpdate_Extension
{
public void closeOk()
{

next closeOk();
Formrun thisForm = @this;
FormRun callerForm = thisForm.args().caller();

if( callerForm.name() == formstr(WorkOrderTable))

{

FormDataSource woLineDS = callerForm.dataSource(formDataSourceStr(WorkOrderTable,WorkOrderLine ));
WorkOrderLine selectedWOLine = woLineDs.cursor();

}

}

lookupReference & lookup on Form

public Common lookupReference(FormReferenceControl _formReferenceControl)
{
SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tablenum(ParmJobVariant), _formReferenceControl, true);
Query query;
QueryBuildDataSource qbdsJobVariant;
QueryBuildDataSource qbdsJobTypeVariant;
QueryBuildRange queryBuildRange;

sysTableLookup.addLookupfield(fieldnum(ParmJobVariant, JobVariantId));
sysTableLookup.addLookupfield(fieldnum(ParmJobVariant, Description));

query = new Query();
qbdsJobVariant = query.addDataSource(tablenum(ParmJobVariant));
qbdsJobTypeVariant = qbdsJobVariant.addDataSource(tableNum(ParmJobTypeVariant));
qbdsJobTypeVariant.relations(true);
qbdsJobTypeVariant.joinMode(JoinMode::ExistsJoin);

queryBuildRange = qbdsJobTypeVariant.addRange(fieldnum(ParmJobTypeVariant, JobType));
queryBuildRange.value(SysQuery::value(workOrderLine.JobType));

sysTableLookup.parmQuery(query);
return sysTableLookup.performFormLookup();
}

 

public void lookup()
{
MROObjectRecID objectrecid;
sysTableLookup sysTableLookup = sysTableLookup::newParameters(tablenum(ParmObjectCounter), this);
Query query;
QueryBuildDataSource qbds;
QueryBuildRange queryBuildRange;

objectrecid = WorkOrderLine.Object;

query = new Query();
qbds = query.addDataSource(tablenum(ParmObjectCounter));
qbds = qbds.addDataSource(tableNum(ObjectCounter));
qbds.joinMode(JoinMode::ExistsJoin);
qbds.relations(true);

qbds.addRange(fieldNum(ObjectCounter,Object)).value(queryValue(objectrecid));

qbds.addSortField(fieldNum(ParmObjectCounter, CounterID));
qbds.addSortField(fieldnum(ParmObjectCounter, Name));
qbds.addSortField(fieldnum(ParmObjectCounter, SequenceNumber));
qbds.orderMode(OrderMode::GroupBy);

sysTableLookup.addLookupfield(fieldnum(ParmObjectCounter, CounterID));
sysTableLookup.addLookupfield(fieldnum(ParmObjectCounter, Name));
sysTableLookup.addLookupfield(fieldnum(ParmObjectCounter, SequenceNumber));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

Lookup by cancel super:

[FormControlEventHandler(formControlStr(WorkOrderTable, WorkOrderLine_JobTypeCopy1), FormControlEventType::Lookup)]
public static void WorkOrderLine_JobTypeCopy1_OnLookup(FormControl sender, FormControlEventArgs e)
{

FormRun             formRun          = sender.formRun();

WorkOrderTable workOrderTable = sender.formRun().dataSource(FormDataSourceStr(WorkOrderTable, workordertable)).cursor() as WorkOrderTable;

//canceling super()
FormControlCancelableSuperEventArgs cancelableArgs = e as FormControlCancelableSuperEventArgs;
cancelableArgs.CancelSuperCall();

FormReferenceGroupControl ObjectId = formRun.design(0).controlName(“WorkOrderLine_Object”);

SysReferenceTableLookup lookup = SysReferenceTableLookup::newParameters(tableNum(ParmJobType), sender);
Query query = new Query();
QueryBuildDataSource qbdsJobType = query.addDataSource(tableNum(ParmJobType));
qbdsJobType.addRange(fieldNum(MROParmJobType, Task)).value(SysQuery::valueNot(enum2str(MROTask::Blank)));
lookup.addLookupfield(fieldNum(MROParmJobType, JobTypeID));
lookup.addLookupfield(fieldNum(MROParmJobType, Name));

lookup.parmQuery(query);

lookup.performFormLookup();
}

Event handlers on Form

HI, get current record based on event handler class

[FormDataSourceEventHandler(formDataSourceStr(WorkOrderTable, WorkOrderTable), FormDataSourceEventType::Initialized)]
public static void WorkOrderTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{

FormRun             formRun          = sender.formRun();
FormDataSource      WorkOrderTable_ds   = formRun.dataSource(formDataSourceStr(WorkOrderTable, WorkOrderTable)) as FormDataSource;
WorkOrderTable WorkOrderTable= WorkOrderTable_ds.cursor();

}

 

Form Control :

FormFunctionButtonControl buttonWorkOrderTableCreate = formRun.design(0).controlName(“WorkOrderTableCreate”);