function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
fullvaluefullvalue 

Using Salesforce popup lookup window

Let me explain.  I am building a new page via s-control that is ajax and dojo.  I have a need to add a owner to the record on this page.  I would like to use the popup window that Salesforce uses when assigning a user to a record.  How can I do this?  Or should I just create my own? 


Thanks!
Greg HGreg H
You'll need to include the following style sheets in your sControl (for formatting in my example):
Code:
<!-- common styles --><link href="/sCSS/10.0/Theme2/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet"> 
<!-- standard styles --><link href="/sCSS/10.0/Theme2/dStandard.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet"> 
<!-- elements styles --><link href="/sCSS/10.0/Theme2/elements.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet">

Include the standard salesforce functions file (this will allow you to use the openLookup function later in example):
Code:
<!-- salesforce.com specific functions --><script src="/js/functions.js" type="text/javascript"></script>

Place these hidden inputs in the body of your document (these hold the required values for the lookup to work and pass back the user's selection from the opened window):
Code:
<!-- Hidden elements for proper lookup assign button functionality -->
<input type="hidden" name="assigned_lkid" id="assigned_lkid" value="{!$User.Id}">
<input type="hidden" name="assigned_lkold" id="assigned_lkold" value="{!User.FirstName} {!User.LastName}">
<input type="hidden" name="assigned_lktp" id="assigned_lktp" value="StandardUserLookup">
<input type="hidden" name="assigned_lspf" id="assigned_lspf" value="0">
<input type="hidden" name="assigned_mod" id="assigned_mod" value="0">

Use this code to display the assiged field and the lookup icon (This is only a snippet from a full table you will need to hold the input field for assigned user and the lookup icon):
Code:
<td class="data2Col" colspan="3"><div class="requiredInput"><div class="requiredBlock"></div><span class="lookupInput"><input id="assigned" maxlength="80" name="assigned" onchange="document.getElementById('assigned_lkid').value='';document.getElementById('assigned_mod').value='1';" size="75" type="text" value="{!User.FirstName} {!User.LastName}">&nbsp;<a href="JavaScript: openLookup('/_ui/common/data/LookupPage—lkfm=editPage&lknm=assigned&lktp='+document.getElementById('assigned_lktp').value,670,document.getElementById('assigned_mod').value,'&lksrch='+escapeUTF(document.getElementById('assigned').value),'maxw')" id="assigned_lkwgt" onclick="setLastMousePosition(event)" title="Assigned To Lookup (New Window)"><img src="/s.gif" alt="Assigned To Lookup (New Window)" class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="Assigned To Lookup (New Window)"></a></span></div></td>

You may need to tweak the code from my fourth snippet to fit in your specific table because the TD tag I used will span three columns and you may only want it to span one.
 
Without going into too much detail, these snippets will allow you to create a lookup field and icon in your personal sControl and hook into the standard salesforce.com assigned lookup window.  Do not change any of the element id values as they are what salesforce needs to move the data from the pop up window of the user search and the window holding your sControl.
 
Let me know if you need further explanation or encounter issues,
-greg