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
gokubigokubi 

Wouldn't an object Lookup Widget be fantastic?

Hey Dave, Ron, Adam and all the sf.com folks who read this board.

I love the AJAX tookit! It has put incredible control over the sf.com UI in my hands. I'm creating custom code that users have no idea isn't standard sf.com functionality. I get to chain together API calls and save the user from cumbersome data entry steps. I can't say enough how important this toolkit is to my work--my job is to make sf.com a good platform for nonprofits to use to track donors, grants, volunteers, etc. With S-Controls and the AJAX toolkit I can make it work. I wanted to thank you guys for making my job possible (and fun) and for your continued development of AJAX toolkit.

In the Beta 3.3 I noticed that UI widgets are starting to surface. The most important widget on my wish list is an object lookup field. I find myself creating S-Controls that ask the user for data, and it sure would be nice to be able to look up existing sf.com objects using the existing lookup layouts. Example:

As part of my Householding application, I have an S-Control data entry form that creates two Contacts (a married couple), creates a Household (their home address), and then relates the new Contacts to that new Household. As we all know, Contacts need an Account when they are created. So, the user supplies an Account name to add the Contacts to on creation, and I go look it up with a query, get the ID if I find an exact match of the name, create a new Account if the name doesn't match exactly, or use a default Account if no name is supplied. If the Account name is misspelled, a new account will be created.

Obviously, a lookup box like we have in the sf.com web UI is what's needed here. Frankly, I don't have the time/skills to build that kind of lookup myself.

I'd love to see a lookup widget for objects. In my thinking about how to do it, I've come to realize that there is non-trivial complexity involved. But it sure would be great to be able to add an object lookup to an S-Control in one line of code. So, if you're thinking about it, mark me down as interested!

Thanks again for all the great work,

Steve
DevAngelDevAngel
We have some decisions to make with regards to building widgets.  As I'm sure you are aware, there are others who are building toolkits and frameworks for alot of the widget type stuff that you might want to do (dojo, scriptaculous, Yahoo UI and MS Atlas to name a few).  These efforts are getting tons of use and are getting very stable and useful.   Take a lookup for instance.  To do this we need a popup to put the lookup ui in and it needs to be stable and reliable.  The salesforce.com part of the lookup is rather simple as the api makes the data searches, queries, etc. very easy.  The difficult part is in creating this pop div or iframe or whatever, that pops up where you want it and doesn't have any quirks with regards to browser variations (think select element showing through div in IE).

So, do we duplicate all the hard work down by others who are arguably farther ahead of the curve with widgets, or, do we somehow provide a path for you, the developer community, to create a slew of widgets specifically for salesforce?

I think the later is a better solution for us and for you.  I'm currently working on samples for a couple of the frameworks so that you all can see how this is done.  My hope is that our developer community will produce lots of really nice "widgets", publish them on the appexchange and the platform will be richer and your toolset will grow organically.

In answer to your question, YES!! a lookup widger would be great.


Cheers
gokubigokubi
Can't wait to see those examples! I haven't played with other toolkits, and would be happy to use them if they're stable and I can get my head around doing sf.com specific stuff like looking up objects. I'm all about using code samples from the Appexchange and monitor the RSS feed for new publications from which to learn and borrow.

When I have what I think are interesting S-Control examples I try to publish links to their Appexchange listings to this list, even if the code might be a bit rough, and even a tad embarrassing. I'd love to see more developers do the same.

I knew you guys were thinking about the widget stuff, thanks for the update!

Steve
SteveBowerSteveBower
If it helps, (and sometimes it does), I stole code from the Salesforce UI for simple lookups.  This is fine for  just implementing the native Salesforce Lookup solution, but it fails when you want to implement more interesting lookups.  (For example, I wonder if there is any way in a Lookup to restrict it to specific record  types.)

But, I agree, a deeper library of UI tools would be welcome.  Frankly though, I'm not sure that the strategy of relying on external developers for base-ui functionality will work.  Those frameworks are generalized frameworks and some code still needs to be written for good salesforce integration, look and feel, behavior, etc.  I think it remains to be seen if, and how quickly, this will flesh out.

Steve.

Code to implement a simple lookup for a "project" object (type a0D).
<input name="project_p_lkid" id="project_p_lkid" value="000000000000000" type="hidden">
<input name="project_p_lkold" id="project_p_lkold" value="null" type="hidden">
<input name="project_p_lktp" id="project_p_lktp" value="a0D" type="hidden">
<input name="project_p_lspf" id="project_p_lspf" value="0" type="hidden">
<input name="project_p_mod" id="project_p_mod" value="0" type="hidden">
<span class="lookupInput"> 
<input tabindex="7" maxlength="80" 
onchange="document.getElementById('project_p_lkid').value='';
  document.getElementById('project_p_mod').value='1';" 
 id="project_p" size="20" name="project_p" type="text">

    <a href=
    "JavaScript: openLookup('/_ui/common/data/LookupPage—lknm=project_p&lkfm=HMTL_form_Not_Shown_in_this_fragment&lktp=' + document.getElementById('project_p_lktp').value,
    670,
    document.getElementById('project_p_mod').value,
    '&lksrch=' + escapeUTF(document.getElementById('project_p').value),
    'maxw')"
    tabindex="7" title="Project Lookup (New Window)" 
    onclick="setLastMousePosition(event)" 
    id="project_p_lkwgt">
    <img src="/s.gif" alt="Project Lookup (New Window)" class="lookupPopup">
    </a>
 
</span>

 

DevAngelDevAngel
Agreed, it still remains to be seen.  But, on the other had, I feel it's easier to write a "middle-ware" js to wire up the other frameworks with salesforce data than to re-invent the wheel.  For instance, it's quite simple to create a mouse over/tool tip type of effect using the yahoo libs.  Saves me from having to write the whole floating div piece.  As for basic functionality, hopefully as folks begin to integrate with the other frameworks, we will see these "widgets" on the boards and the exchange so that we can collect references to a bunch of basic functionality that is available to all.

gokubigokubi
Thanks for the code Steve. I'm having some trouble with the form submitting when I come back from the popup, but I'll keep at it.

Steve
SteveBowerSteveBower
Hmmm perhaps a little clarification might help?  The form that you have to put in the HTML doesn't have to have any "action" associated with it.  To be clearer, the form I'm using in my case has:   action="#"   which does nothing.  (In fact, for all the s-control's I've done so far, I don't have any "active" forms.)

The reason you have to supply a formname as a parameter is so that the widget can use it to navigate the DOM and find the fields that you're specifying.

So, if you're really using an active form, and you also want to use this, you might need to implement something like:  (pseudo code obviously)
.... html....

<form action="Something that you're really doing when the 'outer'
            form is submitted">
....more stuff....
<form action="#" id="dataentryform">
<input id="somefieldyoupopulatewithlookup">
 ... etc... Lookup stuff referring to dataentryform and somefieldyoupopulatewithlookup </form> </form>

Hope this helps, Steve Bower.