You need to sign in to do that
Don't have an account?

Can search picklist be populated?
I'm trying to populate a search picklist so that only relevant values are displayed. The user is viewing an invoice (custom object) and may want to add the invoice to an existing Case or create a case if no cases exist for that account. I can't find a way to populate the salesforce search popup. I have some rather muddled code at the moment I'm posting below, I know it is wrong because the Option property is probably not relevant to the picklist, but I'm at a loss and would really value some guidance here. I know this can't work in edit mode but they don't need to be in edit mode, the scontrol is invoked from a button on the detail view page.
Code:
Thanks,
Erica
Code:
function GetCaseList(AccountID) { var strSQL="Select CaseNumber From Case where AccountId = '" + AccountID+"'"; var result = sforce.connection.query(strSQL); if (result.getBoolean("success")) { //if successful var records = result.getArray("records"); var _Caselist = document.getElementById('CF00N20000001CqW7'); // URL of Case picklist window _Caselist.options.length = 0; i=0; while ( i<records.length) { var _case = records[i].CaseNumber; _Caselist.options[i] = new Option(_case); i++; } var retURL= escape("/{!m62_Invoice__c.Id}"); parent.location.href = retURL; } else { alert("No records returned for this account.\n\nCreate a new Case.\n\nClick OK to refresh."); //alert note } }I'd really appreciate some guidance here -
Thanks,
Erica
Hoping that I understand your issue and considering these two options I would opt for the second simply because you are initiating the sControl from the detail page of your record and not an edit page. Which means that you cannot pass anything back to the initiating window from the standard salesforce lookup.
At a high level you would essentially allow for the user to access you sControl from the page. The scontrol would be in a popup window and when the window is displayed it will query for your invoices. If invoices are found, you will allow for selection of one invoice and if one is clicked you will simply save the invoice Id to your record, close the popup window and refresh the parent window.
Writing this code can be more complicated than simply editing what you have here but hopefully the help I've provided above will prove useful.
-greg
I'd rather do option (1) but the problem with the way salesforce works, is that the popup list isn't filtered for custom objects, whereas I want to populate the options appearing with the existing cases belonging to that account. If they then choose one of them, I will add my invoice to that existing case as a related list item, otherwise if they cancel they can create a new case from another button on the invoice detail page.
You said <<Hoping that I understand your issue and considering these two options I would opt for the second simply because you are initiating the sControl from the detail page of your record and not an edit page. Which means that you cannot pass anything back to the initiating window from the standard salesforce lookup.>>
I understood that there is no way to invoke an scontrol from an edit page. Is that assumption wrong?Also, I wasn't as clear as I should have been about what I am doing. I am on the detail page of an invoice, and want to find (Search) all existing cases belonging to the Account that the invoice is related to. We use Cases to chase up invoices, amongst other things. If a case of the appropriate type (i.e. invoice chase-up) exists, then the user will add that invoice to the existing case in a related list. If it doesn't they will cancel the search window and choose New Case from a button on the detail page, which will create a new case and populate the appropriate fields.