Members$PublicData_afterUpdate

Greetings,

I have a data collection named ‘Resume’ which includes a photo field and a reference field associated with Members/PublicData. My objective is to automatically update the member’s profile photo, located in Members/PublicData, to the Resume collection whenever the member uploads or updates it.

To accomplish this, I have created an after update hook on the PublicData collection. However, this implementation is not functioning as intended.

I would appreciate any guidance or advice you can provide on this matter.

Thank you.

import wixData from 'wix-data';

export function Members$PublicData_afterUpdate(item, context) {
    const memberId = item._id;
    return wixData.query("Resume")
    .eq("member", memberId)
    .find()
    .then(() => {
        wixData.update("Resume", {photo: item.profilePhoto.url})
    })
}
1 Like

In fact I do the contary and I just found the solution.

When your read the url from a dataset, you don’t obtain a real url but an internal wix link (starting with : “wix:image://v1/”) and you need to transform this value before loading it (replace by “https://static.wixstatic.com/media/”).

you could use : Url = urlReadInYourDataset.split(‘#’)[0].replace(“wix:image://v1/”, “https://static.wixstatic.com/media/”);

In my case wix add some other informations at the end that we need to clean (not the same depending of how I obtain the original file by contact form or data entry)

regards