1

I am attempting to use a visualforce page instead of a standard new button. I have an object Line__c that has a master detail relationship to another object Line_Type__c.

I have a Line__c related list on Line_Type__c detail page. This is where the button is going. What I want to accomplish is that, when my button is clicked, pass in the URL, the value of the master (Line_Type__c) ultimately setting the lookup field in my VF page with the value of the current Line_Type__c record we are on.

 {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
 {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 

    var url = 'apex/LinePage?CF00NJ0000001LOR6={!Line_Type__c.Name}&CF00NJ0000001LOR6_lkid={!Line_Type__c.Id}';


    if(window.parent != null){ 
    window.parent.location.href = url; 
    }
    else{ 
    window.location.href = url; 
    }
2

since its a Visualforce you dont need to worry about using IDS of form element .A simple merge field would do ,provided you properly pass the parentId as paremeter when button is clicked

Lets assume your url from List button will be like

apex/LinePage?Parent_Id=XXXXXXXXXXXXXXX

Now its easier to obtain this is using page parameter to auto populate,provided you have standard controller

<apex:inputfield value="{!$CurrentPage.parameters.Parent_Id}"
| improve this answer | |
0

I ended up just using some queries in my controller instead of passing it via URL

| improve this answer | |

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.