© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

Local Integration - Unusual Behaviour with Edit Employee 12/4

We have recently come across issues when updating staff using:  

 SIMS.Processes.EditEmployee emp = new SIMS.Processes.EditEmployee();
           

Error when saving an identical record

It is always possible that required changes are made to staff both within SIMS and outside of SIMS before an external system tries to update SIMS.  For example staff member changes their preferred name from Andrew to Andy.  If this is done in both systems and the external system tries to update SIMS then an error of:

"There are no changes to save."

Could be returned along with a 'false' or failed to save.  Some external systems will then repeatedly try to update the staff member on each call up and this will continue to fail until an 'effective' change occurs.

In this case TI code may need to check the error messages, for example:

bool ActuallyFailed = false;
if (!emp.Save(DateTime.Now))
{
  foreach (SIMS.Entities.ValidationError v in emp.Employee.ValidationErrors)
  if (v.Message == "There are no changes to save.") 
  {
     break;
  }
  else
  {
    ActuallyFailed = true;
    Console.Writeline(v.Message);
  }
}

 

Validation

We have also had reports about the lack of validation on the save call which is ironic with regard to the above.  As a minimum validation, we would recommend the following as minimum validation for employees. This was largely derived from the UI and may have missed edge cases.

        public bool IsValid()
        {
            bool rc =
                !string.IsNullOrEmpty(Surname) &&
                !string.IsNullOrEmpty(FirstName) &&
                !string.IsNullOrEmpty(PreferredSurname) &&
                !string.IsNullOrEmpty(PreferredFirstName) &&
                !string.IsNullOrEmpty(Gender) &&
                //!string.IsNullOrEmpty(PayrollNumber) &&
                !string.IsNullOrEmpty(NINumber) &&
                DateOfBirth != null &&
                EmploymentStartDate != null &&
                DateOfBirth.AddYears(13) <= EmploymentStartDate; // Must be 13 to work
            if (rc && ContinuousServiceStart != null)
           {
                if (ContinuousServiceStart > EmploymentStartDate)
                {
                    rc = false;
                }
            }
            return rc;
        }