Personalizing a function to generate an internal notification
Pionier AI turns an existing SQL function into a clear HTML internal notice, with a table and operational recommendations for vehicle documents.
- HTML + table
- structured internal notice
- vehicle documents
- expired or near expiration
- custom function
- from existing SQL
While using the Nexus ERP platform, an existing function had to be personalized for the automatic generation of an internal notification regarding the expiration of documents associated with vehicles. The purpose of the request was to transform an initial function into a clearer, structured, and easier-to-use version that highlights the essential information for users in HTML format.
The function identifies documents related to active vehicles that have expired or are about to expire in the following period, excluding documents of the inspection type. The result is intended to send an internal notification to the people responsible for managing vehicle documents.
Request sent to Pionier AI
Starting from the initial version I sent, highlight the essential points in the email, and where appropriate introduce tables and HTML formatting.

INSERT INTO @ret_table ([text], al_tabel, pl_tabel, id_tabel, nume_tabel)
SELECT
'Informare :' +
CHAR(13) + CHAR(10) +
STRING_AGG(a.[text], CHAR(13) + CHAR(10)),
'',
MAX(a.pct_lcr),
MAX(a.id),
'm_transport'
FROM
(
SELECT DISTINCT
[text] =
CASE
WHEN ziledif > 0 THEN
'- ' + dbo.trim(l.tip) +
' - în următoarele ' +
LTRIM(STR(ziledif)) + ' zile expiră'
WHEN ziledif < 0 THEN
'- ' + dbo.trim(l.tip) +
' - a expirat deja de ' +
LTRIM(STR(ABS(ziledif))) + ' zile'
ELSE
'- ' + dbo.trim(l.tip) +
' - expiră astăzi'
END
+ ', la data de: ' + dbo.dtoc(l.data_av),
a.pct_lcr,
a.id
FROM m_transport_view a
INNER JOIN
(
SELECT
tip,
pl_mas,
id_mas,
MAX(data_urm) AS data_av,
DATEDIFF(DAY, GETDATE(), MAX(data_urm)) AS ziledif
FROM m_operatii_periodice
WHERE tip NOT LIKE '%REVIZIE%'
AND data_urm IS NOT NULL
GROUP BY tip, pl_mas, id_mas
) l
ON a.pct_lcr = l.pl_mas
AND a.id = l.id_mas
WHERE a.status = 'Activ'
AND ziledif < 15
) aResponse generated by Pionier AI
Pionier AI generated a personalized version of the function, using HTML formatting to structure the message content. The result includes a title, description, warning area, a table with vehicle documents, status highlighting, and an operational recommendation.
INSERT INTO @ret_table
(
[text], al_tabel, pl_tabel, id_tabel, nume_tabel
)
SELECT
CONCAT(
N'<html>
<body style="font-family: Arial, sans-serif; font-size: 14px; color: #333333; line-height: 1.5;">
<div style="max-width: 820px; margin: 0 auto; border: 1px solid #dddddd; border-radius: 8px; overflow: hidden;">
<div style="background-color: #1f4e79; color: #ffffff; padding: 18px 24px;">
<h2 style="margin: 0; font-size: 20px;">Informare internă - expirare documente autovehicule</h2>
<p style="margin: 4px 0 0 0;">Monitorizare documente flotă</p>
</div>
<div style="padding: 24px;">
<p>
Au fost identificate documente aferente autovehiculelor active care sunt expirate
sau urmează să expire în perioada următoare.
</p>
<div style="background-color: #fff4e5; border-left: 4px solid #f0ad4e; padding: 14px 16px; margin: 20px 0;">
<strong>Acțiune necesară:</strong><br>
Vă rugăm să verificați documentele de mai jos și să inițiați demersurile necesare pentru reînnoire.
</div>
<h3 style="margin-top: 24px; color: #1f4e79;">Documente autovehicule</h3>
<table style="width: 100%; border-collapse: collapse; margin: 12px 0 20px 0;">
<tr>
<th style="border: 1px solid #dddddd; padding: 10px; background-color: #f5f7fa; text-align: left;">Nr. circulație</th>
<th style="border: 1px solid #dddddd; padding: 10px; background-color: #f5f7fa; text-align: left;">Document</th>
<th style="border: 1px solid #dddddd; padding: 10px; background-color: #fff4e5; text-align: left;">Status</th>
<th style="border: 1px solid #dddddd; padding: 10px; background-color: #f5f7fa; text-align: center;">Data expirării</th>
</tr>',
STRING_AGG(
CONCAT(
N'<tr>
<td style="border: 1px solid #dddddd; padding: 10px;"><strong>', dbo.trim(a.nr_circ), N'</strong></td>
<td style="border: 1px solid #dddddd; padding: 10px;">', dbo.trim(l.tip), N'</td>
<td style="border: 1px solid #dddddd; padding: 10px;',
CASE
WHEN l.ziledif < 0 THEN N' color: #b00020;'
WHEN l.ziledif = 0 THEN N' color: #b00020;'
ELSE N' color: #1f4e79;'
END,
N'"><strong>',
CASE
WHEN l.ziledif > 0 THEN N'Expiră în ' + LTRIM(STR(l.ziledif)) + N' zile'
WHEN l.ziledif < 0 THEN N'Expirat de ' + LTRIM(STR(ABS(l.ziledif))) + N' zile'
ELSE N'Expiră astăzi'
END,
N'</strong></td>
<td style="border: 1px solid #dddddd; padding: 10px; text-align: center;">', dbo.dtoc(l.data_av), N'</td>
</tr>'
),
N''
),
N'
</table>
<div style="background-color: #eaf3fb; border-left: 4px solid #1f4e79; padding: 14px 16px; margin: 20px 0;">
<strong>Recomandare:</strong><br>
Documentele expirate sau aflate aproape de expirare trebuie verificate cu prioritate pentru evitarea blocajelor operaționale.
</div>
</div>
<div style="background-color: #f5f5f5; padding: 14px 24px; font-size: 12px; color: #666666;">
Informare internă generată automat de sistemul Nexus ERP.<br>
Mesaj destinat persoanelor responsabile de administrarea documentelor autovehiculelor.
</div>
</div>
</body>
</html>'
),
'',
MAX(a.pct_lcr),
MAX(a.id),
'm_transport'
FROM m_transport_view a
INNER JOIN
(
SELECT
tip,
pl_mas,
id_mas,
MAX(data_urm) AS data_av,
DATEDIFF(DAY, GETDATE(), MAX(data_urm)) AS ziledif
FROM m_operatii_periodice
WHERE tip NOT LIKE '%REVIZIE%'
AND data_urm IS NOT NULL
GROUP BY tip, pl_mas, id_mas
) l
ON a.pct_lcr = l.pl_mas
AND a.id = l.id_mas
WHERE a.status = 'Activ'
AND l.ziledif < 15;Result of applying the function
Applying the personalized function led to the generation of a structured internal notification with an improved visual appearance. The message highlights vehicle documents that have expired or are about to expire, presenting the information in a clear table with document status and expiration date.

Result analysis
This case study highlights Pionier AI's ability to support not only search or information-identification activities, but also technical personalization processes. Through the request, the user obtained an improved version of the initial function, with the information reorganized into a clearer and easier-to-interpret format.
Functionally, Pionier AI helped transform a technical result into an operational message suitable for internal communication. The use of HTML elements, tables, and visual markers makes it easier to quickly understand situations that require intervention. As a result, the information is no longer presented only as raw text, but in a structured, action-oriented form.
Identified benefits
The main benefits observed in this case are increased readability of the generated notification, automatic highlighting of situations that require attention, reduced time needed for manual message drafting, and improved internal communication. Pionier AI also made it possible to obtain a personalized solution starting from an existing function, without fully rewriting the initial logic.
Conclusions
The results show that formulating requests in natural language leads to more complete and useful answers for the user's activity. While keyword-based queries allow quick identification of functionality, clearly and contextually written questions help generate detailed explanations and recommendations that can be applied in current work. This case study demonstrates the importance of using natural language when interacting with Pionier AI and supports one of the main recommendations presented in the best-practices guide.
