Show Sales Rep name in Aged Accounts Receivable

I want to show Sales rep name.

I added Salesperson/Purchaser table to customer table and linked by salespersoncode.

It shows the sales person name, but it print the blank aged accounts.

How can I eliminate the blank ones.



It sounds as though you have added Salesperson/Purchaser as a dataitem above the Customer table and linked them that way. You don’t really need to go to this trouble if all you want to do is pull a field from a related table.

You could create a Global Variable to store the Salesperson name and assign this in the OnAfterGetRecord trigger for the Customer table. You will need a local variable in that trigger for the Salesperson/Purchaser table. Then do a IF l_Salesperson.GET(Customer.“Salesperson”) THEN; followed by a g_SalespersonName := l_Salesperson.Name. I didn’t look up any of these table names or field names but hopefully you get the idea of what I am talking about.

If you really want to use the data items as you have done, you can use the PrintOnlyIfDetail property on the Salesperson/Purchaser dataitem. This will tell NAV to only print this section if the child items have data.



Thank you Dave.

But I need more information.

My Steps:

1: create a global variable salespersom

2: OnAfterGetRecord trigger of customer table

IF (customer.salespersoncode= Salesperson/Purchasor.code) Then

salesperson = Salesperson/

Are these steps write?



Hi Dave

I created variable salesperson text (30) and another variable SalespersonPurchaser as record and assigned the table Salesperson/Purchaser.

IF " Salesperson code" <> ’ ’ Then

salesperson =


When I print salesperson, it is not giving any data.

Where is my mistake.



It is not reading from SalesperonPurchaser table.



Hi Barathy,

I’m not clear how you have constructed the report. Here’s the code to find the name.

Declare a variable SalespersonRec

in the OnAfterGetRecord of the customer add

if not SalesPersonRec.get( Customer.“Salesperson Code” ) then


This will populate for customers who have (valid) salespeople

You can then print SalesPersonRec.Name

Hi Dave

I added the code as you said.

Now I get this error message.

You have specified an unknown variable.

define the variable under global C/AL symbols.


The unknown variable would be the Customer as in SalesPersonRec.get( Customer.“Salesperson Code” )

This should likely have read direct from the ‘Cust. Ledger Entry’:

IF NOT SalesPersonRec.get("Salesperson Code") then

//Or to save transaction calls to the server
IF "Salesperson Code" <> SalesPersonRec.Code THEN
IF NOT SalesPersonRec.get("Salesperson Code") then

The code supplied by Dave would be pseudo-code and un-validated which is meant as an example for you to work with, not always a full solution, it really should have been enough for you to have worked this out.


Thank you Dave and David.

It worked.
I can print the sales person’s name now. Thank you so much.

You’re welcome from the 3 Davids/Daves [:D]