Tag: UIBuilder

Batch job D365

Hi,

Contact:

[DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(CounterEntryOutliersUIBuilderClass))]
public class CounterEntryOutliersContract
{
Transdate startDate,endDate;
MROObjectCounterID objectCounterID;
MROObjectID objectId;

[DataMemberAttribute(‘Counter’),
SysOperationDisplayOrderAttribute(‘1’)]
public MROObjectCounterID parmCounter(MROObjectCounterID _objectCounterID = objectCounterID)
{
objectCounterID = _objectCounterID;
return objectCounterID;
}

[DataMemberAttribute(‘objectId’),
SysOperationDisplayOrderAttribute(‘2’)]
public MROObjectID parmObjectId(MROObjectID _objectId = objectId)
{
objectId = _objectId;
return objectId;
}

[DataMemberAttribute(‘StartDate’),
SysOperationDisplayOrderAttribute(‘3’)]
public StartDate parmStartDate(TransDate _startDate = startDate)
{
startDate = _startDate;
return startDate;
}

[DataMemberAttribute(‘EndDate’),
SysOperationDisplayOrderAttribute(‘4’)]
public EndDate parmEndDate(TransDate _endDate = endDate)
{
endDate = _endDate;
return endDate;
}

DP:

[
SRSReportQueryAttribute(queryStr(ObjectCounterQuery)),
SRSReportParameterAttribute(classStr(CounterEntryOutliersContract))
]
public class
CounterEntryOutliersDP extends SRSReportDataProviderBase
{

[SysEntryPointAttribute(false)]
public void processReport()
{
M

query = this.parmQuery();

contract = this.parmDataContract();

counterID = contract.parmCounter();
objectId = contract.parmObjectId();
startdate = contract.parmStartDate();
endDate = contract.parmEndDate();

startDateTime = DateTimeUtil::newDateTime(startdate,0);
endDateTime = DateTimeUtil::newDateTime(endDate,86400);

delete_from objectCounterTmp;
if(counterID)
{
select firstonly parmObjectCounter where parmObjectCounter.CounterID == counterID;
query.dataSourceTable(tablenum(ObjectCounter)).addRange(fieldnum(ObjectCounter,Counter)).value(queryValue(parmObjectCounter.RecId));
}
if(objectId)
{
select RecId from objectTable where objectTable.ObjectID == objectId;
query.dataSourceTable(tablenum(ObjectCounter)).addRange(fieldnum(ObjectCounter,Object)).value(queryValue(objectTable.RecId));// 5637178326));
}

query.dataSourceTable(tablenum(ObjectCounter)).addRange(fieldnum(ObjectCounter,CounterDateTime)).value(queryRange(startDateTime, endDateTime));

queryRun = new QueryRun(query);

ttsbegin;
while (queryRun.next())
{
this.insertTmpTable(mroObjectCounter);
}
ttsCommit;
}

private void insertTmpTable(MROObjectCounter objectCounter)
{
objectCounterTmp.insert();
}

[SRSReportDataSetAttribute(“ObjectCounterTmp”)] //tmp table
Public OObjectCounterTmp getObjectCounterTmp()
{
select * from objectCounterTmp;

return objectCounterTmp;
}

UIBuilder : 

class CounterEntryOutliersUIBuilderClass extends SysOperationAutomaticUIBuilder
{
CounterEntryOutliersContract contract;

DialogField dialogCounter;
DialogField dialogStartDate;
DialogField dialogEndDate;
DialogField dialogObjectId;

public void build()
{
Dialog dialogLocal = this.dialog();
contract = this.dataContractObject();
this.addDialogField(methodStr(CounterEntryOutliersContract,parmCounter), contract);
this.addDialogField(methodStr(CounterEntryOutliersContract,parmStartDate), contract);
this.addDialogField(methodStr(CounterEntryOutliersContract,parmEndDate), contract);
}

public void getFromDialog()
{
contract = this.dataContractObject();
super();
}

public void initializeFields()
{
contract = this.dataContractObject();
}

public void lookupCounter(FormStringControl _control)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(ParmObjectCounter), _control);
;
sysTableLookup.addLookupfield(fieldnum(ParmObjectCounter, CounterID),true);

queryBuildDataSource = query.addDataSource(tablenum(ParmObjectCounter));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();
}

public void postBuild()
{
;
super();
dialogCounter = this.bindInfo().getDialogField(
this.dataContractObject(),
methodStr(CounterEntryOutliersContract,parmCounter));

dialogCounter.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(CounterEntryOutliersUIBuilderClass,lookupCounter),this);

dialogStartDate = this.bindInfo().getDialogField(
this.dataContractObject(),
methodStr(CounterEntryOutliersContract,parmStartDate));
dialogEndDate = this.bindInfo().getDialogField(
this.dataContractObject(),
methodStr(CounterEntryOutliersContract,parmEndDate));

}

