Wix Location .to an internal anchor, on dynamic members profile page

Hi guys/ girls im having trouble navigating from users static members area pages to the users dynamic profile pages via code, i want it to link and scroll to an anchor on another dynamic page with a url query but everything Ive tried it just doesn’t work, heres some screenshots and code Ive made, thanks in advance

//this is the page code I’m navigating away from..
 
export function button7_click(event,$w) {

const currentItem = $w("#dataset5").getCurrentItem(_id);
wixLocation.to(`/Updatedmemberprofile/${currentItem}?a=1`);  }

//this is the page code i want to navigate to with the anchor on..
export function page1_viewportEnter(event) 

{let query = wixLocation.query;
if(query.a === '1'){
$w("#anchor1").scrollTo()
.then( ( ) => {
console.log("Done with scroll");
})}
}

Please remember to specify where the error is and more precisely what you have already tried to perform.
If i understand correctly its the part of scrollTo() that is never run,
I am unsure why your using the

export function page1_viewportEnter(event)

to run the code, unsure writing this if it would even be called.
but also remember console.log is your friend. Believe if you run following

console.log(wixLocation.query.a); 

I think either its not called at all (as viewportEnter is not called) or its called but its not ‘1’

Best of luck.

Hi Claes thanks, the problem isn’t the viewport enter or not being = to ‘1’
i don’t know the correct page to navigate to here highlighted in red where it says _id within my db half of the field key id link- is greyed out because its too long like in the last image above

thanks

export function button7_click(event,$w) {

const currentItem = $w("#dataset5").getCurrentItem(_id);
wixLocation.to(`/Updatedmemberprofile/${currentItem}?a=1`);  }

@millwards322
Have a look at this previous forum post about the same thing.
https://www.wix.com/corvid/forum/community-discussion/wix-location-to-an-internal-anchor-dynamic-pages

@givemeawhisky Ive already seen this bud Ive even commented on it at the bottom lol

@millwards322
Lol okay, I didn’t look at bottom of the post itself, I just recalled Doron having replied to something like this before and so looked for the previous post about it.

Anyways, going by your pics attached, it looks like you have used the Wix Members Profile tutorial as shown here.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

In response to the question above about wanting to know the _id field key part as it is not fully shown.

Well I have used the same tutorial on a site of mine and have just used Members as my field name so here is what it should be fully - link-Members-_id as shown in the picture below. (Obviously you will need to change the Members part of it.

However, you can just double click on your partially hidden field key name and just select it all with keyboard shortcut and then also just simply copy it using keyboard shortcut again. I have tried it myself on my Members Update field and it gives me the full field key link-Members-Update-_id

The thing that gets me is that you have in your pic here…


… that you have the MemberProfile Update (ID) page and yet however you have three pages called MemberProfile (ID), when in theory you should only have the one for the tutorial to work.

If you are wanting to have other member pages within your MemberProfile Pages (Dynamic) section, then they should all be called different names and not have the same name url.

So can you clarify that these are not all the same name and url for these three MemberProfile (ID) pages in this section.

Also, looking at this pic here…


… I can see that some of the rows in this dataset are empty and don’t contain any data in them.
So just note that it might not work correctly if you have no data in the users row, although if you have that MemberProfile (ID) field with data in it already then it should work as that row would contain data!

There is an old forum post in which Mikhail (Wix Mod) replies to a similar post and gives a reply about empty datasets and links not working, however he is replying to a user who is trying to link through the Wix Editor’s own page link settings and not through code itself, however towards the end of the post Mikhail does mention that it would be better to use the scrollTo code.
https://www.wix.com/corvid/forum/community-discussion/linking-up-anchors-in-a-dynamic-page

Also, did J. D. not give you a fully working code example to do this in a previous post of yours?
https://www.wix.com/corvid/forum/community-discussion/help-with-linking-to-a-dynamic-pages-anchor

@givemeawhisky hi thanks for pointing these things out to me above, i since deleted all the blank fields in my db now so i’m just left with fields that contain data and it still doesn’t work, i re tried the code above J.D made for me to and it goes straight to a 404 page, i’m guessing its because of this code highlighted in red, its grabbing the id from the private members db, which is different to the one i need within my MembersProfile db where the link is greyed out, thats why its 404ing

export function button7_click(event) {
let pagePath= `Updatedmemberprofile/${wixUsers.currentUser.id}`;//use your own destinatio npath
let anchorPropertyId = 'anchor1';//use the anchor id
wixLocation.to(`/${pagePath}#${anchorPropertyId}`);
}