Copying Image from Lead to Account

I have one custom field (Image) in Lead.

I have tried to copy this image field to Account by giving same field name.

I can copy data and the issue is not able to show as Image in Detail View.

When I edit this record, I can the value of Image field.

Any idea to show image in Detail View.

Hi @nwt,

Welcome to the community! :tada:
Have you added the field to the detail view via studio? If not this is the best way to start.

Hi @Mac-Rae

Thank you for your reply.

I have added and it only show blank image (traced from Chrome console)

But when edit the record, I can see image value.

Are there any errors in the browser console ? (Hit F12 and press on console tab).

Hi @Mac-Rae

Yes there was errors at console.

Number of errors 3806+++ is keep on increasing in console.

Thank you.

What version are you currently on?

Can you give us a little more explanation on the scenario?

You have a custom field in Lead (image field)
When you convert that lead then you expect it to carry over the image field value to the Account yeah?

Do you have any custom code doing this or is this just utilising the same field/same field transfer that Suite has OTB?

Hi @samus-aran

My version is Version 7.11.7

Yes. You are right. I just use same field name to transfer data.

This was only added recently:

Is that code already in your version?

EDIT: Are you using the standard field name, photo? You need to stick to that name and core field, otherwise it won’t work. If you want to use a custom field you would have to add your own custom code to handle it.

1 Like

Hi @pgr

Thanks for your info and my version already have this code.

I am using custom field name and want to copy from Lead to Account.

Either change to use the default field (I recommend this) or stick to your field and add an after_save logic hook that replicates the code in that PR to copy the photo file.

I know that it’s an old topic, but I still got this issue.

Got the exact same name of Image field in lead and account : rib_c

After conversion, the file isn’t here, in fact in the upload folder I can see the file with the OLD id of the fresh converted lead. So this ID isn’t in the database anymore cause the lead have been converted.

If I rename the file with the new account created, everything work fine. So we just need to rename the file with the new ID. Its on my todo list, I think I can do this in view.convertlead.php or a file like that.

And I have like @nwt, the name of the file in the editview, if I download it I got the “No-Image.png”, cause he cant find any image related.

So what would be desired generic behaviour? During conversion, check each and every field to see if it is “picture” type (or whatever that is called, I didn’t check), and copy the file if it is?

what if somebody doesn’t want some fields copied? What is desirable for one person’s conversion, might not be desirable for the other…

And I wonder if from modules/Leads/views/view.convertlead.php there is any quick, practical way to get the field type… I can’t check now, haven’t looked at this code for years…

For me, It was generic, like if you have a custom text field in lead with the same name in account, it will copy it automatically, so if you have an image field with the same name in both lead and account it should do it too…

I mean if it do this with text field why not image field too ahah.

we ran into the same issue and expected the behaviour holdusback described.

I copied the modules/Leads/viewsview.convertlead.php to custom/modules/Leads/viewsviewsview.convertlead.php and adapted the code proposed in Github Issue 7456. It might not be the perfect solution for everyone, but it does the trick for now:

            foreach ($bean->field_defs as $field => $def) {
                if (!isset($_REQUEST[$module . $field]) && isset($lead->$field) && $bean->field_name_map[$field]['type'] == 'image') {
                    // modified to handle all images and not only photo, handle copying image file, if present:
                    if (!empty($lead->$field) && !empty($bean->$field)) {
                        $bCopied = false;
                        if (($lead->$field === $bean->$field) && is_readable('upload/' . $lead->id . '_' . $field)) {
                            $bCopied = copy(
                                'upload/' . $lead->id . '_' . $field,
                                'upload/' . $bean->id . '_' . $field
                        if ($bCopied) {
                            $bean->$field = $lead->$field;
                        } else {
                            LoggerManager::getLogger()->warning('Lead conversion: failed copying upload/' . $lead->id . '_' . $field . ' to upload/' . $bean->id . '_' . $field);
1 Like