Wednesday, 7 January 2015

Mark / Un Mark -

The code should look like:

 
 
To get Un Mark all - custTable_ds.PAMarked(true,custTableLocal,false);
 
In Button Click method - write below code

 

Tuesday, 6 January 2015

Dialog : Conditional update in to DB

When you modify  vehicle status , dialog box should appear and when we click yes, log should be entered in to table , if no the value  should remain unchanged and record should not be entered in to table

public boolean modified()
{
    boolean ret;
    DialogButton diagBut;
     str strMessage,strTitle;
    NQ_ServiceObjectStatusLog nQ_ServiceObjectStatusLog;
     strMessage = "Do you Want to Change Vehicle Status";
     strTitle = "Status Change Confirmation";

    diagBut = Box::yesNoCancel(
        strMessage,
        DialogButton::No, // Initial focus is on the No button.
        strTitle);
    if (diagBut == DialogButton::No)
        {
            ret = false;
        }
    else
        {
            ret =true;
             ret = super();
            nQ_ServiceObjectStatusLog.ServiceObjectId = SMAObjectTable.ServiceObjectId;
            nQ_ServiceObjectStatusLog.NQ_VehicleStatus = SMAObjectTable.NQ_VehicleStatus;
            nQ_ServiceObjectStatusLog.UserId = curUserId();
            nQ_ServiceObjectStatusLog.StatusChangeTime = DateTimeUtil::getSystemDateTime();
            nQ_ServiceObjectStatusLog.insert();

        }
   //super();  Super - is mandatory commented super because, its opening 2 times  the dialog box, even after  entering  Yes. 

If  not commented , when you click "No" we are getting newly selected value not , previous value before selection . which is wrong.
    return ret;
}

