Skip to main content

Multi-Select


MULTI-SELECTION REPORT PARAMETER


1. Create a contract class as follows of type List in multi selection :


[SysOperationContractProcessingAttribute(classStr(SLD_RecieptSlipUIBuilderClass))]
class SLD_RecieptSlipReportContract implements SysOperationValidatable
{
List purchidlist;
[
DataMemberAttribute('purchidlist'),
SysOperationLabelAttribute(literalstr("Purchase Order ID's")),
SysOperationHelpTextAttribute(literalstr("Purchase Order ID's")),
AifCollectionTypeAttribute("purchidlist", Types::String)
]
public List parmpurchid(List _purchidlist = purchidlist)
{
purchidlist = _purchidlist;
return purchidlist;
}

/*[

DataMemberAttribute('Semester'), SysOperationLabelAttribute(literalstr("@ConWAN:StdSem")),
SysOperationHelpTextAttribute(literalstr("@ConWAN:StdSem")),
SysOperationDisplayOrderAttribute('2')]
public Integer parmsemester(Integer _semester = semester)
{
semester = _semester;
return semester;
}*/

public boolean validate()
{
boolean isValid = true;
if(!this.parmpurchid())
{
isValid = checkFailed("not valid purchase order ID");
}
return isValid;
}
}


2. for multi select Look-up create a UI Builder class :

class SLD_RecieptSlipUIBuilderClass extends SysOperationAutomaticUIBuilder
{
DialogField dialogCust;
container conCustTable;
SLD_RecieptSlipReportContract contract;


public void build()
{
contract = this.dataContractObject() as SLD_RecieptSlipReportContract;
dialogCust = this.addDialogField(
methodStr(SLD_RecieptSlipReportContract, parmpurchid),
contract);
}




public void postBuild()
{

super();

contract = this.dataContractObject() as SLD_RecieptSlipReportContract;
dialogCust = this.bindInfo().getDialogField(
contract,
methodStr(SLD_RecieptSlipReportContract, parmpurchid));
dialogCust.registerOverrideMethod(
methodStr(FormStringControl, lookup),
methodStr(SLD_RecieptSlipUIBuilderClass, purchTableLookup),
this);

if (dialogCust)
{
dialogCust.lookupButton(2);
}
}
private void purchTableLookup(FormStringControl _control)
{
Query query= new Query();
QueryBuildDataSource qbdsSLD_Enroll;
qbdsSLD_Enroll = query.addDataSource(tableNum(VendPackingSlipJour));
qbdsSLD_Enroll.addSelectionField(fieldNum(VendPackingSlipJour, PurchId));
//qbdsSLD_Enroll.fields().addField(fieldNum(VendPackingSlipJour, PurchId));
//sysTableLookup = SysTableLookup::newParameters(tableNum(VendPackingSlipJour), _control);
//sysTableLookup.addLookupfield(fieldNum(VendPackingSlipJour, PurchId));
//sysTableLookup.parmQuery(query);
//sysTableLookup.performFormLookup();
//conCustTable = [tableNum(VendPackingSlipJour), fieldNum(VendPackingSlipJour, PurchId)];
SysLookupMultiSelectGrid::lookup(
query,
_control,
_control,
_control,
conCustTable);
}

public void postRun()
{
//super();
}
}


3. Finally Create a DP class as follows :

