Original question here.

Right now, there is NO record being returned with :

this.enroll = (Enroled_Contact__c)stdController.getRecord();

as a result, parentId is empty.

How do I get the parent's record ID when I'm making a new record from the parent record's related list view?

I have a custom button that will call a VF page. The controller will check if there is a parent ID, if not, it will throw error, else it will take user to a different page.

It should be possible by passing params via Javascript but with this code :


window.open("/apex/NewEnroledContactError?id={!Enrolment__c.Id}", "toolbar=no, menubar=no", "_self");

it opens a new window (should display in same tab, no change of focus).

HOWEVER, I'm running into many problems.

I'm getting TWO logs for every time I click on the button, instead of one. In the first log, it correctly shows the right info in the debug, but in the 2nd its gone, all the required info is NULL.

How to solve this?

  • if you are passing the record id in url like Id = {!Enrolment__c.Id} then stdController.getId() will give you the Id .. what else you are looking for ? – Ratan Paul Sep 27 '16 at 9:23
  • my code is running TWO times for some reason... codepad.org/JjyEO0fR here is the full code. it shows TWO debug everytime i click my button. first log, it shows the values correct, second time, it will show null/blank values. – fraglord Sep 27 '16 at 9:36
  • can you provide info like which is your parent object, child object, id you are passing through url, etc. – Reshma Sep 27 '16 at 9:47

Your Answer

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

Browse other questions tagged or ask your own question.