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

EXCEL Add-in D365 FO

EXCEL add-in USED FOR D365 DATA ENTITY To use excel add-in for D365 data entities for CRUD operations. You can easily follow below mentioned steps: 1. Open Excel from any Desktop or VM and click on Add-ins option under insert tab: 2. Check if you have Microsoft Dynamics Office Add-ins, If not then download it from Microsoft store: 3. If you have above mentioned Add-in click on this and click add server information: 4. In server URL add your environment URL either dev, UAT or PROD and click OK.  for e.g:  (https://xxxxxxxxxxxxxxxxxxx.dynamics.com/)  5. Click on Design button and it will display below mentioned screen: 6. Click on Select entity data source and choose your desired data entity from list on which you need to perform CRUD operations and click on NEXT: 7. Double click on each field present in AVAILABLE FIELD SECTION to get them in SELECTED FIELD SECTION: 8. Click on Refresh Once and you will be able to see data in your entity in Excel: 9. After making changes to...

Deep Links

  DEEP LINKS FOR SALES ORDERS In this blog we will discuss about generating deep links for any form , record or datasource. Deep links are basically termed for generating URL's through code for any specific record in D365. Using Deep links other environments can access D365 records by using this URL generated from it. 1. In below blog I am creating Deep links for sales order header record. 2. To Access these links one should always be added the user in FinOps to access through URL. Step #1 Create and extension class of  URLUtility class  and also add following code snippet to access this class : using Microsoft.Dynamics.AX.Framework.Utilities; using Microsoft.Dynamics.@Client.ServerForm.Contexts; public static str generateRecordUrl(str _menuItemName, MenuItemType _menuItemType, DataSourceName _dataSourceName, Map _indexFieldValuesMap, DataAreaId _dataAreaId = curExt()) {   System.Uri host = SessionContext::Get_Current().Get_RequestUrl();   UrlHelper.UrlGenerator...

Record level Security Ax 2012

RECORD LEVEL SECURITY IN AX 2012 In this blog we will discuss record level security in Ax 2012. Record level security includes Query, Constrained table, Security policy, Temp table (Optional).   Create a query That will be used to restrict data access from the  Constraint  table. Right-click  Data Sources , and the select  New Data Source . In the  Table  field, enter the primary table name  CustGroup . Right-click  Ranges , and then select  New Range . Set the  Enabled  field to  Yes . In the  Data Source  field, enter the primary table name, in this case, ‘CustGroup’. In the  Value field , enter  10  to restrict access to data where CustGroup has value of 10, by defining the Range for the CustGroup field. Add a new security policy Add a new security policy.  Set  Constrained Table  to  Yes . This will also secure access to the primary table. In this example this is the...