🔌 API

FAQ not to work

👤 kklo
Q
Question
Hi,

Can someone tell me if it's normal for the FAQ not to work?

Is it a bug?

Another problem I have is that the Responsible Person's name doesn't appear, only 19x1, just like the Contact appears as 12x890. Is this a bug or a Portal configuration issue? The rest works fine.

I'm using vTiger and Customer Portal version 8.4.0

Thanks
kklo
A
Community Solution
✓ Answered
It’s not an FAQ issue, (it's already doesn't appear in old versions) , For the portal, please use this workaround: The issue only for vTiger CRM 8.4.0. The Customer Portal is unable to retrieve user names through the API and instead displays record IDs such as 19x1.

As a workaround, add the following code to:

modules/CustomerPortal/apis/FetchRecord.php

This modification resolves the assigned user ID and displays the corresponding user or group name in the Customer Portal instead of the internal CRM ID.

if ($current_user) {
$record = $this->processRetrieve($request);
$record = CustomerPortal_Utils::resolveRecordValues($record);

// --- START: TRANSLATE ASSIGNED USER ID FOR PORTAL ---
global $adb;
if (!empty($record['assigned_user_id'])) {
$ownerField = $record['assigned_user_id'];
$userId = '';

// Extract ID safely
if (is_array($ownerField) && !empty($ownerField['value'])) {
$userId = $ownerField['value'];
} elseif (is_string($ownerField)) {
$userId = $ownerField;
}

if (!empty($userId) && strpos($userId, 'x') !== false) {
$parts = explode('x', $userId);
$realDbId = end($parts);

$ownerName = '';

// Check if it is a User
$userRes = $adb->pquery(
"SELECT first_name, last_name FROM vtiger_users WHERE id = ?",
array($realDbId)
);

if ($adb->num_rows($userRes) > 0) {
$firstName = $adb->query_result($userRes, 0, 'first_name');
$lastName = $adb->query_result($userRes, 0, 'last_name');
$ownerName = trim($firstName . ' ' . $lastName);
} else {
// Check if it is a Group
$groupRes = $adb->pquery(
"SELECT groupname FROM vtiger_groups WHERE groupid = ?",
array($realDbId)
);

if ($adb->num_rows($groupRes) > 0) {
$ownerName = $adb->query_result($groupRes, 0, 'groupname');
}
}

if (!empty($ownerName)) {
$record['assigned_user_id'] = array(
'value' => $userId,
'label' => html_entity_decode($ownerName, ENT_QUOTES, 'UTF-8')
);
}
}
}
// --- END: TRANSLATE ASSIGNED USER ID FOR PORTAL ---

$response->setResult(array('record' => $record));
}
← Back to API Join to answer →