Wednesday, March 30, 2022

SSMS Database backup path

 C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup\

Monday, March 21, 2022

Worker position in D365 FO

 display str workerPositionId()

    {

        HcmPositionDetail               hcmPositionDetail;

        HcmPosition                     hcmPosition;

        HcmPositionWorkerAssignment     workerAssignment;

        HcmWorker                       hcmWorker;

        HcmJob                          hcmJob;


        select hcmPositionDetail

            join  hcmPosition

                where hcmPositionDetail.Position == hcmPosition.RecId

            join  workerAssignment

                where hcmPosition.RecId == workerAssignment.Position

            join  hcmWorker

                where hcmWorker.RecId == workerAssignment.Worker

                &&    hcmWorker.RecId == this.Worker;

        select * from hcmjob

            where hcmjob.RecId==hcmPositionDetail.Job;

        return hcmjob.JobId;

    }

Saturday, March 19, 2022

Uploading file on SharePoint D365 FO

The following class will create a "TextFile.txt" in "MyFolder" folder of the sharepoint.

Class GITS_Testing

{

    public static void main(Args _args)

    {

        System.UriBuilder builder = new System.UriBuilder("https://osoolbh.sharepoint.com/sites/Testing");

        str extId = xUserInfo::getExternalId();

        Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider provider;

        Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation documentLocation = new Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation();

        provider = new Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider("osoolbh.sharepoint.com", "sites/Testing", "Shared%20Documents/MyFolder", extId);

        System.Byte[] reportBytes = new System.Byte[0]();

        System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();

        reportBytes = enc.GetBytes("AY");

        System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(reportBytes);

        documentLocation = provider.SaveFile(newGuid(), 'TextFile.txt', System.Web.MimeMapping::GetMimeMapping('TextFile.txt'), memoryStream);

    }


}

Wednesday, March 16, 2022

How to take data from report parameter before running the report - SSRS Report


To get marked data in controller/DP class before the report runs

Controller:


class GITS_CertificateOfSalaryController extends SrsReportRunController

{

    EnglishArabic   EnglishArabic;



    public static GITS_CertificateOfSalaryController construct()

    {

        return new GITS_CertificateOfSalaryController();

    }


    public static  void main(Args _args)

    {

        GITS_CertificateOfSalaryController  GITS_CertificateOfSalaryController = GITS_CertificateOfSalaryController::construct();

        GITS_CertificateOfSalaryController.parmReportName(ssrsReportStr(GITS_CertificateOfSalary, Report));

        GITS_CertificateOfSalaryController.parmArgs(_args);

        GITS_CertificateOfSalaryController.parmDialogCaption("Certificate of letter");

        GITS_CertificateOfSalaryController.startOperation();

    }


    protected void preRunModifyContract()

    {

        RefRecId worker;

        GITS_CertificateOfSalaryContract contract = this.parmReportContract().parmRdpContract() as GITS_CertificateOfSalaryContract;

        worker          = contract.parmWorkerRecId();

        EnglishArabic   = contract.parmEnglishArabic();

        this.parmReportContract().parmReportName(this.getReportName(contract));

        super();

    }


    protected void prePromptModifyContract()

    {


    }


    private str getReportName(GITS_CertificateOfSalaryContract _contract)

    {

        str lclReportName;

        if (_contract.parmEnglishArabic() == EnglishArabic::English)

        {

            lclReportName = ssrsReportStr(GITS_CertificateOfSalary, Report);

        }

        if (_contract.parmEnglishArabic() == EnglishArabic::Arabic)

        {

            lclReportName = ssrsReportStr(GITS_CertificateOfSalary, ReportArabic);

        }

        return lclReportName;

    }


}



Contract:


[DataContractAttribute]

public class GITS_CertificateOfSalaryContract

{

    HcmWorkerRecId  WorkerRecId;

    EnglishArabic   EnglishArabic;

    [

        DataMemberAttribute(identifierStr(WorkerRecid)),

        SysOperationLabelAttribute("Employee"),

        SysOperationDisplayOrderAttribute('1')

    ]

    public HcmWorkerRecId parmWorkerRecId(HcmWorkerRecId _WorkerRecId = WorkerRecId)

    {

        WorkerRecId = _WorkerRecId;

        return WorkerRecId;

    }


    [

        DataMemberAttribute(identifierStr(EnglishArabic)),

        SysOperationLabelAttribute("Language"),

        SysOperationDisplayOrderAttribute('2')

    ]

    public EnglishArabic parmEnglishArabic(EnglishArabic _EnglishArabic = EnglishArabic)

    {

        EnglishArabic = _EnglishArabic;

        return EnglishArabic;

    }


}



DP Class:


[SRSReportParameterAttribute(classStr(GITS_CertificateOfSalaryContract))]

