• Manoj Maraka 18
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 10
    Replies
Hi All,

I am very new to Salesforce. I am trying to implement 2 multiselect picklists, Left picklist takes contacts from Contact object and on clicking ">>" button selected contacts should be moved from left picklist to right picklist. And on hitting 'Save', a message should be displayed saying so and so contacts are selected.
The issue here is the contacts are not getting added in right picklist. I dont know where I am going wrong. Could anyone please help? Here's the code I used.

VF Page:

<apex:page controller="multiselect2">
    <apex:form >
    <apex:pageBlock >
    
        <apex:outputLabel value="   Available List"> </apex:outputLabel>
      
        
        <apex:panelGrid columns="3" id="abcd">
        
            
            <apex:selectList id="sel1" value="{!leftselected}" multiselect="true" style="width:150px" size="7">
                <apex:selectOptions value="{!unselectedvalues}" />
            </apex:selectList>
                <apex:panelGroup >
                    <br/>
                    
                        <apex:commandbutton value=">>" action="{!selectclick}" reRender="abcd"></apex:commandbutton>
                    
                    
                    <br/><br/>
                    <apex:actionRegion >
                        <apex:commandbutton value="<<" action="{!unselectclick}" reRender="abcd">  </apex:commandbutton>  
                    </apex:actionRegion>
                         
                </apex:panelGroup>
                
            <apex:selectList id="sel2" value="{!rightselected}" multiselect="true" style="width:150px" size="7">
                <apex:selectOptions value="{!rightselected}" />
            </apex:selectList>
        </apex:panelGrid>
        
        <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                
            </apex:pageBlockButtons>
          </apex:pageBlock>
         
    </apex:form>
</apex:page>

Controller:
public class multiselect2 {
    
    Public List<Contact> leftselected{get;set;}
    Public List<Contact> rightselected{get;set;}
    Set<Contact> leftvalues = new Set<Contact>();
    Set<Contact> rightvalues = new Set<Contact>();
    
    public multiselect2(){
        List<Contact> ov = [SELECT Id, Name FROM Contact]; 
        Set<Contact> originalValues = new Set<Contact>(ov);
        leftselected = new List<Contact>();
        rightselected = new List<Contact>();
        leftvalues.addAll(originalValues);
    }
     
    public PageReference selectclick(){
        rightselected.clear();
        for(Contact c : leftselected){
       
            leftvalues.remove(c);
            rightvalues.add(c);
            
        }
        return null;
    }
     
    public PageReference unselectclick(){
        leftselected.clear();
        for(Contact c : rightselected){
            rightvalues.remove(c);
            leftvalues.add(c);
        }
        return null;
    }
 
    public List<SelectOption> getunSelectedValues(){
        List<SelectOption> options = new List<SelectOption>();
        List<Contact> tempList = new List<Contact>();
        tempList.addAll(leftvalues);
        tempList.sort();
        for(Contact c : tempList)
            options.add(new SelectOption(c.id,c.name));
        return options;
    }
 
    public List<SelectOption> getSelectedValues(){
        List<SelectOption> options1 = new List<SelectOption>();
        List<Contact> tempList = new List<Contact>();
        tempList.addAll(rightvalues);
        tempList.sort();
        for(Contact c : tempList)
            options1.add(new SelectOption(c.id,c.name));
        return options1;
    }
    public PageReference save() {
    
        
    return null;
    }
}


 
I want to add two dropdowns at contact create form and I want to fetch these dropdowns value from an object It can be possible.
Please suggest the best idea.
Hello,

I have parent objet ParentX and child object childY.
I want to have related list of ChildY on parentX records.

My question is, i need tocreate lookup on child or parent ?

Thanks 
Can anybody help me with a lookup field in a form to create a record in lightning component?
i am creating a record by taking input from a form using lightning which has one lookup to the user record, i want help with that field....help needed with the same field....
Thanks in advance
 
I have related list called "Approvers" in opportunity object.

And I created few dummy records in approvers.

I am trying to fetch all those related list record associated with opportunity in apex trigger. As I wannted to assign values to the picklist field in realted list depend on Oppotunity pickist field value

For eg : Select all approvers where opportunity id="some-id";

Any suggestion would be really appreciated.
I am creating a generic list component that takes in an object type, and a list of fields that it wants to display. I am looping through each of the items and building a table, but when it comes to outputting the different fields, I am at a bit of a roadblock for doing it dynamically. Here is the relevant component code: 
<aura:component description="ObjectList" controller="ObjectListController">
    <aura:attribute name="objectName" type="String" default="" />
    <aura:attribute name="objectFieldsString" type="String" default="Id,Name" />
    <aura:attribute name="objectFields" type="List" />
    <aura:attribute name="items" type="List" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <table>
        <thead>
        <tr>
            <aura:iteration items="{!v.objectFields}" var="fieldName">
                    <th scope="col"><div class="slds-truncate">{!fieldName}</div></th>
            </aura:iteration>
        </tr>
        </thead>
        <tbody>
        <aura:iteration items="{!v.items}" var="item">
            <tr>
                <aura:iteration items="{!v.objectFields}" var="field">
                        <td>
                                {!item.field}
                        </td>
                </aura:iteration>
            </tr>
        </aura:iteration>
        </tbody>
    </table>
