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
fourfourfunfourfourfun 

Rolling you own lookup

Hi all,

 

Working through this fantastically useful guide here:

 

http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/

 

Except it is a little too light in places for someone of my skill level. At the moment trying to replicate the example before diving into customising.

 

I'm getting that this is the section of the 4 pieces of code where I have to start bespoking:

 

https://github.com/jeffdonthemic/Blog-Sample-Code/blob/master/salesforce/src/classes/CustomAccountLookupController.cls

      // Following is the url of Custom Lookup page. You need to change that accordingly
      baseURL = "/apex/CustomAccountLookup?txt=" + txtId;
      
      // Following is the id of apex:form control "myForm". You need to change that accordingly
      baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}");
      if (modified == '1') {
        baseURL = baseURL + "&lksearch=" + searchParam;
      }
      
      // Following is the ID of inputField that is the lookup to be customized as custom lookup
      if(txtId.indexOf('Account') > -1 ){
        isCustomLookup = true;

 The top bit I have done:

 

      // Following is the url of Custom Lookup page. You need to change that accordingly
      baseURL = "/apex/CustomAccountLookup?txt=" + "066V0000000D4vc"; 
      //latter is the bespoke Salesforce ID for the CustomLookupPage - like URL hacking

 But this:

 

      // Following is the id of apex:form control "myForm". You need to change that accordingly
      baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}");
      if (modified == '1') {
        baseURL = baseURL + "&lksearch=" + searchParam;
      }

 I'm not sure what I am meant to be sticking in here.

 

Assuming the third part of this is where I put the ID of the lookup field I have created on the contact screen.

 

Thanks for any help on this.

Best Answer chosen by Admin (Salesforce Developers) 
fourfourfunfourfourfun

Best option seems to be to run it from a button/link (which works fine). Next quandary is how on earth to pass the results between records efficiently.

All Answers

fourfourfunfourfourfun

Hah. Seen a few queries on this line in here, none of which really tell me what I am up to. Commenting seems to be at an assumed higher level in the code.

fourfourfunfourfourfun

Ok, the more I dive into this, the more I think I am poking around the wrong quarters. It is almost as if the code does not know to run when the lookup is clicked. Unfortunately, my limited visualforce knowledge cannot tell what on earth I have to change for this to happen.

 

Do I have to change BaseURL to something? Do I have to change somewhere else? I just cannot tell how this code knows that I have clicked on the lookup.

fourfourfunfourfourfun

My issue appears to be my reading ability. On going through the blog again, it seems that the lookup will only work when running on a Visualforce page... this is how it "understands" to trigger the code when the lookup is clicked on.

 

My big quandary: how to put this into my org? This was to go in a custom object, but now it is looking like I need an alternative.

fourfourfunfourfourfun

Best option seems to be to run it from a button/link (which works fine). Next quandary is how on earth to pass the results between records efficiently.

This was selected as the best answer