Variable for Employee Code

Does anyone know what is the variable for the employee code? We are trying to show the employee code on the payslip. I know it is possible to do that using a custom field, but that would mean duplication of work since we have already inputted all of our employees along with their codes under the Employees module.

We tried to use {{ recipient.code }} on a Payslip form in order to return the employee code used on the Employee form, but it returns an empty string. Is there another reference that can be used to return the code tied to the specific employee for which the payroll slip is being issued, without having to create a custom field? As we are trying to minimize duplication/repetition of entires.

You could include the Code in the Employee’s Name or Address field but this is a bit clumsy.

I used this {{ employee.custom_fields.TaxType}} in the form defaults payslip and it worked .But then I wanted it up the top so I changed to Theams and put it this way

{{ recipient.name }}
{{ recipient.address | newline_to_br }}
{{ recipient.identifier }}
{{ "TaxType".Label.text = "Tax Type" }}
{{ custom_fields["TaxType"] }}

@Joe91 Thanks for the suggestion, but as you said it gets a bit “clumsy”, it was one way to solve the issue though. Appreciated.

@Wornout: Thank you for the elaborate response. This fixed our issue, with a bit of tweaking. Much appreciated.

@ Anaguib I think the “Code” is actually a custom field so try Code as a custom field
{{ employee.custom_fields.Code}}

It is not a custom field. It is built in.

Yeah, I was referring to the built in variable/reference. Thing is, our accountants want to show the employee code on the payslip and the expense claim, for traceability. We created a custom field under employees called “Employee Number” and we were able to call that value in the payslip, but it is not working for the expense claim. Hence, my original question was about the built in variable for the employee code entered when adding a new employee.

@ anaguib Are you talking about the key cod which is a whole bunch of numbers. Patch taught us how to get that.
step 1 open the employee form in edit view
step 2 Right click on the blue word employees and open open in a new window
Step 3 in the address bar you should have something that looks like this the number maybe diffrent like this
http://localhost:58241/employees?Skip=0&Take=50&
straight after the employees put.json and hit enter then figure out which is the key code you want.
the finished address should look like this
http://localhost:58241/employees.json?Skip=0&Take=50

That is because you are calling employees as expense claim payers when you choose them for expense claims, not directly as employees. And custom fields cannot be applied on either expense claims payers or on expense claims themselves.

One alternative is to include the employee number in the summary-level Description field on expense claims.

Another, as @Joe91 suggested, is to put it in the employee name field. Despite what he thinks, I don’t find that clumsy. If you think about it, where would you ever have a use for the employee’s name that the number would not be appropriate, too?

1 Like