Friday, January 24, 2014

To Filter a record by dialog field thorugh X++ method clicked

// To Filter a record by dialog field thorugh X++ method clicked


// Date field

void MethodName()
{
    EmployeeDetails Emp_1;
    EmployeeTMP EmpTmp;

    Dialog dialog;
    DialogGroup dialogGroup;

    DialogField dialogFieldDateOfJoining1;
    DialogField dialogFieldDateOfJoining2;

    dialog = new Dialog("Employee DateOfJoining Filter");
    dialogGroup = dialog.addGroup("Employee Date Of Joining");
    dialogFieldDateOfJoining1 = dialog.addField(extendedTypeStr(DateofJoining),"Date Of Joining > = :");
    dialogFieldDateOfJoining2 = dialog.addField(extendedTypeStr(DateofJoining),"Date Of Joining < = :");

    delete_from EmpTmp;
    if(dialog.run())
    {

        //delete_from EmpTmp;

        while select Emp_1  where Emp_1.DateofJoining >= dialogFieldDateOfJoining1.value() && Emp_1.DateofJoining <= dialogFieldDateOfJoining2.value()
        {

            EmpTmp.EmpCode = Emp_1.EmpCode;
            EmpTmp.EmpName = Emp_1.EmpName;
            EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
            EmpTmp.Age = Emp_1.Age;
            EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
            EmpTmp.DateofJoining = Emp_1.DateofJoining;
            EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
            EmpTmp.Salary = Emp_1.Salary;
            EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
            EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
            EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;

            EmpTmp.insert();


        }
       EmployeeTMP_ds.research();
       EmployeeTMP_ds.refresh();
    }

  //  element.close();
    element.detach();
}


// Int field

void method name()
{
    EmployeeDetails Emp_1;
   EmployeeTMP EmpTmp;

    Dialog dialog;
    DialogGroup dialogGroup;

    DialogField dialogFieldEmpCode1;
    DialogField dialogFieldEmpCode2;

    dialog = new Dialog("Employee Code Filter");
    dialogGroup = dialog.addGroup("Employee Code");
    dialogFieldEmpCode1 = dialog.addField(extendedTypeStr(EmpCode),"EmpCode > :");
    dialogFieldEmpCode2 = dialog.addField(extendedTypeStr(EmpCode),"EmpCode < :");

    delete_from EmpTmp;

    if(dialog.run())
    {
        //info(dialogFieldEmpCode1.value());
        //info(dialogFieldEmpCode2.value());
       // delete_from EmpTmp;

        while select Emp_1  where Emp_1.EmpCode > dialogFieldEmpCode1.value()   && Emp_1.EmpCode < dialogFieldEmpCode2.value()
        {
            EmpTmp.EmpCode = Emp_1.EmpCode;
            EmpTmp.EmpName = Emp_1.EmpName;
            EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
            EmpTmp.Age = Emp_1.Age;
            EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
            EmpTmp.DateofJoining = Emp_1.DateofJoining;
            EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
            EmpTmp.Salary = Emp_1.Salary;
            EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
            EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
            EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;

            EmpTmp.insert();


        }
       EmployeeTMP_ds.research();
       EmployeeTMP_ds.refresh();
    }
  //  element.close();
    element.detach();
}


// Enum Field

void method Name()
{
    EmployeeDetails Emp_1;
   EmployeeTMP EmpTmp;

    Dialog dialog;
    DialogGroup dialogGroup;

    DialogField dialogFieldEmployeeDesgination;

    dialog = new Dialog("Employee Designation Filter");
    dialogGroup = dialog.addGroup(" Employee Designation");
    dialogFieldEmployeeDesgination = dialog.addField(enumStr(EmployeeDesgination),"EmployeeDesgination :");

    delete_from EmpTmp;

    if(dialog.run())
    {
        //delete_from EmpTmp;

        while select Emp_1  where Emp_1.EmployeeDesgination ==dialogFieldEmployeeDesgination.value()
        {

            EmpTmp.EmpCode = Emp_1.EmpCode;
            EmpTmp.EmpName = Emp_1.EmpName;
            EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
            EmpTmp.Age = Emp_1.Age;
            EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
            EmpTmp.DateofJoining = Emp_1.DateofJoining;
            EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
            EmpTmp.Salary = Emp_1.Salary;
            EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
            EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
            EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;

            EmpTmp.insert();


        }
       EmployeeTMP_ds.research();
       EmployeeTMP_ds.refresh();
    }

  //  element.close();
    element.detach();
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...