How to create employees using the API?
The Human Resources module of PRIMAVERA ERP includes several features that allow you to manage your organization's human resources processes with greater speed and efficiency, such as salary processing, integration with social security or payment and receipts management. In this article we will explore the V10 API using the example of creating an employee. This will enable your organization to create or update employee data through external applications. Among all the options available in the module, the main Human Resources entity is the employee table, where you can access employee files. This table is used in many of the existing processes and includes the configurations used in most of the module. Note: For this demonstration, we use the project available in GitHub. Step 1 - Add the reference to the Human Resources module Create a project in Visual Studio and add the references to the Human Resources API: Step 2 - Use the "RhpBE100" namespace To make it easier to read the code, add the API's HR namespace. Step 3 - Create the employee object with the required information Use the method for creating the "employee" object and define the required fields. Step 4 - Check if it is a new record Use the 'EmModoEdicao' property to define the type of record to be made. If this value is "true", the employee table will receive an "Update", otherwise the operation will be an "Insert". To fill this property, use the employee code entered in "txtID.Text" to validate through the Human Resources API if the employee already exists. Step 5 - Register the employee Use the "Actualiza" method to make changes to the database and create/update the employee, according to the value defined in the "EmModoEdicao" property.Employee Files
Example of creating an employee:
using RhpBE100;
RhpBEFuncionario employee = new RhpBEFuncionario
{
Funcionario = txtID.Text,
Nome = txtName.Text,
DataAdmissao = dtHireDate.Value,
Situacao = txtSituation.Text,
Instrumento = txtWorkPolicy.Text,
Estabelecimento = txtWorkLocation.Text,
SegurancaSocial = txtSocialSec.Text,
};
Employee.EmModoEdicao = PriEngine.Engine.RecursosHumanos.Funcionarios.Existe(txtID.Text)
PriEngine.Engine.RecursosHumanos.Funcionarios.Actualiza(employee);
login para deixar a sua opinião.