To stop duplicate values to insert to same field in table : - With out setting index


 In Datasource level Validate method.  ( SMAObjectTable_AssetId.valueStr();- field in form , needed to declare auto declaration to true.
public boolean validate()
{
    boolean ret;

   SMAServiceObjectTable SMAServiceObjectTableloc;

    ret = super();

    select SMAServiceObjectTableloc where SMAServiceObjectTableloc.AssetId ==SMAObjectTable_AssetId.valueStr();
    if(SMAServiceObjectTableloc)
    {
        ret=  false;
        Box::warning("Asset Id is already assigned to some other Service object");
    }
    else
    {
        ret = true;
    }

    return ret;
}

To send email through SMTP :


    Declarations
  SysMailer   mailer = new SysMailer();
    SysEmailParameters parameters = SysEmailParameters::find();
    str Body,CCEmail;
   
    // Get Email forthe employee
    select HcmWorker where HcmWorker.PersonnelNumber == HcmEmploymentLeave.PersonnelNumber;
    select DirPartyTable where DirPartyTable.RecId == HcmWorker.Person;
    select DirPartyLocation where DirPartyLocation.Party == DirPartyTable.RecId;
    select LogisticsElectronicAddress where LogisticsElectronicAddress.Location == DirPartyLocation.Location
                                        && LogisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;
    // To get email for  Dept heads
    DeptHead = HcmWorker::findRecId(HcmWorker.DepartmentHead).Person;
    select DirPartyTableDeptHead where DirPartyTableDeptHead.RecId == DeptHead;
    select DirPartyLocationDeptHead where DirPartyLocationDeptHead.Party == DirPartyTableDeptHead.RecId;
    select LogisticsElectronicAddressDeptHead where LogisticsElectronicAddressDeptHead.Location == DirPartyLocationDeptHead.Location
                                        && LogisticsElectronicAddressDeptHead.Type == LogisticsElectronicAddressMethodType::Email;
     // To get email for  TeamLead
    TeamLead = HcmWorker::findRecId(HcmWorker.Supervisor).Person;
    select DirPartyTableTeamLead where DirPartyTableTeamLead.RecId == TeamLead;
    select DirPartyLocationTeamLead where DirPartyLocationTeamLead.Party == DirPartyTableTeamLead.RecId;
    select LogisticsElectronicAddressTeamLead where LogisticsElectronicAddressTeamLead.Location == DirPartyLocationTeamLead.Location
                                        && LogisticsElectronicAddressTeamLead.Type == LogisticsElectronicAddressMethodType::Email;
    //For SMTP 
    if (parameters.SMTPRelayServerName)
        {
            mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                               parameters.SMTPPortNumber,
                               parameters.SMTPUserName,
                               SysEmailParameters::password(),
                               parameters.NTLM);
        }
        else
        {
            mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                               parameters.SMTPPortNumber,
                               parameters.SMTPUserName,
                               SysEmailParameters::password(),
                               parameters.NTLM);
        }
   if(HcmEmploymentLeave.LeaveTypes == HcmAbsenceType::PermissionLeave)
    {
        CCEmail = LogisticsElectronicAddressDeptHead.Locator +";"+LogisticsElectronicAddressTeamLead.Locator;
        mailer.fromAddress('hr@dynamicnetsoft.com');
        mailer.tos().appendAddress(LogisticsElectronicAddress.Locator);
        mailer.ccs().appendAddress(CCEmail);
        mailer.htmlBody("Dear <b>"+ HcmEmploymentLeave.Employeename()+ "</b>,<br/><br/>We have processed your Permission Request referenced  "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate)+ " for the date "+ date2StrUsr(HcmEmploymentLeave.StartDate)+ " from "+ time2str(HcmEmploymentLeave.StartTime, TimeSeparator::Colon, TimeFormat::AMPM)+" to "+ time2str(HcmEmploymentLeave.EndTime,TimeSeparator::Colon, TimeFormat::AMPM)+ " for "+ time2StrHMS(HcmEmploymentLeave.NoOfHours)+ " hours. "+ "<br/><br/>Leave ID:"+ HcmEmploymentLeave.AbsenceID+ "<br/>Leave Type:"+ enum2str(HcmEmploymentLeave.LeaveTypes)+ "<br/>Start Date:"+ date2StrUsr(HcmEmploymentLeave.StartDate)+ "<br/>End Date:"+ date2StrUsr(HcmEmploymentLeave.EndDate)+ "<br/>Start Time:"+ time2str(HcmEmploymentLeave.StartTime, TimeSeparator::Colon, TimeFormat::AMPM)+ "<br/>End Time:"+ time2str(HcmEmploymentLeave.EndTime, TimeSeparator::Colon, TimeFormat::AMPM)+ "<br/>No.of Hours:"+ time2StrHMS(HcmEmploymentLeave.NoOfHours)+ "<br/>Reporting to Office on:"+ date2StrUsr(HcmEmploymentLeave.ReportingOn)+ "@"+ time2str(HcmEmploymentLeave.ExpectedTime, TimeSeparator::Colon, TimeFormat::AMPM)+  "<br/>No. of Permission taken in this month:"+ int2str(HcmEmploymentLeave.PermissionCount)+ "<br/>Note: Only 3 Permission is allowed per month, any additional permission will be considered as LOP or deduction in your vacation Holidays."+ "<br/><br/>Please submit or update HR on your report to work with in 1 hour from your reporting time.  Failure to do so may result in deduction of Half Day from your vacation days."+ "<br/><br/><br/>***<b>This is a system generated email, so please do not reply to this mail.  For any clarifications in your leave request, please contact HR directly </b>***");
        mailer.subject("HR Alert:  Your Permission Request ID "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate));
        mailer.sendMail();
    }
   else
    {
        CCEmail = LogisticsElectronicAddressDeptHead.Locator +";"+LogisticsElectronicAddressTeamLead.Locator;
        mailer.fromAddress('hr@dynamicnetsoft.com');
        mailer.tos().appendAddress(LogisticsElectronicAddress.Locator);
        mailer.ccs().appendAddress(CCEmail);
        mailer.htmlBody("Dear <b>"+ HcmEmploymentLeave.Employeename()+"</b>,<br/><br/>Thank you for submitting your leave application form.<br/><br/>We have processed your leave application referenced "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate)+ " against "+ enum2str(HcmEmploymentLeave.LeaveTypes)+ " for the date starting from "+ date2StrUsr(HcmEmploymentLeave.StartDate)+" to "+ date2StrUsr(HcmEmploymentLeave.EndDate)+ " for "+ int2str(HcmEmploymentLeave.NoOfDays)+ " day/days. "+ "<br/><br/>Leave ID:"+ HcmEmploymentLeave.AbsenceID+ "<br/>Leave Type:"+ enum2str(HcmEmploymentLeave.LeaveTypes)+ "<br/>Start Date:"+ date2StrUsr(HcmEmploymentLeave.StartDate)+ "<br/>End Date:"+ date2StrUsr(HcmEmploymentLeave.EndDate)+ "<br/>No.of Days:"+ int2str(HcmEmploymentLeave.NoOfDays)+ "<br/>Report back to Work: "+ date2StrUsr(HcmEmploymentLeave.ReportingOn)+ "<br/><br/>The application has been processed in the system successfully and intimated to your higher authority by email.  So please complete your “Report Back to Work” procedure on your return to work day "+ (date2StrUsr(HcmEmploymentLeave.ReportingOn))+ " and submit it to HR without fail to update the system off your return."+ "<br/><br/>As per the current records, following are the available leaves for your reference."+ "<br/><br/><br/>Casual Leave:"+ num2str(HcmEmploymentLeave.NoOfCasualDaysAvailable,1,2,1,2)+  "<br/>Privilege Leave:"+ num2str(HcmEmploymentLeave.NoOfPrivilegedLeaveAvailable,1,2,1,2)+  "<br/>Sick Leave:"+ num2str(HcmEmploymentLeave.NoOfSickLeaveAvailable,1,2,1,2)+ "<br/>Records as of "+ date2StrUsr(HcmEmploymentLeave.PostingDate)+ "<br/><br/>Please submit your “Report Back to Work form” duly signed by immediate reporting authority before end of "+ date2StrUsr(HcmEmploymentLeave.ReportingOn)+ "."+ " <br/>Note:  For Sick leave, it is mandatory you need to submit your Medical Certificate."+ "<br/><br/><br/>***<b>This is a system generated email, so please do not reply to this mail.  For any clarifications in your leave request, please contact HR directly </b>***");
        mailer.subject("HR Alert: Your Leave Application "+ HcmEmploymentLeave.AbsenceID+ " dated "+ date2StrUsr(HcmEmploymentLeave.PostingDate));
        mailer.sendMail();
    }

