Showing posts with label How to. Show all posts
Showing posts with label How to. Show all posts

Tuesday, November 23, 2021

Pass Multi Line Record Using Button Clicked

 

Pass multi Line Record using Button

Form A Button clicked Method:
void clicked()
{
    int         recordsCount;
    SalesLine   _salesLine;
    container   con;
    Args        args;
    str         multiSelectString;
 
    args = new Args();
    recordsCount = SalesLine_1_ds.recordsMarked().lastIndex(); // gets the total records selected
    _salesLine = SalesLine_1_ds.getFirst(1);
 
    while (_salesLine)
    {
    con = conIns(con, 1, _salesLine.RecId);
 
    multiSelectString = con2Str(con, ",");
 
    _salesLine = SalesLine_1_ds.getNext(); // moves to next record
    }
    args.parm(multiSelectString);
    new MenuFunction(menuitemDisplayStr(GofyndSalesOrderError), MenuItemType::Display).run(args);
}
 
Form B Init Method:
public void init()
{
    super();
   
    multipleRecords = element.args().parm();
 
    con = str2con(multipleRecords,",");
    for(i = 1; i<= conLen(con);i++)
    {
  SalesLine_ds.query().dataSourceTable(Tablenum(SalesLine)).addRange(fieldNum(SalesLine,RecId)).value(SysQuery::value(conPeek(con,i)));
SalesLine_ds.query().dataSourceTable(tableNum(SalesLine)).addRange(fieldNum(SalesLine,S3_GofyndError)).value(sysquery::valueNotEmptyString());
    }
   

}

 

Thursday, July 29, 2021

Simple List Form With Multi Filters

 Filter Form Look:


Modified Method:

        public boolean modified()

        {

            boolean ret;

            ret = super();

            PurchTable_DS.executeQuery();

            return ret;

        }

Lookup Method:

        public void lookup()

        {

            Query   query = new Query();

            super();

            SysTableLookup  SysTableLookup = SysTableLookup::newParameters(tableNum(TableName),this);

            QueryBuildDataSource qbds = query.addDataSource(tableNum(TableName));

            SysTableLookup.addLookupfield(fieldNum(TableName,Field1));

            SysTableLookup.addLookupfield(fieldNum(TableName,Field2));

            sysTableLookup.parmQuery(query);

            sysTableLookup.performFormLookup();

        }

Execute Query Method:

        public void executeQuery()

        {

            PurchTable_DS.query().dataSourceName('PurchTable').clearRanges();

            PurchTable_DS.init();

            if(VendAccount.valueStr())

            {

                str   account = VendAccount.valueStr();

                if(account != '0')

                    this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, OrderAccount)).value(account);

            }

            if(PurchType.valueStr())

            {

                this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchStatus)).value(PurchType.valueStr());

            }

            if(InventSiteId.valueStr())

            {

                str   site = InventSiteId.valueStr();

                this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable,InventSiteId)).value(site);

            }

            if (monthfilter.valueStr())

            {

                TransDate               lastDate = endMth(monthfilter.dateValue());

                TransDate               startDate = dateStartMth(monthfilter.dateValue());

                this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, DeliveryDate)).value(sysQuery::range(startDate, lastDate));

            }

            

            if (!monthfilter.valueStr())

            {

                TransDate               lastDate ;

                TransDate               startDate;

                if(dayOfMth(today()) <16)

                {

                    lastDate = mkDate(15,mthOfYr(today()),Year(today()));

                    startDate = mkDate(16,mthOfYr(today())-1,Year(today()));

                }

                if(dayOfMth(today()) >15)

                {

                    lastDate = mkDate(15,mthOfYr(today())+1,Year(today()));

                    startDate = mkDate(16,mthOfYr(today()),Year(today()));

                }

                this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, DeliveryDate)).value(sysQuery::range(startDate, lastDate));

            }        this.query().dataSourceTable(tableNum(PurchTable)).addSortField(fieldNum(PurchTable,DeliveryDate),SortOrder::Descending);   

            super();

        }

/// Enjoy 👍

Sunday, April 11, 2021

Auto Generate Number In D365 Table Field

This Post explains to you how to generate a sequence of auto Generated Numbers using X++ code. One way is we can use Number Sequence and another way we can write this logic to generate our auto-updated number.

Let's Go to the code you can write this logic to the InitValue Method of the table to update the value on every creation.

    /// <summary>
    ///
    /// </summary>
    public void initValue()
    {
        TableName          table;
        int                         i;
        super();

        select count(RecId) from table;
        i = table.RecId;
      
        this.FieldName =  (i + 1);   
    }

Enjoy 👍

Saturday, April 3, 2021

Exist method in D365 Table

    public static boolean Exist(TableID   id)

   {

       TableName    tableName;


       if(id != '')

        {

            select firstonly RecId from tableName where tableName.TableID   == id;

        }

        

        return (tableName.RecId != 0);

   }

Or

    public static boolean Exist()

    {

        return (select firstonly RecId from TableName).RecId != 0;

    }

Workflow Approver Name For PurchRequsition Order

 For First Approver, this.workflowApprover(purchReqTable.RecId);     public void workflowApprover (RecId _recId)  // Requsation Table RecId ...