The trouble is you think you have time. Your success depends on how you utilize your time.

Update or Refresh Form using X++ in Events or in Class Dynamics Finance and Operations

Update or Refresh Form using X++ in Events or in Class Dynamics Finance and Operations

To update or refresh a form while using a main(Args _args) function of a class you need to get the caller as FormRun object. 

            FormRun formRun = _args.caller();
     if(formRun)
     {
        #Task
        formRun.task(#taskRefresh);
     }

let say you want to use this code in an event then you will use it like this:

      [FormControlEventHandler(formControlStr(SalesTable, ImportFromExcel), FormControlEventType::Clicked)]
        public static void ImportFromExcel_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            FormRun formRun = sender.formRun();
            if(formRun)
            {
                #Task
                formRun.task(#taskRefresh);
            }
        }

Want to read more cool stuff about Finance and Operation and Dynamics AX development then click HERE

Convert amount to words using AL code Business central

Business Central has removed the FormatNoText procedure from the check report, we used this function to convert an amount to words by using the following code:

     checkreport.InitTextVariable();
     checkreport.FormatNoText(TextArray, Amount, CurrencyCode);

but now it has been removed, there are two ways right now which i know to convert amount to words

1- Create your own procedure 
2- Use FormatNoText from another report 

I am going to show you both ways/

1- Creating own procedure:

I am going to put the code into the codeunit but you can put that code anywhere you want.

codeunit 50105 AmountToWords
{
    procedure FormatNoText(var NoText: array[2] of Text[80]; No: Decimal; CurrencyCode: Code[10])
    var
        PrintExponent: Boolean;
        Ones: Integer;
        Tens: Integer;
        Hundreds: Integer;
        Exponent: Integer;
        NoTextIndex: Integer;
        DecimalPosition: Decimal;
        Text026: Label 'ZERO';
        Text027: Label 'HUNDRED';
        Text028: Label 'AND';
    begin
        Clear(NoText);
        NoTextIndex := 1;
        NoText[1] := '****';

        if No < 1 then
            AddToNoText(NoText, NoTextIndex, PrintExponent, Text026)
        else
            for Exponent := 4 downto 1 do begin
                PrintExponent := false;
                Ones := No div Power(1000, Exponent - 1);
                Hundreds := Ones div 100;
                Tens := (Ones mod 100) div 10;
                Ones := Ones mod 10;
                if Hundreds > 0 then begin
                    AddToNoText(NoText, NoTextIndex, PrintExponent, OnesText[Hundreds]);
                    AddToNoText(NoText, NoTextIndex, PrintExponent, Text027);
                end;
                if Tens >= 2 then begin
                    AddToNoText(NoText, NoTextIndex, PrintExponent, TensText[Tens]);
                    if Ones > 0 then
                        AddToNoText(NoText, NoTextIndex, PrintExponent, OnesText[Ones]);
                end else
                    if (Tens * 10 + Ones) > 0 then
                        AddToNoText(NoText, NoTextIndex, PrintExponent, OnesText[Tens * 10 + Ones]);
                if PrintExponent and (Exponent > 1) then
                    AddToNoText(NoText, NoTextIndex, PrintExponent, ExponentText[Exponent]);
                No := No - (Hundreds * 100 + Tens * 10 + Ones) * Power(1000, Exponent - 1);
            end;

        AddToNoText(NoText, NoTextIndex, PrintExponent, Text028);
        DecimalPosition := GetAmtDecimalPosition(CurrencyCode);
        AddToNoText(NoText, NoTextIndex, PrintExponent, (Format(No * DecimalPosition) + '/' + Format(DecimalPosition)));

        if CurrencyCode <> '' then
            AddToNoText(NoText, NoTextIndex, PrintExponent, CurrencyCode);
    end;

    local procedure AddToNoText(var NoText: array[2] of Text[80]; var NoTextIndex: Integer; var PrintExponent: Boolean; AddText: Text[30])
    var
        Text029: Label '%1 results in a written number that is too long.';
    begin
        PrintExponent := true;

        while StrLen(NoText[NoTextIndex] + ' ' + AddText) > MaxStrLen(NoText[1]) do begin
            NoTextIndex := NoTextIndex + 1;
            if NoTextIndex > ArrayLen(NoText) then
                Error(Text029, AddText);
        end;

        NoText[NoTextIndex] := DelChr(NoText[NoTextIndex] + ' ' + AddText, '<');
    end;

    local procedure GetAmtDecimalPosition(currencycode: Text): Decimal
    var
        Currency: Record Currency;
    begin
        if currencycode = '' then
            Currency.InitRoundingPrecision
        else begin
            Currency.Get(currencycode);
            Currency.TestField("Amount Rounding Precision");
        end;
        exit(1 / Currency."Amount Rounding Precision");
    end;

    procedure InitTextVariable()
    begin
        OnesText[1] := Text032;
        OnesText[2] := Text033;
        OnesText[3] := Text034;
        OnesText[4] := Text035;
        OnesText[5] := Text036;
        OnesText[6] := Text037;
        OnesText[7] := Text038;
        OnesText[8] := Text039;
        OnesText[9] := Text040;
        OnesText[10] := Text041;
        OnesText[11] := Text042;
        OnesText[12] := Text043;
        OnesText[13] := Text044;
        OnesText[14] := Text045;
        OnesText[15] := Text046;
        OnesText[16] := Text047;
        OnesText[17] := Text048;
        OnesText[18] := Text049;
        OnesText[19] := Text050;

        TensText[1] := '';
        TensText[2] := Text051;
        TensText[3] := Text052;
        TensText[4] := Text053;
        TensText[5] := Text054;
        TensText[6] := Text055;
        TensText[7] := Text056;
        TensText[8] := Text057;
        TensText[9] := Text058;

        ExponentText[1] := '';
        ExponentText[2] := Text059;
        ExponentText[3] := Text060;
        ExponentText[4] := Text061;
    end;


    var
        TensText: array[10] of Text[30];
        OnesText: array[20] of Text[30];
        ExponentText: array[5] of Text[30];
        currencycode: Text;
        Text032: Label 'ONE';
        Text033: Label 'TWO';
        Text034: Label 'THREE';
        Text035: Label 'FOUR';
        Text036: Label 'FIVE';
        Text037: Label 'SIX';
        Text038: Label 'SEVEN';
        Text039: Label 'EIGHT';
        Text040: Label 'NINE';
        Text041: Label 'TEN';
        Text042: Label 'ELEVEN';
        Text043: Label 'TWELVE';
        Text044: Label 'THIRTEEN';
        Text045: Label 'FOURTEEN';
        Text046: Label 'FIFTEEN';
        Text047: Label 'SIXTEEN';
        Text048: Label 'SEVENTEEN';
        Text049: Label 'EIGHTEEN';
        Text050: Label 'NINETEEN';
        Text051: Label 'TWENTY';
        Text052: Label 'THIRTY';
        Text053: Label 'FORTY';
        Text054: Label 'FIFTY';
        Text055: Label 'SIXTY';
        Text056: Label 'SEVENTY';
        Text057: Label 'EIGHTY';
        Text058: Label 'NINETY';
        Text059: Label 'THOUSAND';
        Text060: Label 'MILLION';
        Text061: Label 'BILLION';
}
Then after that, you can basically call the codeunit and convert the amount just like before

     cu.InitTextVariable();
     cu.FormatNoText(TextArray, Amount, CurrencyCode);

2- The Second way is to use the FormatNoText from another built-in report.

you can create a record of the following report:

ChkTransMgt: Report "Check Translation Management";  

then you can use the following statement with you desired parameters

ChkTransMgt.FormatNoText(DescriptionLine, CheckLedgEntry.Amount, CheckLanguage, BankAcc2."Currency Code") 

Browse and select the file or image and save it into the container field of table

Browse and upload file/image, get its path to convert it to base64 then put that into the container and save it into the table.


        public static void main(Args _args)

    {

        Str1260 fileUrl;

        BinData binData = new BinData();

        container imageContainer;

        ListIterator    iterator;

        List urls =  new List(Types::String);

        str finalUrl = '';

        MZNUKEmployeeSignature currentRec;


        if  (tableNum(MZNUKEmployeeSignature) == _args.dataset())

        {

            currentRec = _args.record();

        }

       

        FileUploadTemporaryStorageResult result = File::GetFileFromUser() as                FileUploadTemporaryStorageResult;

        If(result && result.getUploadStatus())

        {

            fileUrl = result.getDownloadUrl();            

            urls = strSplit(fileUrl, '?');

            int i = 1;

            iterator = new ListIterator(urls);

            while(iterator.more())

            {

                if (i == 1)

                    finalUrl = iterator.value();


                i++;

                iterator.next();

            }

        }

        

        System.Drawing.Image image;

        System.IO.MemoryStream memoryStream;

        str fileEncoded = '';


        System.Net.WebRequest req = System.Net.WebRequest::Create(fileUrl);

        System.Net.WebResponse resp = req.GetResponse();

        System.IO.Stream stream = resp.GetResponseStream();

        Filename filepath;

        Filename filename;

        Filename fileType;

        [filepath, filename, fileType] = fileNameSplit(finalUrl);


        image = System.Drawing.Image::FromStream(stream);

        memoryStream = new System.IO.MemoryStream();



        if ( strUpr(any2str(fileType)) == '.JPEG')

            image.Save(memoryStream, System.Drawing.Imaging.ImageFormat::Jpeg);

        else if ( strUpr(any2str(fileType)) == '.PNG')

            image.Save(memoryStream, System.Drawing.Imaging.ImageFormat::Png);

        else if ( strUpr(any2str(fileType)) == '.BMP')

            image.Save(memoryStream, System.Drawing.Imaging.ImageFormat::Bmp);

        else

            image.Save(memoryStream, System.Drawing.Imaging.ImageFormat::Bmp);

               

        fileEncoded = System.Convert::ToBase64String(memoryStream.ToArray());

        imageContainer = BinData::loadFromBase64(fileEncoded);

        currentRec.EmployeeSignature = imageContainer;

        currentRec.update();

        Info('Action Completed.');

}


Read how to make UIBuilder Class Click Here

Read how to make DP class for Contact Click Here

DP Class for UI Builder ListEnumerator d365 x++ Finance and Operations 

Get all Journal voucher using financial dimensions Query x++ D365 Finance and Operations

 Get all Journal voucher using financial dimensions x++ D365 Finance and Operations


select DIMENSIONATTRIBUTE.Name, DIMENSIONATTRIBUTELEVELVALUEALLVIEW.DISPLAYVALUE, DIMENSIONATTRIBUTE2.Name, DIMENSIONATTRIBUTELEVELVALUEALLVIEW2.DISPLAYVALUE,

DIMENSIONATTRIBUTE3.Name, DIMENSIONATTRIBUTELEVELVALUEALLVIEW3.DISPLAYVALUE,* from GeneralJournalAccountEntry

join DIMENSIONATTRIBUTELEVELVALUEALLVIEW on GeneralJournalAccountEntry.LEDGERDIMENSION = DIMENSIONATTRIBUTELEVELVALUEALLVIEW.VALUECOMBINATIONRECID

join DIMENSIONATTRIBUTE on DIMENSIONATTRIBUTE.RECID = DIMENSIONATTRIBUTELEVELVALUEALLVIEW.DIMENSIONATTRIBUTE

join DIMENSIONATTRIBUTELEVELVALUEALLVIEW as DIMENSIONATTRIBUTELEVELVALUEALLVIEW2 on GeneralJournalAccountEntry.LEDGERDIMENSION = DIMENSIONATTRIBUTELEVELVALUEALLVIEW2.VALUECOMBINATIONRECID

join DIMENSIONATTRIBUTE as DIMENSIONATTRIBUTE2 on DIMENSIONATTRIBUTE2.RECID = DIMENSIONATTRIBUTELEVELVALUEALLVIEW2.DIMENSIONATTRIBUTE

join DIMENSIONATTRIBUTELEVELVALUEALLVIEW as DIMENSIONATTRIBUTELEVELVALUEALLVIEW3 on GeneralJournalAccountEntry.LEDGERDIMENSION = DIMENSIONATTRIBUTELEVELVALUEALLVIEW3.VALUECOMBINATIONRECID

join DIMENSIONATTRIBUTE as DIMENSIONATTRIBUTE3 on DIMENSIONATTRIBUTE3.RECID = DIMENSIONATTRIBUTELEVELVALUEALLVIEW3.DIMENSIONATTRIBUTE

where DIMENSIONATTRIBUTE.NAME = 'Projects'
and DIMENSIONATTRIBUTELEVELVALUEALLVIEW.DISPLAYVALUE ='PCB-000051'
and DIMENSIONATTRIBUTE2.NAME = 'PURPOSE'
and DIMENSIONATTRIBUTELEVELVALUEALLVIEW2.DISPLAYVALUE ='PSL-0002'
and DIMENSIONATTRIBUTE3.NAME = 'MainAccount'
and DIMENSIONATTRIBUTELEVELVALUEALLVIEW3.DISPLAYVALUE ='35710010005'

Get LEDGERJOURNALTRANS against Financial dimension of Project , Purpose and Main account

 Get LEDGERJOURNALTRANS against  Financial dimension of Project , Purpose and Main account 


select DIMENSIONATTRIBUTE.NAME, DimensionAttributeLevelValueAllView.DISPLAYVALUE,  DIMENSIONATTRIBUTE2.NAME, DimensionAttributeLevelValueAllView2.DISPLAYVALUE,

 DIMENSIONATTRIBUTE3.NAME, DimensionAttributeLevelValueAllView3.DISPLAYVALUE, AMOUNTCURCREDIT, AMOUNTCURDEBIT from LEDGERJOURNALTRANS

join DimensionAttributeLevelValueAllView on DimensionAttributeLevelValueAllView.VALUECOMBINATIONRECID = LEDGERJOURNALTRANS.LEDGERDIMENSION

join DIMENSIONATTRIBUTE on DIMENSIONATTRIBUTE.RECID =DimensionAttributeLevelValueAllView.DIMENSIONATTRIBUTE

join DimensionAttributeLevelValueAllView as DimensionAttributeLevelValueAllView2 on DimensionAttributeLevelValueAllView2.VALUECOMBINATIONRECID = LEDGERJOURNALTRANS.LEDGERDIMENSION

join DIMENSIONATTRIBUTE as DIMENSIONATTRIBUTE2 on DIMENSIONATTRIBUTE2.RECID = DimensionAttributeLevelValueAllView2.DIMENSIONATTRIBUTE

join DimensionAttributeLevelValueAllView as DimensionAttributeLevelValueAllView3 on DimensionAttributeLevelValueAllView3.VALUECOMBINATIONRECID = LEDGERJOURNALTRANS.LEDGERDIMENSION

join DIMENSIONATTRIBUTE as DIMENSIONATTRIBUTE3 on DIMENSIONATTRIBUTE3.RECID = DimensionAttributeLevelValueAllView3.DIMENSIONATTRIBUTE

where DIMENSIONATTRIBUTE2.Name = 'PROJECTS'

and  DIMENSIONATTRIBUTE.Name = 'PURPOSE'

and  DIMENSIONATTRIBUTE3.Name = 'MainAccount'

and DimensionAttributeLevelValueAllView2.DisplayValue = 'PCB-000051'

Get display value of a dimension using purchaseline or salesline through default dimension

Get Displayvalue of Financial dimensions or Ledger Dimensions using purchase line or sales line through default dimension.

Select  DisplayValue From DefaultDimensionView
where  DefaultDimensionView.DEFAULTDIMENSION == salesLine.DefaultDimension
&& DefaultDimensionView3.name == 'PURPOSE';

   // Code from Moznum.blogspot.com
   // Hire ERP consultants from www.Moznum.com

Select  DisplayValue From DefaultDimensionView
where  DefaultDimensionView.DEFAULTDIMENSION == purchLine.DefaultDimension

&& DefaultDimensionView3.name == 'PROJECT';


Read how to make UIBuilder Class Click Here


Get Financial Dimensions using LEDGERJOURNALTRANS in Single Line, Query x++ Dynamics AX, Finance and Operations

Get Financial Dimensions using LEDGERJOURNALTRANS  in Single Line, Query x++ Dynamics AX, Finance and Operation


select LEDGERJOURNALTRANS.LEDGERDIMENSION, LEDGERJOURNALTRANS.journalnum, DimensionAttributeLevelValueAllView.DISPLAYVALUE, DIMENSIONATTRIBUTE.NAME,

DimensionAttributeLevelValueAllView2.DISPLAYVALUE, DIMENSIONATTRIBUTE2.NAME,

DimensionAttributeLevelValueAllView3.DISPLAYVALUE, DIMENSIONATTRIBUTE3.NAME

from LEDGERJOURNALTRANS


inner join DimensionAttributeLevelValueAllView on DimensionAttributeLevelValueAllView.VALUECOMBINATIONRECID = LEDGERJOURNALTRANS.LEDGERDIMENSION

inner join DIMENSIONATTRIBUTE on DIMENSIONATTRIBUTE.RECID = DimensionAttributeLevelValueAllView.DIMENSIONATTRIBUTE

and DIMENSIONATTRIBUTE.Name = 'Projects'


inner join DimensionAttributeLevelValueAllView as DimensionAttributeLevelValueAllView2 on DimensionAttributeLevelValueAllView2.VALUECOMBINATIONRECID = LEDGERJOURNALTRANS.LEDGERDIMENSION

inner join DIMENSIONATTRIBUTE as DIMENSIONATTRIBUTE2 on DIMENSIONATTRIBUTE2.RECID = DimensionAttributeLevelValueAllView2.DIMENSIONATTRIBUTE

and DIMENSIONATTRIBUTE2.Name = 'MainAccount'

inner join DimensionAttributeLevelValueAllView as DimensionAttributeLevelValueAllView3 on DimensionAttributeLevelValueAllView3.VALUECOMBINATIONRECID = LEDGERJOURNALTRANS.LEDGERDIMENSION

inner join DIMENSIONATTRIBUTE as DIMENSIONATTRIBUTE3 on DIMENSIONATTRIBUTE3.RECID = DimensionAttributeLevelValueAllView3.DIMENSIONATTRIBUTE

and DIMENSIONATTRIBUTE3.Name = 'Purpose'
where  LEDGERJOURNALTRANS.RECID = 5637176076