+ Start a Discussion

Create a New record via Jquery pop up



in one of our interface, we use Jquery pop up which pulls existing open opportunities. If there are no open opportunities, the user has to navigate away and create opportunities and then come back to the interface and add that newly created opportunity via the Jquery pop up.


How can we create a New Opportunity from within the jquery pop up window?


Any help is highly appreciated.




Saurabh DhobleSaurabh Dhoble

I'm not sure if the AJAX Toolkit allows you to create popup dialogs on the fly. I used the colorbox jquery library and created a popup which allows users to edit contacts inside the dialog box. Basically it shows a custom VF page to edit contacts - you can do the same for your create new opportunity. Here's the code snippet which did the trick :-


<apex:page standardController="Account" extensions="XXXXXXXXX">
<apex:form >
    <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" />
    <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js" />
    <apex:stylesheet value="{!URLFOR($Resource.ColorBox_CSS, '/colorbox.css')}" />
    <apex:includeScript value="{!URLFOR($Resource.JQuery_ColorBox)}" />
         $j = jQuery.noConflict();
		 $j(document).ready(function() {
        	$j(".customajax").colorbox({iframe:true, width:"60%", height:"60%", opacity:"50%"});

       	<apex:pageBlockTable value="{!searchResults}" var="c" id="searchResults">
            <apex:column >
                <a class="customajax" href="/apex/custom_contact_edit_page?id={!c.Id}">Edit</a>
            <apex:column value="{!c.Name}" />
            <apex:column value="{!c.Title}" />
            <apex:column value="{!c.Department}" />
            <apex:column value="{!c.Phone}" headerValue="Phone No." />
            <apex:column value="{!c.Email}" headerValue="Email Address" />


Warning - since my custom contact related list renders inside it's own iFrame, I had to redo the entire Account page as a custom VF page.



jQuery is just the UI. The AJAX Toolkit provides the data provider you need to save the record(s) programmatically. It's really one more way to reach the same result. However, I do like your solution as well, although the only real difference is where the transaction orginates (Visualforce versus API), which is basically the opposite sides of the same technological coin.