+ Start a Discussion
sales4cesales4ce 

Create a New record via Jquery pop up

Hi,

 

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.

 

Thanks,

Sales4ce

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)}" />
    <script>
         $j = jQuery.noConflict();
		 $j(document).ready(function() {
        	$j(".customajax").colorbox({iframe:true, width:"60%", height:"60%", opacity:"50%"});
        })
	</script>

       	<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>
            <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" />
        </apex:pageBlockTable>

 

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.

 

sfdcfoxsfdcfox

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.