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
Princes91221Princes91221 

How to save multi select lookup values

Hi Everyone,

I have created a multi select lookup component in Account object.
Selected multi select lookup values
Below I am pasting the code.
public class reUsableMultiSelectLookupCtrl {
    @AuraEnabled(cacheable=true)
    public static List<sObject> retriveSearchData(String ObjectName, String fieldName, String value, List<String> selectedRecId) {
        List<sObject> sObjectResultList = new List<sObject>();
        if(selectedRecId == null)
            selectedRecId = new List<String>();

        if(String.isNotEmpty(value)) {
            String query = 'Select '+fieldName+' FROM '+ObjectName+' WHERE Name LIKE \'%' + value.trim() + '%\' and ID NOT IN: selectedRecId order by createdDate DESC LIMIT 5';
            for(sObject so : Database.Query(query)) {
                sObjectResultList.add(so);
            }
        }
        return sObjectResultList;
    }
}

I want to save the select lookup in lead object under a custom field.

Any help is appreciated.

Thanks in advance!
AshwiniAshwini (Salesforce Developers) 
Hi @Princes91221 ,
Can you elaborate more on the ask?
What is the type of the custom field?
Princes91221Princes91221
Hi Ashwini,
Type of custom field is Textarea.