+ Start a Discussion
Amitkumar15Amitkumar15 

Modal window on Custom link

 

I have to open a modal windon on click of custom link and on that modal window i want to display some fileds from user object like address and city to update and a 'Submit ' button

and on click of submit button that data should be saved to user object..

 

 

 

Any help on this?

Dhaval PanchalDhaval Panchal

I have created same but on contact object.

see my example.

 

below is vf page to add "Other Address" values. Page name is "AddOtherAddress"

 

<apex:page standardController="Contact" sidebar="false" showHeader="false" id="myPage">
    <apex:includeScript value="/soap/ajax/16.0/connection.js"/>
    <apex:form id="myForm">
        <apex:pageBlock id="pb">
            <apex:pageBlockButtons>
                <apex:CommandButton oncomplete="Save();" value="Save" reRender="myPage:myForm:pb:OtherCountry,myPage:myForm:pb:OtherState,myPage:myForm:pb:OtherCity,myPage:myForm:pb:OtherStreet,myPage:myForm:pb:OtherPostalCode"/>
                <apex:CommandButton value="Cancel" action="{!Cancel}" onclick="window.close();"/>
            </apex:pageBlockButtons>
            <apex:inputHidden id="OtherStreet" value="{!Contact.OtherStreet}"/>
            <apex:inputHidden id="OtherCity" value="{!Contact.OtherCity}"/>
            <apex:inputHidden id="OtherState" value="{!Contact.OtherState}"/>
            <apex:inputHidden id="OtherPostalCode" value="{!Contact.OtherPostalCode}"/>
            <apex:inputHidden id="OtherCountry" value="{!Contact.OtherCountry}"/>
            <apex:pageBlockSection columns="1" id="pbs">
                <apex:pageBlockSectionItem>    
                    <apex:outputLabel for="otherStreet">{!$ObjectType.Contact.fields.OtherStreet.label}</apex:outputLabel>
                    <apex:inputField id="otherStreet" value="{!Contact.OtherStreet}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>    
                    <apex:outputLabel for="OtherCity">{!$ObjectType.Contact.fields.OtherCity.label}</apex:outputLabel>
                    <apex:inputField id="OtherCity" value="{!Contact.OtherCity}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>    
                    <apex:outputLabel for="OtherState">{!$ObjectType.Contact.fields.OtherState.label}</apex:outputLabel>
                    <apex:inputField id="OtherState" value="{!Contact.OtherState}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>    
                    <apex:outputLabel for="OtherPostalCode">{!$ObjectType.Contact.fields.OtherPostalCode.label}</apex:outputLabel>
                    <apex:inputField id="OtherPostalCode" value="{!Contact.OtherPostalCode}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>    
                    <apex:outputLabel for="OtherCountry">{!$ObjectType.Contact.fields.OtherCountry.label}</apex:outputLabel>
                    <apex:inputField id="OtherCountry" value="{!Contact.OtherCountry}"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <script>
        function Save(){
            sforce.connection.sessionId = '{!$Api.Session_ID}';
            var con = new sforce.SObject("Contact");
            con.Id = "{!Contact.Id}";
            //alert(document.getElementById("myPage:myForm:pb:OtherPostalCode").value);
            con.OtherStreet = document.getElementById("myPage:myForm:pb:OtherStreet").value;
            con.OtherCity = document.getElementById("myPage:myForm:pb:OtherCity").value;
            con.OtherState = document.getElementById("myPage:myForm:pb:OtherState").value;
            con.OtherPostalCode = document.getElementById("myPage:myForm:pb:OtherPostalCode").value;
            con.OtherCountry = document.getElementById("myPage:myForm:pb:OtherCountry").value;
            result = sforce.connection.update([con]); 
            //alert(con.OtherCountry);
            window.close();
        }
    </script>
</apex:page>

 I have created on javascript button for contact detail page like below.

 

var parenturl = parent.location.href; 

var URL = location.protocol + "//" + location.host + "/apex/AddOtherAddress?id={!Contact.Id}";
var newwindow = window.showModalDialog(URL,'','dialogWidth:620px; dialogHeight:400px; center:yes; resizable:no');

parent.location.href = parenturl;

 And added this button on detail page layout. It works fine for me.

You can develop same as per your requirement.

Hope this is helpfull to you.