class GITS_CertificateOfSalaryDP extends SRSReportDataProviderBase

{

    GITS_CertificateOfSalaryTmp     GITS_CertificateOfSalaryTmp;

    CompanyInfo                     companyinfo;




    [SRSReportDataSetAttribute(tablestr(GITS_CertificateOfSalaryTmp))]

    public GITS_CertificateOfSalaryTmp getGITS_CertificateOfSalaryTmp()

    {

        select GITS_CertificateOfSalaryTmp;

        return GITS_CertificateOfSalaryTmp;

    }


    public void processReport()

    {

        GITS_CertificateOfSalaryContract        contract;

        HcmWorkerRecId                          worker;

        EnglishArabic                           EnglishArabic;

        HcmPositionWorkerAssignment             HcmPositionWorkerAssignmentLocal;

        HcmPosition                             HcmPositionLocal;

        HcmPositionDetail                       HcmPositionDetailLocal;

        HRMCourseAttendee                       HRMCourseAttendeeLocal;

        HRMCourseTable                          HRMCourseTableLocal;

        HcmPersonIdentificationNumber           hcmPersonIdentificationNumber;

        DirPerson                               DirPerson;

        HcmPosition                             hcmPosition;

        HcmPositionDetail                       hcmPositionDetail;

        HcmPositionWorkerAssignment             workerAssignment;

        HcmWorker                               hcmWorker;

        ;

        contract        = this.parmDataContract() as GITS_CertificateOfSalaryContract;

        companyinfo     = CompanyInfo::find();

        worker          = contract.parmWorkerRecId();

        EnglishArabic   = contract.parmEnglishArabic();

        TransDate   dateLocal = today();

        select validTimeState(dateLocal,dateLocal) HcmPositionWorkerAssignmentLocal

            where HcmPositionWorkerAssignmentLocal.Worker == worker;

        select * from HcmPositionLocal

            where HcmPositionLocal.RecId == HcmPositionWorkerAssignmentLocal.Position;

        select * from HcmPositionDetailLocal

            where HcmPositionDetailLocal.Position == HcmPositionLocal.RecId;

        select * from HRMCourseAttendeeLocal order by RecId desc

            where HRMCourseAttendeeLocal.Person == HcmWorker::find(worker).Person;

        select * from HRMCourseTableLocal

            where HRMCourseTableLocal.hrmCourseId == HRMCourseAttendeeLocal.hrmCourseId;

        select hcmPersonIdentificationNumber

            where hcmPersonIdentificationNumber.Description == "Passport"

                join DirPerson

            where hcmPersonIdentificationNumber.person == dirPerson.recid

            &&    DirPerson.RecId == HcmWorker::find(worker).Person;

        select hcmPositionDetail

                  join  hcmPosition

                        where hcmPositionDetail.Position == hcmPosition.RecId

                  join  workerAssignment

                        where hcmPosition.RecId == workerAssignment.Position

                  join  hcmWorker

                        where hcmWorker.RecId == workerAssignment.Worker

                        &&    hcmWorker.RecId == worker;

        GITS_CertificateOfSalaryTmp.clear();

        GITS_CertificateOfSalaryTmp.CompanyName       = companyinfo.name();

        GITS_CertificateOfSalaryTmp.CompanyEmail      = companyinfo.email();

        GITS_CertificateOfSalaryTmp.CompanyAddress    = companyinfo.postalAddress().Address;

        GITS_CertificateOfSalaryTmp.CompanyPhoneMobile= companyinfo.phone();

        GITS_CertificateOfSalaryTmp.CompanyFax        = companyinfo.teleFax();

        GITS_CertificateOfSalaryTmp.CompanyLogo       = FormLetter::companyLogo();

        GITS_CertificateOfSalaryTmp.Name              = HcmWorker::find(contract.parmWorkerRecId()).Name();

        GITS_CertificateOfSalaryTmp.TransDate         = DAPEmplContract::findActiveContractForEmpl(worker).ValidFrom;

        GITS_CertificateOfSalaryTmp.JoiningDate       = subStr(any2Str(GITS_CertificateOfSalaryTmp.TransDate),1,10);

        GITS_CertificateOfSalaryTmp.PassportNumber    = hcmPersonIdentificationNumber.IdentificationNumber;

        

        GITS_CertificateOfSalaryTmp.Position          = hcmPositionDetail.Description;

        GITS_CertificateOfSalaryTmp.Salary            = DAPEmplContract::findActiveContractForEmpl(worker).BasicSalary;

        GITS_CertificateOfSalaryTmp.SalaryWords       = Global::numeralsToTxt(GITS_CertificateOfSalaryTmp.Salary);

        GITS_CertificateOfSalaryTmp.Course            = HRMCourseTableLocal.description;

        GITS_CertificateOfSalaryTmp.CourseLocaltion   = HRMCourseTableLocal.hrmCourseLocationId;

        GITS_CertificateOfSalaryTmp.Department        = hcmWorker.primaryDepartmentName();

        str b = any2Str(DatetimeUtil::month(HRMCourseTableLocal.startDateTime));    str c = any2Str(DatetimeUtil::year(HRMCourseTableLocal.startDateTime));     str h = any2Str(DatetimeUtil::day(HRMCourseTableLocal.startDateTime));

        str e = any2Str(DatetimeUtil::month(HRMCourseTableLocal.endDateTime));      str f = any2Str(DatetimeUtil::year(HRMCourseTableLocal.endDateTime));       str g = any2Str(DatetimeUtil::day(HRMCourseTableLocal.endDateTime));

        str Duration = h + "-" + b + "-" + c + " to " + g + "-" + e + "-" + f;

        GITS_CertificateOfSalaryTmp.CourseDuration    =  Duration;

        if(HcmPersonPrivateDetails::findByPerson(HcmWorker::find(worker).Person).Gender == HcmPersonGender::Male)

        {

            GITS_CertificateOfSalaryTmp.HisHer = "His";   GITS_CertificateOfSalaryTmp.HeShe  = "He";    GITS_CertificateOfSalaryTmp.HeSheSmall = "he";

            GITS_CertificateOfSalaryTmp.MrMrs  = "Mr";    GITS_CertificateOfSalaryTmp.HimHer = "Him";   GITS_CertificateOfSalaryTmp.HimHerSmall = "him";

        }

        if(HcmPersonPrivateDetails::findByPerson(HcmWorker::find(worker).Person).Gender == HcmPersonGender::Female)

        {

            GITS_CertificateOfSalaryTmp.HisHer = "Her";       GITS_CertificateOfSalaryTmp.HeShe  = "She";       GITS_CertificateOfSalaryTmp.HeSheSmall = "she";

            GITS_CertificateOfSalaryTmp.MrMrs  = "Mrs";       GITS_CertificateOfSalaryTmp.HimHer = "Her";       GITS_CertificateOfSalaryTmp.HimHerSmall = "her";

        }

        GITS_CertificateOfSalaryTmp.insert();

    }


}

