Custom Field Type Record ID Smarty cache Issue

I have a custom field type to show images. The path for the field is custom/include/SugarFields/Fields/MyImages/
Here i have the files. EditView.tpl, DetailView.tpl and MyImages.php I have also added the field type to the Dynamic Fields and Admin folder and it is working fine. The issue is that i need Each Accessed record ID in the detailview.tpl of the field so what i did in the MyImage.php file is


function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex, $searchView = false)
    {
        $displayParams['bean_id'] = 'id';
        $record = $_REQUEST['record'];
        $module = $_REQUEST['module'];

        $this->ss->assign('MODULE', $module);
        $this->ss->assign('RECORD', $record);

        $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
        return $this->fetch($this->findTemplate('DetailView'));
    }

And in DetailView.tpl of the field, i use the variable as {$RECORD} But when i do Repair/Rebuild and access records of the Module where i have added this custom field, i See that Only One record value shows correct and that the Smarty has actually translated the {$RECORD} into the record that i first access after RR. Looking at the smarty translated template in cache/smarty/templates_c/[some_code]DetailView.tpl i see that the {$RECORD} variabel translates to

<?php echo $this->_tpl_vars['RECORD']; ?>

How can the variable be set so that it displays the Record ID ?

I am on SuiteCRM 7.10.4 Bitnami Stack
Ubuntu 16.04.4 LTS
PHP 7.0.29