Sunday, 29 November 2015

Methods in X++

Pack
                         this method is a standard method inherited from RunBase. It is used to save
the values that the user selects and store them until the next time the user executes the class.

Public container pack ()
 
{
         return [#CurrentVersion, #CurrentList];
}


unpack
                       Standard method inherited from RunBase and used to fetch the values that the user selected the previous time he executed the class.

public boolean unpack(container packed Class)
{
          Version version = RunBase::getVersion(packedClass);
          ;
          switch (version)
         {
                case #CurrentVersion:
                [version, #CurrentList] = packedClass;
                break;
                default:
               return false;
          }
return true;
}

How the values will be stored in pack 

Example : 

I am having values customer account, transdate 















In Class declaration 
// Packed
    TransDate       transDate;
    CustAccount     custAccount;

#define.CurrentVersion(1)
    #define.Version1(1)
    #localmacro.CurrentList
        transDate,
        custAccount
    #endmacro

#define.currentVersion(1) -Version stored in the cache by list (how many values added here 1) what if you are going to add one more field on that list. then you need to increase the version by 1 (at your choice but the version must differ numerically like #define.currentVersion(2)) because cache knows version 1 has 1 variables and version 2 has 2 variables.

#localmacro.currentList ...........#endmacro - it describes what are all the variables we are going to store.

SysSaveable -- Class stores values 




























Public void initParmDefault()
{
transDate       
custAccount
}

Above methods combine to ensure the values that needed by xSysLastValue.savelast method.This values are needed to maintain different user store values different objects in different companies.

                      Override close() method by below coding

                 public void close()
          {
               ;
               custAccount = ComboBox.selection();
                   transDate  =      

               xSysLastValue::saveLast(this);
                   super();
             }

   when the form closes this system method triggered. here the xSysLastValue class send the user selected values to cache.
To retrieve last values
public void run()
{

      //called before opeing the form 
      super();
      //get the last value stored in cache 
      //here unpack method used
      xSysLastValue::getLast(this);   
      //set the last user selection on the field
       Custaccoun.selection(custAccount);
 }






Refresh
                    refresh() will not reread the record from the database.  It basically just refreshes the screen with whatever is stored in the form cache.

Reread
                    
                   reread() will only re-read the CURRENT record from the DB so you should not use it to refresh the form data if you have added/removed records.  It's often used if you change some values in the current record in some code, and commit them to the database using .update() on the table, instead of through the form datasource.  In this case .reread() will make those changes appear on the form.

Research

               research() will rerun the existing form query against the data source, therefore updating the list with new/removed records as well as updating existing ones.  This will honour any existing filters and sorting on the form.

Display 

            Display methods are used on forms. They are commonly created on the table, and can also be defined on the form. Display methods return a value that is displayed on the form or report. They are often used to display a calculation, or to look up a single field from another table. 

The following example shows how to display the item name on a form that displays data from a table containing the item id.


// BP Deviation documenteddisplay itemName itemName(){inventTable inventTableselect name from inventTablewhere inventTable.itemId == this.itemId;return inventTable.name;}     The first line in this code is a comment to the compiler indicating that a BestPractice deviation is considered and evaluated as reasonable. The deviation isbecause a display method is able to return any data from any table or field in the system, and so the security implications should be considered.


Thursday, 26 November 2015

How to Filter Data on one field Between Two Dates in X++

     In Data Source, Override Execute Query Method and Copy Below Code

    public void executeQuery()
   {
          date  fromdate = today()-7;
          date   todate       = today();
                   this.query().dataSourceTable(tablenum(InventTrans)).addRange(fieldnum(InventTrans,DatePhysical)).value(queryRange(fromdate,todate));

   }




Thursday, 19 November 2015

How To Set Grand Total property in Auto Design SSRS

Expand  Design Node,expand Auto designed node.


  •  Expand Data Node
  • Select the Field( Here I Selected AmountMST), & Go to Properties.
  • In Aggregation Property, Set it to "Sum".
  • After Setting Property