1

I have a visualforce page that will be accessed via a List Button. This VF page relates to the case object and the list button will appear on several object UIs (opportunity, account etc) related lists.

Using the "Execute Javascript" option I wish to open the visualforce page using a location.replace function but I wish to add the record Id and the sObjectType/API Name in URL parameters from the parent/source that the related list was clicked on.

I know how to get the record Id in the parameter but is there a global variable or a method i can use to include the sObjectName/API Name as a parameter?

For example, the location.replace url will look like:

/apex/vfPage?parentId={!Id}&sObjectName={SOBJECTVARIABLE}

From my understanding if I use a VF page redirect using a standard controller I will receive the parent Id but not the sObject name.

Does anybody know how I can achieve this?

3

The $ObjectType global variable lets you merge in the type of SobjectType. You can specify things like the API name, label, and so on. Besides that, though, you can always get the SobjectType directly from an ID in Apex Code, so you might not even need that. Simply using Id.getSObjectType will give you an SObjectType token that you can use to determine which object an Id belongs to.

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.