3

I am trying to use the new visualForce remote objects to get information about the current user. I have

usr.retrieve({ where: { UserID: { eq: '' } }, limit: 1 },

The problem is that I do not know how to dynamically get the userId in VF remote objects. Has anyone figured out how to do this?

4

Since you're in Visualforce context, it should suffice to say:

eq: '{!$User.Id}'

Which will be merged in by the Visualforce engine at runtime. Note that if your script is instead located in an include file, you'll need to have that value available before that script can run:

// This script should appear anywhere in the document, before the page finishes loading
window.$userId = "{!$User.Id}";

// In your script:
eq: window.$userId

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.