</aura:component>

In the aura:iteration in the tbody, I am trying to cycle through the different field names, and then grab those fields from the item, but it doesn't seem like lightning supports it. For example if objectFields contained an array of strings containing ["Id","Name"], I want to then grab item.Id and item.Name and display them in the table. But using {!item.field} or anything similar does not seem to work.

Could anyone provide me with the proper syntax if this is possible, or a possible workaround to get something like this to work?

Having an issue i my Save Code. Code is as below

public PageReference doSave() {
        try{
        List<Unidentified_Deals__c> uds = new List<Unidentified_Deals__c>();
        for(oppWrap o:opps){
            if(o.check){
                Unidentified_Deals__c u = new Unidentified_Deals__c(Name=o.opp.Name,Opportunity__c=o.opp.Id, Account_Plan__c=accountPlanId, Account__c = o.opp.AccountId);
                uds.add(u);
            }
        }
        insert uds;
        upsert od;
        upsert lw;
        fetchOpps();
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO, 'Saved and Refreshed!!');
        ApexPages.addMessage(myMsg);
        }catch(Exception e){
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Error, e.getMessage());
        ApexPages.addMessage(myMsg);
        }
        return null;
    }
The content is getting saved, but only excuting the "Saved and Refreshed". I don't want to execute "Saved and Refreshed", i want the page to return to the previous page where i cam from. Your help is really appreciated.

Thanks & Regards
Ravi


 

Hi All,

I am very new to Salesforce. I am trying to implement 2 multiselect picklists, Left picklist takes contacts from Contact object and on clicking ">>" button selected contacts should be moved from left picklist to right picklist. And on hitting 'Save', a message should be displayed saying so and so contacts are selected.
The issue here is the contacts are not getting added in right picklist. I dont know where I am going wrong. Could anyone please help? Here's the code I used.

VF Page:

<apex:page controller="multiselect2">
    <apex:form >
    <apex:pageBlock >
    
        <apex:outputLabel value="   Available List"> </apex:outputLabel>
      
        
        <apex:panelGrid columns="3" id="abcd">
        
            
            <apex:selectList id="sel1" value="{!leftselected}" multiselect="true" style="width:150px" size="7">
                <apex:selectOptions value="{!unselectedvalues}" />
            </apex:selectList>
                <apex:panelGroup >
                    <br/>
                    
                        <apex:commandbutton value=">>" action="{!selectclick}" reRender="abcd"></apex:commandbutton>
                    
                    
                    <br/><br/>
                    <apex:actionRegion >
                        <apex:commandbutton value="<<" action="{!unselectclick}" reRender="abcd">  </apex:commandbutton>  
                    </apex:actionRegion>
                         
                </apex:panelGroup>
                
            <apex:selectList id="sel2" value="{!rightselected}" multiselect="true" style="width:150px" size="7">
                <apex:selectOptions value="{!rightselected}" />
            </apex:selectList>
        </apex:panelGrid>
        
        <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                
            </apex:pageBlockButtons>
          </apex:pageBlock>
         
    </apex:form>
</apex:page>

Controller:
public class multiselect2 {
    
    Public List<Contact> leftselected{get;set;}
    Public List<Contact> rightselected{get;set;}
    Set<Contact> leftvalues = new Set<Contact>();
    Set<Contact> rightvalues = new Set<Contact>();
    
    public multiselect2(){
        List<Contact> ov = [SELECT Id, Name FROM Contact]; 
        Set<Contact> originalValues = new Set<Contact>(ov);
        leftselected = new List<Contact>();
        rightselected = new List<Contact>();
        leftvalues.addAll(originalValues);
    }
     
    public PageReference selectclick(){
        rightselected.clear();
        for(Contact c : leftselected){
       
            leftvalues.remove(c);
            rightvalues.add(c);
            
        }
        return null;
    }
     
    public PageReference unselectclick(){
        leftselected.clear();
        for(Contact c : rightselected){
            rightvalues.remove(c);
            leftvalues.add(c);
        }
        return null;
    }
 
    public List<SelectOption> getunSelectedValues(){
        List<SelectOption> options = new List<SelectOption>();
        List<Contact> tempList = new List<Contact>();
        tempList.addAll(leftvalues);
        tempList.sort();
        for(Contact c : tempList)
            options.add(new SelectOption(c.id,c.name));
        return options;
    }
 
    public List<SelectOption> getSelectedValues(){
        List<SelectOption> options1 = new List<SelectOption>();
        List<Contact> tempList = new List<Contact>();
        tempList.addAll(rightvalues);
        tempList.sort();
        for(Contact c : tempList)
            options1.add(new SelectOption(c.id,c.name));
        return options1;
    }
    public PageReference save() {
    
        
    return null;
    }
}