Get automatic number sequence for a field in table and then insert record through code

HcmAbsenceID absenceid; // EDT of the field. ( create  object )
absenceid  = NumberSeq::newGetNum(HRMParameters::numRefabsenceentryID()).num();
HcmEmployee.AbsenceID = absenceid;
HcmEmployee.Name = "Sujana";
HcmEmployee.insert();
Insert  a new record in HcmEmployee with numbersequence.
===============================================================
[ In form  level  to get automatic number sequence.
if (!numberSeqFormHandler)
    {
        numberSeqFormHandler = NumberSeqFormHandler::newForm(HRMParameters::numRefabsenceentryID().NumberSequenceId,
                                                             element,
                                                             HcmEmploymentLeave_ds,
                                                             fieldNum(HcmEmploymentLeave,AbsenceID)
                                                            );
    }
    return numberSeqFormHandler;
]

Grid posted records as editable if not posted, else non - editable :

  public int active()
{
    int ret;
    if(IPMPFComodityLines.Post == NoYes::Yes)
    {
        TransactionLinesGrid.allowEdit(false);
    }
    else
        {
            TransactionLinesGrid.allowEdit(true);
    }
    ret = super();
    return ret;
}

Contents of TDD (Technical Design Document)

  1.  Technical Design Planning
Overview
Microsoft Dynamics AX functional and technical understanding is needed to plan this Technical
Design Document.  A developer needs to know how the AX functional part works and what options will
affect functionality of other forms or processing. The AX AOT is used to add new or modify existing
objects, elements. AOT expert understanding will help to develop a solution with least amount of
changes.
Timetable
1.            Study of functional document
2.            Discussion with functional consultant
3.            Study of Existing development
4.            Determine what needs to be added or changed.
5.            Estimate the timeframe to do development, testing and re-work and re-test
 Roles and Responsibilities
The AX Developer/Designer will create this document and estimate the time needed to develop and
test and potentially re-work and re-test.  Once it is in the Development Environment and has been
approved, the modification will be migrated to the Test Environment for further testing.  Upon
approval, the modification will be migrated to the Production Environment.
2     2.  Review Design Document
     A developer will customize the some of the forms for Human Resources and Payroll. The customization
part will cover
3  3. Document User Interface :- All the forms with screen shots and explanation will be there
    4. Define Data Modifications:- Updates object names ( like Table names and fields, EDTS,Enum etc)