+ Start a Discussion
kavya akavya a 

How to assign user to opportunity from popup

I am new to sfdc please some one help me out.
In opportunity i need to have a custom "button". when i click a button it must open a popup and get all users with search functionality in it. When i select a user and click on "save" it must change the opportunity owner to the user. main functionality is assigning user to opportunity after creation. Thanks in advance.
Dinesh PDinesh P
You can place a custom button on opportunity layout. On click of this button u can call a VF page using javascript that can be window.open(URL of VF page, window size). VF page can hold data related to user, use standard controller on VF page since u may required pagination. VF page can have a save button, which can perform opportunity change owner opration.
kavya akavya a
in button:
 
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )} 

window.open('/apex/popup');

it is opening in other tab but i want to have a popup window to be displayed. How can i achieve this??
 
kavya akavya a
<apex:page standardController="opportunity" extensions="popup">
    <apex:form >
         <apex:pageBlock title="Change User to BD">
         <Apex:pageBlockSection >
             <apex:inputField value="{!opportunity.ownerid}"/>
         </Apex:pageBlockSection>
         </apex:pageBlock>
         
         <apex:commandButton action="{!save}" value="Save" />  

    </apex:form>
</apex:page>
since i had taken standardcontroller i took normal save is enough??

I have written code in popup where when i save i want to redirect it to same detail page closing the popup , how can i achieve this????
K@SK@S
try this way

 return (new PageReference('/apex/Issuse_Recivepage?sfdc.tabName=01r90000000DcUn').setredirect(true));
 
kavya akavya a
for custom button i had written 
 
var url = "/apex/PopUp?id={!Opportunity.Id}"; 
    var width = "520"; 
    var height = "400"; 
    window.open(url, '','scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no, width=' + width + ',height=' + height + ',left=' + ((window.innerWidth - width)/2) + ',top=' + ((window.innerHeight - height)/2) );




vf page:

   
<apex:page standardController="opportunity" extensions="popup">
    <script>
        window.onload = function(){  
            window.onblur = function(){
                window.close();
            }
            if(document.getElementById('ch').innerHTML == "Ok!")
            {
                window.opener.location.href="/{!$CurrentPage.parameters.id}";
                window.top.close();
            }
        }
        </script>
        <apex:form >
             <apex:pageBlock title="Change User to BD">
             <Apex:pageBlockSection >
                 <apex:inputField value="{!opportunity.ownerid}"/>
             </Apex:pageBlockSection>
             </apex:pageBlock>
             
             <apex:commandButton action="{!save}" value="Save" />  
    
        </apex:form>
    </apex:page>



apex class:
public class popup {
    
        public popup(ApexPages.StandardController controller) {
    
        }
    
     
       
    }



I had tried myself and reached here. When i clicked  a custom button popup is opening. Now after opening popup i am selecting a user and click on save. I am now manually closing popup and refresh the opportunity detail page it is changing now.


but main problem here is when i select lookup user and click on " save" button i want to close popup and reload the opportunity detail page.