I have created customize form for creating new employee in AX 2012. Form was working correctly when deployed on test server but when i deployed on live server it is misbehaving. When user insert data first time then form insert values in all tables but when user insert second record it insert data only in some table not all table. What should be the reason.
Note : I want to tell you that I have written all insert code in click method of button.
Here is my code
void clicked() { DialogButton Button; boolean ret = true; boolean isHcmPositionTable; boolean ishcmjobtable; boolean ishcmjobdetail; boolean ishcmpositiondetailtable; boolean ishcmpositiondurationtable; boolean ishcmpositiondefaultdimensiontable; boolean isPayrollPositionDetailstable; boolean ishcmworkertable; boolean ishcmemploymenttable; boolean ishcmemploymentdetailtable; boolean isWorkCalendarEmploymenttable; boolean isHcmPersonPrivateDetailstable; boolean isaddressView; boolean ishcmpersondetails; boolean isPayrollWorkerPositionEarningCode; boolean isHRMCompFixedEmpl; CompanyInfo companyInfo; HcmEmploymentRecId newEmploymentRecId; HcmPositionWorkerAssignmentRecId newPositionWorkerAssignmentRecId; HcmPositionWorkerAssignmentStartDate assignmentStrtDt; HcmPositionWorkerAssignmentEndDate assignmentEndDt; str newWorkerContractId,_earningCode; int64 internshipDurationVar; SL_InternshipDuration durationUnit; utcDateTime newDateIntern; boolean isRenew; date _joiningDate; #RetailSMB //utcDateTime validFrom; //laraib code DirPersonName _dirPersonName; ValidFromDateTime employmentStartDateTime; ValidToDateTime employmentEndDateTime; HcmTitle _hcmtitletable; HcmWorkerPrimaryPosition _HcmWorkerPrimaryPositionTable; HcmJob _hcmjobtable; HcmPosition _hcmpositiontable; HcmPositionDetail _hcmpositiondetailtable; HcmPositionDuration _hcmpositiondurationtable; HcmPositionDefaultDimension _hcmpositiondefaultdimensiontable; HcmWorker _hcmworkertable; HcmEmployment _hcmemploymenttable; HcmEmploymentDetail _hcmemploymentdetailtable; WorkCalendarEmployment _WorkCalendarEmploymenttable; HcmPersonPrivateDetails _HcmPersonPrivateDetailstable; DirPartyPostalAddressView _DirPartyPostalAddressViewtable; HcmPersonDetails _hcmpersondetails; PayrollWorkerPositionEarningCode _PayrollWorkerPositionEarningCode; HRMCompFixedEmpl _HRMCompFixedEmpl; HcmWorkerTitle _HcmWorkerTitletable; HcmJobDetail _hcmjobdetail; OMOperatingUnit _department; PayrollPositionDetails _PayrollPositionDetailstable; HCMPOSITIONWORKERASSIGNMENT _hcmpositionworkerassignmenttable; str _zone,_city,_location,_financialdept; date _HcmPersonBirthDate; HRMCompFixedEmplActionHire hrmCompFixedEmplActionHire; HRMCompFixedPlanTable hrmCompFixedPlanTable; str NewActionId = 'Hire'; str NewPlanId = 'Worker',_Userbranch; int64 _personnelno; HcmPersonnelNumberId _Generatedpersonalnumber,_hcmPersonnelNumberId; HcmEmploymentType _employmenttype; HcmPersonGender _gender; PaymMode _paymentmode; SysUserInfo _SysUserInfo; DirPartyPostalAddressView _dirPartyPostalAddressView; DirParty _dirPartyforaddress; DirPartyTable _dirPartyTable; DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage(); DimensionDefault result; int i; DimensionAttribute dimensionAttribute; DimensionAttributeValue dimensionAttributeValue; container conAttr = ["Zone", "Branch","Department_Costcenter","Item_Faimly","Location"]; // Dimensions container conValue; str dimValue; DirPersonRecId _dirPersonRecid; DirPartyPostalAddressView _addressView; dirPartyContactInfoView _contactView; DirParty _dirParty; container _roles; boolean _isAlltable = false; BOOLEAN _isAllPositiontable = false; boolean _isAllemploymenttable = false; boolean _isdetailtables = true; isHcmPositionTable = false; ishcmjobtable = false; ishcmjobdetail = false; ishcmpositiondetailtable = false; ishcmpositiondurationtable = false; ishcmpositiondefaultdimensiontable = false; isPayrollPositionDetailstable = false; ishcmworkertable = false; ishcmemploymenttable = false; ishcmemploymentdetailtable = false; isWorkCalendarEmploymenttable = false; isHcmPersonPrivateDetailstable = false; isaddressView = false; ishcmpersondetails = false; isPayrollWorkerPositionEarningCode = false; isHRMCompFixedEmpl = false; if (element.isValidCreate() == false) { throw error("You have missed above mandatory fields thats why this Employee Can not be created. Please Reopen this form and do the process."); //info('You have missed above mandatory fields thats why this Employee Can not be created. Please Reopen this form and do the process.'); //Ok.visible(false); } else if(element.isValidCreate() == true) { _Generatedpersonalnumber = personnelNumber.valueStr(); if (isAlreadyCNICExist == true) { Button= Box::okCancel('This person was your employee. Are you sure to rehire this person.',DialogButton::No); if (Button == DialogButton::Ok) { element.rehireemployee(); } //element.rehireemployee(); } else if (isAlreadyCNICExist == false) { Ok.visible(true); _SysUserInfo = SysUserInfo::find(curUserId()); if(_SysUserInfo.Id == 'laraib.t') { SLPRLMethodOfPayment.visible(false); _HcmPersonBirthDate = DateTimeUtil::date(utc_Datetime.dateTimeValue()); dirPersonName.FirstName = FirstName.valueStr(); dirPersonName.MiddleName = MiddleName.valueStr(); dirPersonName.LastName = LastName.valueStr(); _joiningDate = DateTimeUtil::date(EmploymentStartDate.dateTimeValue()); employmentStartDateTime = datetobeginUtcDateTime(_joiningDate,DateTimeUtil::getUserPreferredTimeZone()); employmentEndDateTime = DateTimeUtil::maxValue(); _gender = Gender.selection(); _department = OMOperatingUnit::findName(Dept.valueStr(),OMOperatingUnitType::OMDepartment); _employmenttype = HcmEmploymentType::Contractual; _Userbranch = 'BQF'; _location = 'Bin Qasim Factory'; _zone = 'South'; _city = 'Karachi'; _financialdept = 'Production-BQF'; HcmEmployment_PaymMode.enabled(true); relationType.enabled(true); if (_zone && _city && _location && _financialdept) { conValue = [DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144582,_zone).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144581,_location).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144578,_financialdept).Value,"999", DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144576,_city).Value]; } for (i = 1; i <= conLen(conAttr); i ) { dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i)); if (dimensionAttribute.RecId == 0) { continue; } dimValue = conPeek(conValue,i); if (dimValue != "") { // The last parameter is “true”. A dimensionAttributeValue record will be created if not //found. dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true); // Add the dimensionAttibuteValue to the default dimension valueSetStorage.addItem(dimensionAttributeValue); } } result = valueSetStorage.save(); } if(_SysUserInfo.Id == 'raheel.a') { _HcmPersonBirthDate = DateTimeUtil::date(utc_Datetime.dateTimeValue()); dirPersonName.FirstName = FirstName.valueStr(); dirPersonName.MiddleName = MiddleName.valueStr(); dirPersonName.LastName = LastName.valueStr(); _joiningDate = DateTimeUtil::date(EmploymentStartDate.dateTimeValue()); employmentStartDateTime = datetobeginUtcDateTime(_joiningDate,DateTimeUtil::getUserPreferredTimeZone()); employmentEndDateTime = DateTimeUtil::maxValue(); _gender = Gender.selection(); _department = OMOperatingUnit::findName(Dept.valueStr(),OMOperatingUnitType::OMDepartment); _employmenttype = HcmEmploymentType::Contractual; _paymentmode = 'CASH'; ////////////////////////// _Userbranch = 'BQF'; _location = 'Bin Qasim Factory'; _zone = 'South'; _city = 'Karachi'; _financialdept = 'Production-BQF'; HcmEmployment_PaymMode.enabled(false); relationType.enabled(false); _employmenttype = HcmEmploymentType::Contractual; _paymentmode = 'CASH'; if (_zone && _city && _location && _financialdept) { conValue = [DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144582,_zone).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144581,_location).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144578,_financialdept).Value,"999", DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144576,_city).Value]; } for (i = 1; i <= conLen(conAttr); i ) { dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i)); if (dimensionAttribute.RecId == 0) { continue; } dimValue = conPeek(conValue,i); if (dimValue != "") { // The last parameter is “true”. A dimensionAttributeValue record will be created if not //found. dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true); // Add the dimensionAttibuteValue to the default dimension valueSetStorage.addItem(dimensionAttributeValue); } } result = valueSetStorage.save(); } if(_SysUserInfo.Id == 'ikram.qa') { _HcmPersonBirthDate = DateTimeUtil::date(utc_Datetime.dateTimeValue()); dirPersonName.FirstName = FirstName.valueStr(); dirPersonName.MiddleName = MiddleName.valueStr(); dirPersonName.LastName = LastName.valueStr(); _joiningDate = DateTimeUtil::date(EmploymentStartDate.dateTimeValue()); employmentStartDateTime = datetobeginUtcDateTime(_joiningDate,DateTimeUtil::getUserPreferredTimeZone()); employmentEndDateTime = DateTimeUtil::maxValue(); _gender = Gender.selection(); _department = OMOperatingUnit::findName(Dept.valueStr(),OMOperatingUnitType::OMDepartment); _employmenttype = HcmEmploymentType::Contractual; _paymentmode = 'CASH'; ////////////////////////////////////////// _Userbranch = 'PQF'; _location = 'Port Qasim Factory'; _zone = 'South'; _city = 'Karachi'; _financialdept = 'Production PQF'; relationType.enabled(false); HcmEmployment_PaymMode.enabled(false); _employmenttype = HcmEmploymentType::Contractual; _paymentmode = 'CASH'; if (_zone && _city && _location && _financialdept) { conValue = [DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144582,_zone).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144581,_location).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144578,_financialdept).Value,"999", DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144576,_city).Value]; } for (i = 1; i <= conLen(conAttr); i ) { dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i)); if (dimensionAttribute.RecId == 0) { continue; } dimValue = conPeek(conValue,i); if (dimValue != "") { // The last parameter is “true”. A dimensionAttributeValue record will be created if not //found. dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true); // Add the dimensionAttibuteValue to the default dimension valueSetStorage.addItem(dimensionAttributeValue); } } result = valueSetStorage.save(); } if(_SysUserInfo.Id == 'axtest') { SLPRLMethodOfPayment.visible(false); _HcmPersonBirthDate = DateTimeUtil::date(utc_Datetime.dateTimeValue()); dirPersonName.FirstName = FirstName.valueStr(); dirPersonName.MiddleName = MiddleName.valueStr(); dirPersonName.LastName = LastName.valueStr(); _joiningDate = DateTimeUtil::date(EmploymentStartDate.dateTimeValue()); employmentStartDateTime = datetobeginUtcDateTime(_joiningDate,DateTimeUtil::getUserPreferredTimeZone()); employmentEndDateTime = DateTimeUtil::maxValue(); _gender = Gender.selection(); _department = OMOperatingUnit::findName(Dept.valueStr(),OMOperatingUnitType::OMDepartment); _employmenttype = HcmEmploymentType::Contractual; _Userbranch = 'BQF'; _location = 'Bin Qasim Factory'; _zone = 'South'; _city = 'Karachi'; _financialdept = 'Production-BQF'; HcmEmployment_PaymMode.enabled(true); relationType.enabled(true); if (_zone && _city && _location && _financialdept) { conValue = [DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144582,_zone).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144581,_location).Value, DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144578,_financialdept).Value,"999", DimensionFinancialTag::findByFinancialTagCategoryAndDiscription(5637144576,_city).Value]; } for (i = 1; i <= conLen(conAttr); i ) { dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i)); if (dimensionAttribute.RecId == 0) { continue; } dimValue = conPeek(conValue,i); if (dimValue != "") { // The last parameter is “true”. A dimensionAttributeValue record will be created if not //found. dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true); // Add the dimensionAttibuteValue to the default dimension valueSetStorage.addItem(dimensionAttributeValue); } } result = valueSetStorage.save(); } if(_SysUserInfo.Id == 'laraib.t' || _SysUserInfo.Id == 'axtest' || _SysUserInfo.Id == 'raheel.a' || _SysUserInfo.Id == 'ikram.qa') { _hcmtitletable = HcmTitle::findByTitle(designation.valueStr()); if(!_hcmtitletable) { throw error('Employee can not be created beacuse you have selected wrong designation.'); info('Please ask HR Dept to create new designation.'); } else if(_hcmtitletable) { //checking either job exist or not _hcmjobtable = HcmJob::findByJob(_hcmtitletable.TitleId); _hcmjobdetail = HcmJobDetail::findByJob(_hcmjobtable.RecId); if(!_hcmjobtable) { _hcmjobtable.clear(); _hcmjobtable.initValue(); _hcmjobtable.JobId = designation.valueStr(); _hcmjobtable.MaximumPositions = 2147483647; if(_hcmjobtable.validateWrite()) { _hcmjobtable.insert(); ishcmjobtable =true; } _hcmjobdetail = HcmJobDetail::findByJob(_hcmjobtable.RecId); if (!_hcmjobdetail) { _hcmjobdetail.clear(); _hcmjobdetail.initValue(); _hcmjobdetail.Job = _hcmjobtable.RecId; _hcmjobdetail.ValidFrom = DateTimeUtil::addHours(employmentStartDateTime, -3); _hcmjobdetail.ValidTo = employmentEndDateTime; _hcmjobdetail.DefaultFullTimeEquivalency = 1.00; _hcmjobdetail.Description = _hcmjobtable.JobId; _hcmjobdetail.CompensationLevel = 5637144576; _hcmjobdetail.Title = _hcmtitletable.RecId; _hcmjobdetail.JobFunction = 0; _hcmjobdetail.JobType = 0; _hcmjobdetail.SurveyCompany = 0; if(_hcmjobdetail.validateWrite()) { _hcmjobdetail.insert(); ishcmjobdetail =true; } } } if (dirPersonName.Person != 0 || element.checkDuplicateName()) { select firstonly RecId from companyInfo where companyInfo.DataArea == 'rni'; //startLengthyOperation(); } //if (ishcmjobtable == true && ishcmjobdetail == true) //{ // inserting hcmposition table _hcmpositiontable.clear(); _hcmpositiontable.initValue(); _hcmpositiontable.PositionId = NumberSeq::newGetNum(NumberSeqReference::findReference(extendedTypeNum(HcmPositionId)), true).num(); _hcmpositiontable.insert(); //ishcmpositiontable =true; _hcmpositiondetailtable = HcmPositionDetail::findByPosition(_hcmpositiontable.RecId); if (!_hcmpositiondetailtable) { //inserting hcmposition detail table _hcmpositiondetailtable.clear(); _hcmpositiondetailtable.initValue(); _hcmpositiondetailtable.Position = _hcmpositiontable.RecId; _hcmpositiondetailtable.Job = HcmJob::findByJob(_hcmjobtable.JobId).RecId; _hcmpositiondetailtable.ValidFrom = employmentStartDateTime; _hcmpositiondetailtable.ValidTo = employmentEndDateTime; _hcmpositiondetailtable.Position = _hcmpositiontable.RecId; _hcmpositiondetailtable.Department = _department.recid; _hcmpositiondetailtable.Description =_hcmtitletable.TitleId; _hcmpositiondetailtable.Title = _hcmtitletable.RecId; _hcmpositiondetailtable.Job = _hcmjobdetail.Job; _hcmpositiondetailtable.FullTimeEquivalency = 0.00; _hcmpositiondetailtable.CompLocation = 0; _hcmpositiondetailtable.PositionType = 5637144577; if(_hcmpositiondetailtable.validateWrite()) { _hcmpositiondetailtable.insert(); //ishcmpositiondetailtable =true; } //checking hcmpositiondurationtable _hcmpositiondurationtable = HcmPositionDuration::findByPosition(_hcmpositiontable.RecId); _PayrollPositionDetailstable = PayrollPositionDetails::findByPosition(_hcmpositiontable.RecId); if(!_hcmpositiondurationtable) { _hcmpositiondurationtable.clear(); _hcmpositiondurationtable.initValue(); _hcmpositiondurationtable.Position = _hcmpositiontable.RecId; _hcmpositiondurationtable.ValidFrom = employmentStartDateTime; _hcmpositiondurationtable.ValidTo = employmentEndDateTime; if(_hcmpositiondurationtable.validateWrite()) { _hcmpositiondurationtable.insert(); // ishcmpositiondurationtable = true; } } if (!_hcmpositiondefaultdimensiontable) { //inserting hcmpositiondefaultdimensiontable _hcmpositiondefaultdimensiontable.LegalEntity = companyInfo.RecId; _hcmpositiondefaultdimensiontable.DefaultDimension = result; _hcmpositiondefaultdimensiontable.Position = _hcmpositiontable.RecId; _hcmpositiondefaultdimensiontable.AccountingDistributionTemplate = 0; if(_hcmpositiondefaultdimensiontable.validateWrite()) { _hcmpositiondefaultdimensiontable.insert(); //ishcmpositiondefaultdimensiontable =true; } } if (!_PayrollPositionDetailstable) { _PayrollPositionDetailstable.AutoGenerateSalary = NoYes::Yes; _PayrollPositionDetailstable.DefaultEarningCode = 5637144576; _PayrollPositionDetailstable.DefaultGLIBenefit = 0; _PayrollPositionDetailstable.GenerateEarningsFromSchedule = NoYes::No; _PayrollPositionDetailstable.IsCompanyOfficer = NoYes::No; _PayrollPositionDetailstable.PaidByLegalEntity = 5637145326; _PayrollPositionDetailstable.PayCycle = 5637144576; _PayrollPositionDetailstable.PayrollNormalHours = 2920.00; _PayrollPositionDetailstable.PayrollOvertimeHours = 0.00; _PayrollPositionDetailstable.Position = _hcmpositiontable.RecId; _PayrollPositionDetailstable.Schedule = "Calendar"; _PayrollPositionDetailstable.ScheduleDataAreaId = "rni"; _PayrollPositionDetailstable.ValidFrom = DateTimeUtil::date(employmentStartDateTime);// DateTimeUtil::date(DateTimeUtil::addHours(EmploymentStartDate.dateTimeValue(), -1)); _PayrollPositionDetailstable.ValidTo = DateTimeUtil::date(employmentEndDateTime); _PayrollPositionDetailstable.WorkCycle = 0; if(_PayrollPositionDetailstable.validateWrite()) {_PayrollPositionDetailstable.insert(); // isPayrollPositionDetailstable = true; } } } //} //if(isPayrollPositionDetailstable == true && ishcmpositiontable == true && ishcmpositiondefaultdimensiontable == true //&& ishcmpositiondetailtable == true) //{ //_isAllPositiontable = true; // //} //if (_employmenttype == HcmEmploymentType::Contractual) //{ // // //if (_Userbranch == 'BQF') //{ //select firstfast _hcmworkertable order by _hcmworkertable.PersonnelNumber desc //where _hcmworkertable.HcmEmployementType == HcmEmploymentType::Contractual //&& !(_hcmworkertable.PERSONNELNUMBER like '*TESTING*') //&& (_hcmworkertable.PERSONNELNUMBER like '2*'); //personnelno = str2int64(_hcmworkertable.PersonnelNumber); //Generatedpersonalnumber = strFmt("%1",int642str(personnelno 1)); //} // //else if (_Userbranch == 'PQF') //{ //select firstfast _hcmworkertable order by _hcmworkertable.PersonnelNumber desc //where _hcmworkertable.HcmEmployementType == HcmEmploymentType::Contractual //&& !(_hcmworkertable.PERSONNELNUMBER like '*TESTING*') && (_hcmworkertable.PERSONNELNUMBER like '1*') //&& !(_hcmworkertable.PERSONNELNUMBER like '*100331_del*'); //personnelno = str2int64(_hcmworkertable.PersonnelNumber); //Generatedpersonalnumber = strFmt("%1",int642str(personnelno 1)); // //} // checking either employee exist or not // } _hcmworkertable = HcmWorker::findByPersonnelNumber(_Generatedpersonalnumber); if (!_hcmworkertable || _hcmworkertable.RecId == 0) { //inserting in hcmworker _hcmworkertable = HcmWorker::find(HcmWorkerTransition::newHireHcmWorker_Customize(CNIC.valueStr(), _employmenttype, dirPersonName, _Generatedpersonalnumber, _hcmpositiontable.RecId, employmentStartDateTime, employmentEndDateTime, employmentStartDateTime,//DateTimeUtil::removeTimeZoneOffset(EmploymentStartDate.dateTimeValue(), DateTimeUtil::getUserPreferredTimeZone()), employmentEndDateTime, companyInfo.RecId )); // ishcmworkertable = true; _hcmWorkerTitletable.clear(); _hcmWorkerTitletable.initValue(); _hcmWorkerTitletable.Worker = HcmWorker::findByPersonnelNumber(_Generatedpersonalnumber).RecId; _hcmWorkerTitletable.Title = _hcmtitletable.RecId; _hcmWorkerTitletable.OfficeLocation = _location; _hcmWorkerTitletable.ValidFrom = employmentStartDateTime; _hcmWorkerTitletable.ValidTo = employmentEndDateTime; _hcmWorkerTitletable.Location = 0; if(_hcmWorkerTitletable.validateWrite()) {_hcmWorkerTitletable.insert();} //updating hcmemployment _hcmemploymenttable.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction); ttsBegin; while select forUpdate _hcmemploymenttable where _hcmemploymenttable.Worker == HcmWorker::findByPersonnelNumber(_Generatedpersonalnumber).RecId && _hcmemploymenttable.EmploymentType == _employmenttype && _hcmemploymenttable.LegalEntity == companyInfo.RecId { if (_hcmemploymenttable.EmploymentType == HcmEmploymentType::Contractual) { _hcmemploymenttable.DefaultDimension = result; _hcmemploymenttable.VendAccount = "V-000001"; _hcmemploymenttable.PaymMode = 'CASH'; _hcmemploymenttable.SLDefaultProfileId = "General"; _hcmemploymenttable.SLMarkAutoAttendance = NoYes::Yes; _hcmemploymenttable.SLExperience = 0; if(_hcmemploymenttable.validateWrite()) {_hcmemploymenttable.Update(); //ishcmemploymenttable = true; } } } ttsCommit; //checking employment detail _hcmemploymentdetailtable = HcmEmploymentDetail::findByWorkerLegalEntity(_hcmworkertable.RecId,companyInfo.RecId); if(_hcmemploymentdetailtable) { _hcmemploymentdetailtable.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction); //Updating employment detail ttsBegin; while select forUpdate _hcmemploymentdetailtable where _hcmemploymentdetailtable.Employment == _hcmworkertable.RecId { _hcmemploymentdetailtable.WorkerStartDate = employmentStartDateTime; _hcmemploymentdetailtable.AdjustedWorkerStartDate = employmentStartDateTime; _hcmemploymentdetailtable.ValidFrom = employmentStartDateTime; //if(_hcmemploymentdetailtable.validateWrite()) //{ _hcmemploymentdetailtable.update(); //ishcmemploymentdetailtable = true; //} } ttsCommit; _hcmemploymenttable = HcmEmployment::findByWorkerLegalEntity(_hcmworkertable.RecId,companyInfo.RecId); _WorkCalendarEmploymenttable = WorkCalendarEmployment::findByEmploymentRecId(_hcmemploymenttable.RecId); } } if(_WorkCalendarEmploymenttable && _hcmemploymenttable.RecId != 0) { ttsBegin; while select forUpdate _WorkCalendarEmploymenttable where _WorkCalendarEmploymenttable.Employment == _hcmemploymenttable.RecId { _WorkCalendarEmploymenttable.CalendarId = "Calendar"; _WorkCalendarEmploymenttable.CalendarDataAreaId = "rni"; if(_WorkCalendarEmploymenttable.validateWrite()) { _WorkCalendarEmploymenttable.doUpdate(); //isWorkCalendarEmploymenttable = true; } } ttsCommit; } if(!_WorkCalendarEmploymenttable && _hcmemploymenttable.RecId != 0) { //inserting calendar _WorkCalendarEmploymenttable.clear(); _WorkCalendarEmploymenttable.initValue(); _WorkCalendarEmploymenttable.CalendarId = "Calendar"; _WorkCalendarEmploymenttable.CalendarDataAreaId = "rni"; _WorkCalendarEmploymenttable.Employment = _hcmemploymenttable.RecId; if(_WorkCalendarEmploymenttable.validateWrite()) { _WorkCalendarEmploymenttable.insert(); // isWorkCalendarEmploymenttable = true; } //checking hcm person private if (_hcmworkertable.Person) {_HcmPersonPrivateDetailstable = HcmPersonPrivateDetails::findByPerson(_hcmworkertable.Person);} } //if (ishcmworkertable == true && ishcmemploymenttable == true && ishcmemploymentdetailtable == true && isWorkCalendarEmploymenttable == true) //{ //_isAllemploymenttable = true; //} if(!_HcmPersonPrivateDetailstable) { if (_hcmworkertable.Person) { //insert hcm person private _HcmPersonPrivateDetailstable.clear(); _HcmPersonPrivateDetailstable.initValue(); _HcmPersonPrivateDetailstable.NativeLanguage = 5637144577; _HcmPersonPrivateDetailstable.BirthDate = _HcmPersonBirthDate; if (_gender == HcmPersonGender::Male) {_HcmPersonPrivateDetailstable.Gender = HcmPersonGender::Male;} if (_gender == HcmPersonGender::Female) {_HcmPersonPrivateDetailstable.Gender = HcmPersonGender::Female;} _HcmPersonPrivateDetailstable.HcmWorker = 0; _HcmPersonPrivateDetailstable.Person = _hcmworkertable.Person; _HcmPersonPrivateDetailstable.CitizenshipCountryRegion = 'PAK'; _HcmPersonPrivateDetailstable.IsFulltimeStudent = NoYes::No; _HcmPersonPrivateDetailstable.SLBloodGroup = SLBloodGroup::Blank; if(_HcmPersonPrivateDetailstable.validateWrite()) { _HcmPersonPrivateDetailstable.insert(); // isHcmPersonPrivateDetailstable = true; } } } _dirPersonRecid = HcmWorker::findByPersonnelNumber(_Generatedpersonalnumber).Person; _roles = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Home).RecId]; //create address _DirParty = DirParty::constructFromPartyRecId(_dirPersonRecid); if(Address.valueStr() != '') { _addressView.CountryRegionId = LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId; _addressView.Street = Address.valueStr(); _addressView.City = 'Karachi'; _addressView.IsPrimary = NoYes::Yes; _addressView.IsPrivate = NoYes::Yes; _addressView.Party = _dirPersonRecid; _addressView.Address = Address.valueStr(); _DirParty.createOrUpdatePostalAddress(_addressView,_roles); // isaddressView = true; } if(Contact.valueStr() != '') { _contactView.clear(); _contactView.LocationName = 'Phone'; _contactView.Locator = Contact.valueStr(); _contactView.Type = LogisticsElectronicAddressMethodType::Phone; _contactView.Party = _dirPersonRecid; _contactView.IsPrimary = NoYes::Yes; _dirParty.createOrUpdateContactInfo(_contactView); } _hcmpersondetails = HcmPersonDetails::findByPerson(_hcmworkertable.Person); if(!_hcmpersondetails) { //insert into hcmpersondetail _hcmpersondetails.clear(); _hcmpersondetails.initValue(); _hcmpersondetails.DisabledVeteran = NoYes::No; _hcmpersondetails.ValidFrom = EmploymentStartDate.dateTimeValue(); _hcmpersondetails.ValidTo = employmentEndDateTime; _hcmpersondetails.Person = _hcmworkertable.Person; _hcmpersondetails.VeteranStatus = 0; _hcmpersondetails.IsExpatriateRulingApplicable = NoYes::No; _hcmpersondetails.MaritalStatus = HcmPersonMaritalStatus::None; _hcmpersondetails.NumberOfDependents = 0; _hcmpersondetails.SLSpecialty = ""; if(_hcmpersondetails.validateWrite()) { _hcmpersondetails.insert(); // ishcmpersondetails = true; } } // //if (isHcmPersonPrivateDetailstable == true && isaddressView == true && ishcmpersondetails == true) //{ //_isdetailtables = true; //} //if (_isdetailtables == true) //{ _PayrollWorkerPositionEarningCode.clear(); _PayrollWorkerPositionEarningCode.initValue(); if (PayrollEarningCode::findByEarningCode('Late/Leave Deductions').QuantityUnit == PayrollQuantityUnit::Each) { _PayrollWorkerPositionEarningCode.CalculationFrequency = PayrollCalculationFrequency::findDefaultCalculationFrequency().RecId; } else { _PayrollWorkerPositionEarningCode.CalculationFrequency = 0; } _PayrollWorkerPositionEarningCode.CalculationFrequency = PayrollCalculationFrequency::findDefaultCalculationFrequency().RecId; _PayrollWorkerPositionEarningCode.Formula = 1.00; _PayrollWorkerPositionEarningCode.EarningCode = 5637145375; _PayrollWorkerPositionEarningCode.Position = _hcmpositiontable.RecId; _PayrollWorkerPositionEarningCode.ValidFrom = DateTimeUtil::date(EmploymentStartDate.dateTimeValue()); _PayrollWorkerPositionEarningCode.ValidTo = DateTimeUtil::date(employmentEndDateTime); _PayrollWorkerPositionEarningCode.Worker = _hcmworkertable.RecId; _PayrollWorkerPositionEarningCode.EmploymentType = _hcmworkertable.HcmEmployementType; if(_PayrollWorkerPositionEarningCode.validateWrite()) { _PayrollWorkerPositionEarningCode.insert(); // isPayrollWorkerPositionEarningCode =true; } // } _HRMCompFixedEmpl = HRMCompFixedEmpl::findByWorker(_hcmworkertable.RecId); //if (isPayrollWorkerPositionEarningCode == true) //{ if(!_HRMCompFixedEmpl) { hrmCompFixedEmplActionHire = new HRMCompFixedEmplActionHire(); _HRMCompFixedEmpl.clear(); _HRMCompFixedEmpl.initValue(); _HRMCompFixedEmpl.PlanId = NewPlanId; _HRMCompFixedEmpl.Worker = _hcmworkertable.RecId; _HRMCompFixedEmpl.Status = HRMCompFixedEmplStatus::Active; hrmCompFixedPlanTable = HRMCompFixedPlanTable::find(NewPlanId); _HRMCompFixedEmpl.Type = hrmCompFixedPlanTable.Type; _HRMCompFixedEmpl.CurrencyCode = hrmCompFixedPlanTable.CurrencyCode; _HRMCompFixedEmpl.PayFrequencyId = hrmCompFixedPlanTable.PayFrequencyId; _HRMCompFixedEmpl.ActionId = NewActionId; _HRMCompFixedEmpl.Position = _hcmpositiontable.RecId; _HRMCompFixedEmpl.ValidFrom = DateTimeUtil::date(EmploymentStartDate.dateTimeValue()); _HRMCompFixedEmpl.ValidTo = DateTimeUtil::date(employmentEndDateTime); _HRMCompFixedEmpl.PayRate = Salary.value() Mobileallowance.value() maintainanceallowance.value(); _HRMCompFixedEmpl.GrossPayRate = Salary.value() Mobileallowance.value() maintainanceallowance.value(); _HRMCompFixedEmpl.ProcessType = HRMCompProcessType::NonCyclical; _HRMCompFixedEmpl.DefaultDimension = result; //insert if(_HRMCompFixedEmpl.validateWrite()) { _HRMCompFixedEmpl.Insert(); // isHRMCompFixedEmpl = true; } HRMCompFixedEmplActionHire.parmHrmCompFixedEmpl(_HRMCompFixedEmpl); HRMCompFixedEmplActionHire.parmActionType(HRMCompFixedActionType::HireRehire); HRMCompFixedEmplActionHire.run(); if(_HRMCompFixedEmpl) { Box::info('Employee has been created'); element.refreshempcode();} } }// hcm title condition end } } } }