public void postRun()
{
Dialog dialogLocal = this.dialog();
super();
// This method should be called in order to handle events on dialogs.
dialogLocal.dialogForm().formRun().controlMethodOverload(false);
}

}

 

Advertisements

Using UIBuilder in SSRS contract class

Hi, Below sample code used to get lookups.

In this scenario, i need to get itemid lookup based on Invoice id selected.

UIBuilder class

  1. public class testUIBuilder extends SysOperationAutomaticUIBuilder
    {
    testContract contract;
    DialogField dialogInvoiceId;
    DialogField dialogItemId;
    }
  2. public void build()
    {
    Dialog dialogLocal = this.dialog();
    contract = this.dataContractObject();
    this.addDialogField(methodStr(testContract,parmInvoiceId), contract);
    this.addDialogField(methodStr(testContract,parmItemId), contract);
    }
  3. public void getFromDialog()
    {
    contract = this.dataContractObject();
    super();
    }
  4. public void initializeFields()
    {
    contract = this.dataContractObject();
    }
  5. public void lookupItem(FormStringControl _control)
    {
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource, queryBuildDataSource1;
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(CustInvoiceTrans), _control);
    ;

    sysTableLookup.addLookupfield(fieldnum(CustInvoiceTrans, ItemId),true);

     

    queryBuildDataSource = query.addDataSource(tablenum(CustInvoiceTrans));

    queryBuildDataSource1 = queryBuildDataSource.addDataSource(tablenum(CustInvoiceTrans));

    queryBuildDataSource1.addRange(fieldnum(CustInvoiceTrans, InvoiceId)).value(queryvalue(dialogInvoiceId.value()));

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
    }

  6. public void postBuild()
    {
    ;
    super();
    dialogInvoiceId = this.bindInfo().getDialogField(
    this.dataContractObject(),
    methodStr(testContract,parmInvoiceId));

    dialogItemId = this.bindInfo().getDialogField(
    this.dataContractObject(),
    methodStr(testContract,parmItemId));
    // register override method for lookup customer
    dialogItemId.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(testUIBuilder,lookupItem),this);

    }

  7. public void postRun()
    {
    Dialog dialogLocal = this.dialog();
    super();
    // This method should be called in order to handle events on dialogs.
    dialogLocal.dialogForm().formRun().controlMethodOverload(false);
    }

Contract class

  1. [
    DataContractAttribute,
    SysOperationContractProcessingAttribute(classStr(testUIBuilder))]
    public class testContract implements SysOperationValidatable
    {
    InvoiceId invoiceId;
    ItemId itemId;
    }
  2. [
    DataMemberAttribute(‘InvoiceId’),
    SysOperationDisplayOrderAttribute(‘1’)
    ]
    public InvoiceId parmInvoiceId(InvoiceId _invoiceId = invoiceId)
    {
    invoiceId = _invoiceId;
    return invoiceId;
    }
  3. [
    DataMemberAttribute(‘ItemId’),
    SysOperationDisplayOrderAttribute(‘2’)
    ]
    public ItemId parmItemId(ItemId _itemId = itemId)
    {
    itemId = _itemId;
    return itemId;
    }