Tuesday, January 29, 2019

Create Dialog in D365

class simpledialog extends RunBaseBatch
{
    DialogField     fieldfromDate;
    DialogField     fieldtoDate;

    TransDate       fromDate,toDate;   

    #DEFINE.CurrentVersion(1)
    #LOCALMACRO.CurrentList
        fromDate,toDate
    #ENDMACRO



    // pack() and unpack() methods are used to load the last value from user
    public container pack()
    {
    return [#CurrentVersion,#CurrentList];
    }

    public boolean unpack(container _packedClass)
    {
    int version = conpeek(_packedClass, 1);

    switch (version)
    {
        case #CurrentVersion:
            [version,#CurrentList] = _packedClass;
            break;
        default :
            return false;
    }

    return true;
}

    public Object dialog()
    {
        Dialog dialog;
        dialog = super();

        // Set a title for dialog
        dialog.caption( 'Purchase Order creation for Out Grower');

        // Add a new field to Dialog
        fieldfromDate = dialog.addField(extendedTypeStr(TransDate), 'From Date');
        fieldtoDate   = dialog.addField(extendedTypeStr(TransDate), 'To Date');

        return dialog;
    }

    boolean validate(Object _calledFrom = null)
    {
        boolean ret;

        ret = super(_calledFrom);
     
        if(fromDate > toDate)
         {
            ret = checkFailed('To Date should be greater than From Date') && ret;
         }
     
        return ret;
    }

    public TransDate parmfromDate(TransDate _fromdate = fromDate)
    {
    fromDate = _fromdate;

    return fromDate;
    }

    public TransDate parmtoDate(TransDate _todate = toDate)
    {
    toDate = _todate;

    return toDate;
    }

    public boolean getFromDialog()
    {
        fromDate = fieldfromDate.value();
        toDate = fieldtoDate.value();     

        return super();
    }

    public void run()
    {
       //your Logic 
    }

    public static void main(Args _args)
    {
        simpledialog   simple = new  simpledialog ();

        // Prompt the dialog, if user clicks OK it returns true
        if (simple .prompt())
        {
            simple .run();
        }
    }

   }

Thursday, January 24, 2019

Individual financial dimension value through X++

display DimensionValue displayLocDimension()

    VendTable                                          vendTable;
    DimensionAttributeValueSet             dimensionAttributeValueSet;
    DimensionAttributeValueSetItem      dimensionAttributeValueSetItem;
    DimensionAttributeValue                  dimensionAttributeValue;
    DimensionAttribute                          dimensionAttribute;
   VendTrans                                          vendtrans
    DimensionValue                               location;

      select * from vendTable
                           where vendTable.AccountNum == "XXXX"
            join RecId from dimensionAttributeValueSet
                          where dimensionAttributeValueSet.RecId == vendtrans.DefaultDimension
            join RecId, DisplayValue from dimensionAttributeValueSetItem
                          where dimensionAttributeValueSetItem.DimensionAttributeValueSet == dimensionAttributeValueSet.RecId
            join RecId from dimensionAttributeValue
                        where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
            join RecId, Name from DimensionAttribute
                       where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute
                       && dimensionAttribute.Name == "LOCATION";
            {
                location = DimensionAttributeValueSetItem.DisplayValue;
            }
                return location;
  }

update_recordset with joins

 update_recordset with joins update_recordSet storeTransfer         setting      TransactionId = transfertable.TransferId     join transfert...