Monday, March 14, 2022

ListPage Interaction basic class in D365 FO

 class GITS_TicketRequestInteraction extends ListPageInteraction

{

        DAPEmplContract     dapEmplContract,DAPEmplContractlcl;

        DAPTicketRequest    DAPTicketRequestLocal;


        private DAPTicketRequest DAPTicketRequest()

        {

            return this.listPage().activeRecord(queryDatasourceStr(DAPTicketRequestQ, DAPTicketRequest_1)) as DAPTicketRequest;

        }


        public void initializeQuery(Query _query)

        {

            if (this.listPage().listPageArgs().menuItemName() == 'GITS_TicketRequest_ESS')

            {

                _query.dataSourceTable(tableNum(DAPTicketRequest)).addRange(fieldNum(DAPTicketRequest, Worker)).value(int642Str(HcmWorkerLookup::currentWorker()));

                _query.dataSourceTable(tableNum(DAPTicketRequest)).addRange(fieldNum(DAPTicketRequest, Worker)).status(RangeStatus::Locked);

            }

            super(_query);

        }


        public void selectionChanged()

        {

            if(this.listPage().listPageArgs().menuItemName() == 'GITS_TicketRequest_ESS')

            {

                this.listPage().actionPaneControlVisible(formcontrolstr(GITS_TicketRequest, NewButton), false);

            }

            super();

        }


}

Saturday, March 12, 2022

The service in unavailable error in dynamics 365 ?



Make sure World Wide Web Publishing Service is running


Make sure the application pool for AOSService is running or not on IIS(Internet Information Services)


Restart IIS IISExpress



Tuesday, March 8, 2022

Time to String in D365 FO

Str ToTimeStr;

ToTimeStr =  time2str(this.ToTime,TimeSeparator::Auto, TimeFormat::Hour24);

How to do Job History cleanup in D365 FO

Turn on the Execution history cleanup feature in the "Feature management"




Now in the Data management workspace, select Job history cleanup





Note:
The following tables will be cleaned up:

All staging tables
DMFSTAGINGVALIDATIONLOG
DMFSTAGINGEXECUTIONERRORS
DMFSTAGINGLOGDETAIL
DMFSTAGINGLOG
DMFDEFINITIONGROUPEXECUTIONHISTORY
DMFEXECUTION
DMFDEFINITIONGROUPEXECUTION

Monday, March 7, 2022

How to know the name of caller form using args ?

 str callerName;

callerName = args.caller().name();


// Checking if args dataset is some specific dataset

args.dataset() == tableNum(LedgerJournalTrans)