[SRSReportParameterAttribute(classStr(SLD_RecieptSlipReportContract))]
class SLD_RecieptSlipReportDP extends SRSReportDataProviderBase
{
VendPackingSlipTrans vendPackingSlipTrans;
VendPackingSlipJour vendPackingSlipJour;
SLD_ReceiptSlipTemp receiptslip;
InventDim inventDim;
ListIterator listIdIterator;
ListIterator list;

private Query buildQuery(ListIterator _listIdIterator = null)
{
Query query= new Query();
QueryBuildDataSource packingslip;
packingslip = query.addDataSource(tableNum(VendPackingSlipTrans));

if(_listIdIterator)
{
Info(strFmt('before %1',_listIdIterator.value()));
while(_listIdIterator.more())
{
Info(strFmt('After %1',_listIdIterator.value()));
query.dataSourceTable(tablenum(VendPackingSlipTrans), 1)
.addRange(fieldnum(VendPackingSlipTrans, OrigPurchid)).value(queryValue(_listIdIterator.value()));
_listIdIterator.next();
}
}
return query;
}

/// <summary>
/// Gets the full data from the <c>PurchPackingSlipTmp</c> temporary table.
/// </summary>
/// <returns>
/// The <c>PurchPackingSlipTmp</c> temporary table.
/// </returns>
[SRSReportDataSetAttribute(tableStr(SLD_ReceiptSlipTemp))]
public SLD_ReceiptSlipTemp getPurchReceiptSlipTmp()
{
select receiptslip;
return receiptslip;
}

public void getReportParametes()
{
SLD_RecieptSlipReportContract Contract = this.parmDataContract() as SLD_RecieptSlipReportContract;

if(Contract)
{
listIdIterator = new ListIterator(Contract.parmpurchid());
}
}

private ItemId itemId()
{
ItemId itemId;
switch (VendFormletterParameters::find().ItemNum)
{
case OurYourBoth::Our : itemId = vendPackingSlipTrans.ItemId; break;
case OurYourBoth::Your : itemId = vendPackingSlipTrans.ExternalItemId; break;
case OurYourBoth::Both : itemId = vendPackingSlipTrans.ItemId; break;
}

return itemId;
}


private void PurchPackingSlipDetailsTmp()
{
SLD_RecieptSlipReportContract _dataContract = this.parmDataContract() as SLD_RecieptSlipReportContract;
list = new ListIterator(_dataContract.parmpurchid());
while (list.more())
{
while select vendPackingSlipTrans where list.value() == vendPackingSlipTrans.OrigPurchid
{
receiptslip.JournalRecId = vendPackingSlipJour.RecId;
receiptslip.ItemId = this.itemId();
receiptslip.Name = vendPackingSlipTrans.Name;
//receiptslip.Ordered = vendPackingSlipTrans.Ordered;
receiptslip.PurchUnit = vendPackingSlipTrans.purchUnitTxt();
receiptslip.PurchQty = vendPackingSlipTrans.Qty;
//receiptslip.Remain = vendPackingSlipTrans.Remain;
receiptslip.InventSiteId = vendPackingSlipTrans.inventDim().InventSiteId;
receiptslip.InventLocationId = vendPackingSlipTrans.inventDim().InventLocationId;
receiptslip.InventSizeId = vendPackingSlipTrans.inventDim().InventSizeId;
receiptslip.InventColorId = vendPackingSlipTrans.inventDim().InventColorId;
receiptslip.PurchId = vendPackingSlipTrans.OrigPurchid;
receiptslip.insert();
}

list.next();
}
}

public void processReport()
{
QueryRun queryRun;
SLD_RecieptSlipReportContract contract;
//Query query= new Query();
this.getReportParametes();
queryRun = new QueryRun(this.buildQuery(listIdIterator));
while(queryRun.next())
{
vendPackingSlipTrans = queryRun.get(tablenum(vendPackingSlipTrans));
this.PurchPackingSlipDetailsTmp();
}
}
}


           HEY HEY HEY!!! HACK OF THE DAY !! 

            QUERY NULL EXCEPTION ERROR       

                  Query       query= new Query();

                   QueryBuildDataSource    pack;

             pack = query.addDataSource(tableNum(TN));


             


Comments

Popular posts from this blog

Edit Method on Form

Edit Method D365 for a form Data Source 1. To create an edit method first create a controller class. with following properties  public static edit MainAccountNum LedgerJournalTransLedger(LedgerJournalTrans _ledgerjournal, boolean _set, MainAccountNum _id) { MainAccountNum accountId = _id; MainAccount mainAccount = MainAccount::findByMainAccountId(_id); if(_set) { if(_ledgerjournal.AccountType== LedgerJournalACType::Ledger) { mainAccount = MainAccount::findByMainAccountId(accountId); if(_ledgerjournal.LedgerDimension) { DimensionDefault defaultDim = LedgerDimensionFacade::getDefaultDimensionFromLedgerDimension(_ledgerjournal.LedgerDimension); _ledgerjournal.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccount.RecId, DimensionHierarchy::getAccountStructure(mainAccount.RecId), defaultDim); } else { _ledgerjournal.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccount.RecId, DimensionHierarchy::ge...

Field Level Security In Ax 2012

FIELD LEVEL SECURITY IN AX 2012 In this blog we will discuss field level security applied in  Ax 2012. 1. Field level security is added on form level as well in Ax 2012 its bit different then field level security in D365 2. This also requires privileges to be applied on form specific fields only. Step #1 :  Change datasource property of the field which need to be added in security. Step #2 : Now add these 2 fields in form --- > permissions --- > Read Step #3 : Now finally create privilege and add these fields explicitly in it.       HEY HEY HEY !!!! HACK OF THE DAY  Add Fields in Entry point privilege section of form  Explicitly.  

Security Objects In D365

   PRIVILEGES, DUTIES AND ROLES IN D365 FinOps To add customize security privilege, duty and role you should follow this flow because it is considered as the best practices  Role---> Duty---->Privilege Duty and Privilege would be created at the back end and where as role would be created at front end  1. create privilege from solution explorer in a project  and add new entry point for output, display or action menus to refer in privilege that for which entity we have to give privilege to the user 3. Now Create a duty from solution explorer same as privilege and add this new created privilege to the duty  Now you can refer this duty to the role created on the front end.   HEY HEY HEY !!!! HACK OF THE DAY !!           THE HIGHEST ACCESS LEVEL  FOR ACTION MENU ITEM IS   DELETE