Saturday, January 30, 2021

How to refresh DataBase using LCS

Go to Link

Page should look like this



Sign in with your credentials

Open your project

You will get list of project-environments[Development,Testing,UAT,Production]

Click on UAT (Full details)

Click on Maintain(4th option) -> Move database -> Refresh database



If you click on EXPORT DATABASE that database sits in your ASSET LIBRARY(GO INTO DATABASE BACKUP)


Tuesday, January 19, 2021

Chrome extension for D365 FO Browsing tables

Browse D365 FO Tables

Go to Chrome web store: Chrome web store extension

Search for "Table Browser Caller for D365FO"

Install the first extension that pops up

Now you will get an icon on the top right of your Chrome click on it and you can search the tables from F&O
Table browser extension


Sunday, January 17, 2021

Copy file from one place to another in D365 F&O

Code to copy file from one place to another


        Set    permissionSet;

        FileName fileName            = "C:\\Import\\FROM SMART VISTA\\a.txt";

        FileName fileNameMoved = "C:\\Import\\MOVED INTO AX\\a.txt";


        permissionSet = new Set(Types::Class);

        permissionSet.add(new InteropPermission(InteropKind::ClrInterop));

        permissionSet.add(new FileIOPermission(fileName , 'RWD'));

        permissionSet.add(new FileRepository());

        CodeAccessPermission::assertMultiple(permissionSet);

        WinAPIServer::copyFile(fileName,fileNameMoved,true);

        CodeAccessPermission::revertAssert();


Send sms txt via code in D365 F&O

 In this post, We will be writing code to send SMS via code :


System.Net.WebClient custWebclient;

System.IO.Stream InfoData;

System.IO.StreamReader Streamreader;

System.String URLStr;

Str SMSConfirmID;

str mobileno='919871286647';

str message='Test message';


custWebclient=new System.Net.WebClient();


URLStr = "https://api.textlocal.in/send/?apikey=" + "YOURAPIKEY" + "&numbers=" + mobileno + "&message=" + message + "&sender=txtcl";


InfoData=custWebclient.OpenRead(URLStr);

Streamreader=new System.IO.StreamReader(InfoData);

SMSConfirmID=Streamreader.ReadToEnd();

InfoData.Close();

Streamreader.Close();

Email via code in D365 F&O

In this post, We will be writing code to send mail via code:


 System.IO.Stream workbookStream = new System.IO.MemoryStream();

SysMailerSMTP   mailer = new SysMailerSMTP();

SysMailerMessageBuilder builder = new SysMailerMessageBuilder();

SysEmailParameters parameters = SysEmailParameters::find();

        

if (parameters.SMTPRelayServerName)

{

                mailer.SMTPRelayServer(parameters.SMTPRelayServerName,

                parameters.SMTPPortNumber,

                parameters.SMTPUserName,

                SysEmailParameters::password(),

                parameters.SMTPUseNTLM);

}

else

{

    warning("SERVER NOT FOUND");

}


builder.setFrom("atul.yadav@tectreeconsulting.com");

builder.addTo("atul.yadav@tectreeconsulting.com");

builder.setSubject("Subject of the Mail");

builder.setBody("This is the body of the mail");

SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(builder.getMessage());


Email SMTP setup in D365 F&O

Go to System Administration => Setup => Email => Email parameters.

Verify that SMTP is enabled.

Set the SMTP mail server settings.

outgoing mail server = smtp.office365.com

SMTP port number = 587

Fill the username and password accordingly

Saturday, January 16, 2021

How to automatically generate number sequence in new form

Write the following code in form


[Form]

public class NEWFORMNAME extends FormRun

{

    NumberSeqFormHandler                    numberSeqFormHandler;

    public void close()

    {

        if (numberSeqFormHandler)

        {

            numberSeqFormHandler.formMethodClose();

        }

        super();

    }


    NumberSeqFormHandler numberSeqFormHandler()

    {

        if (!numberSeqFormHandler)

        {

            numberSeqFormHandler =NumberSeqFormHandler::newForm(NumberSeqReference::findReference(extendedtypenum(EDTNAME)).NumberSequenceId,

                                                            element,

                                                            TABLENAME_ds,fieldnum(TABLENAME,FIELDNAME));

        }

        return numberSeqFormHandler;

    }


    [DataSource]

    class TABLENAME

    {

        public void linkActive()

        {

            element.numberSeqFormHandler().formMethodDataSourceLinkActive();

            super();

        }


        public void delete()

        {

            element.numberSeqFormHandler().formMethodDataSourceDelete();

            super();

        }


        public boolean validateWrite()

        {

            boolean ret;


            ret = super();


            ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;


            return ret;

        }


        public void write()

        {

            super();


            element.numberSeqFormHandler().formMethodDataSourceWrite();

        }


        public void create(boolean _append = false)

        {

            element.numberSeqFormHandler().formMethodDataSourceCreatePre();


            super(_append);


            element.numberSeqFormHandler().formMethodDataSourceCreate(true);

        }


    }


}

Friday, January 8, 2021

How to speed up Workflow in Ax2012

Open backend

Open AOT

Go to forms

"Tutorial_WorkFlowProcessor"

If we dont wanna wait for the workflow to run in batch



Other important setting of workflow can also be seen in "System Administrator" > "BatchJobs"