• TweetsMcG
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

Hi there

 

Am a newb to Apex/VF.  I'm trying to populate a multi-select picklist "Site Categories", from a custom object - Site_Categories__c.

 

I want to add this field to the Lead object.

 

Thanks to some wonderful SF people out there, I've been able to succeed in the first part, however, I'm not sure how to add it to the Lead object, plus be able to edit and save the values chosen to the Lead records.

 

All help appreciated!  Code below:

 

Controller

 

public with sharing class MultiSelectPicklist {

    private final Site_Categories__c scats;

    public MultiSelectPicklist(ApexPages.StandardController controller) {
            
       this.scats= (Site_Categories__c)controller.getSubject();

    }

 
    //public Site_Categories__c scats;
    
    public List<SelectOption> LeftSelectList {get;set;}
    public List<SelectOption> RightSelectList {get;set;}
 
    public List<string> LeftSelectedValues {get;set;}
    public List<string> RightSelectedValues {get;set;}
 
    public MultiSelectPicklist()
    {
        LeftSelectList = new List<SelectOption>();
        RightSelectList = new List<SelectOption>();
        

        for(Site_Categories__c scats : [select id,category__c from site_categories__c order by category__c ASC])
        {
            LeftSelectList.add(new SelectOption(scats.Id, scats.category__c)) ;
        }
        
        RightSelectList.add(new SelectOption('-- None --','-- None --'));
    }
 
    public void MoveRight()
    {
        if (LeftSelectedValues != null && LeftSelectedValues.size() > 0)
        {
            
            //Clear RightSelectedValues
            RightSelectedValues = new List<string>();
            
            //Remove 'None' value from RightSelectList            
            if(RightSelectList != null)
            {
                for(integer i = 0; i < RightSelectList.size(); i++)
                {
                    RightSelectList[i].getValue();
                    RightSelectList.remove(i);
                }
            }
            
            for (integer i =0; i < LeftSelectList.size(); i++)
            {
                for (integer si =0; si < LeftSelectedValues.size(); si++)
                {
                    if (LeftSelectList[i].getValue() == LeftSelectedValues[si])
                    {
                        //Remove the SelectOption from LeftSelectList and add it to RightSelectList

                        RightSelectList.add(LeftSelectList.remove(i));
 
                        //Remove the SelectOption from LeftSelectedValues and add it to RightSelectedValues
                        RightSelectedValues.add(LeftSelectedValues[si]);
 
                    }
                }
 
            }
            //Clear LeftSelectedValues
            LeftSelectedValues = new List<string>();
            LeftSelectList.add(new SelectOption('-- None --','-- None --'));
        }
    }
 
    public void MoveLeft()
    {
        //Remove 'None' value from LeftSelectList
        if(LeftSelectList != null)
            {
                for(integer i = 0; i < LeftSelectList.size(); i++)
                {
                    LeftSelectList[i].getValue();
                    LeftSelectList.remove(i);
                }
            }
            
        if (RightSelectList != null && RightSelectList.size() > 0)
        {
            //Clear LeftSelectedValues
            LeftSelectedValues = new List<string>();

            for (integer i =0; i < RightSelectList.size(); i++)
            {
                for (integer si =0; si < RightSelectedValues.size(); si++)
                {
                    if (RightSelectList[i].getValue() == RightSelectedValues[si])
                    {
                        //Remove the None value from the LeftSelectList
                        //LeftSelectList.remove(i);
                                    
                        //Remove the SelectOption from RightSelectList and add it to LeftSelectList
                        LeftSelectList.add(RightSelectList.remove(i));

 
                        //Remove the SelectOption from RightSelectList and add it to LeftSelectedValues
                        LeftSelectedValues.add(RightSelectedValues[si]);
                    }
                }
 
            }
            //Clear RightSelectedValues
            RightSelectedValues = new List<string>();
            RightSelectList.add(new SelectOption('-- None --','-- None --'));
        }
    }
    

}

 

Page

 

<apex:page controller="MultiSelectPicklist" sidebar="false">
<apex:form >
     <apex:pageBlock mode="edit">
 
        <table cellpadding="3">
            <tr>
                <td colspan="2"><apex:outputLabel style="font-weight: bold;">Site Categories</apex:outputLabel></td>
            </tr>
            <tr>
                <td>
                    <apex:selectList size="5" multiselect="true" value="{!LeftSelectedValues}" id="LeftSelectList">
                        <apex:selectOptions value="{!LeftSelectList}"/>
                    </apex:selectList>
                </td>
                <td style="vertical-align:middle;text-align:center;">
                    <apex:commandButton value=">"  action="{!MoveRight}" reRender="LeftSelectList,RightSelectList"/>
                    <br />
                    <apex:commandButton value="<" action="{!MoveLeft}" reRender="LeftSelectList,RightSelectList"/>
                </td>
                <td>
                    <apex:selectList size="5" multiselect="true" value="{!RightSelectedValues}" id="RightSelectList">
                        <apex:selectOptions value="{!RightSelectList}"/>
                    </apex:selectList>
                </td>
 
            </tr>
        </table>
 
    </apex:pageBlock>
</apex:form>
</apex:page>

 

Please help!

 

Thank you :)

 

R

hi all

 

We have a Registration object that hangs off Location Accounts.  Field on registration is called Billing Account.

 

All our accounts should have a Parent Account, however, users keep creating Registrations on Location Accounts, OR Parent Accounts.

 

We are trying to cause an error message to occur when someone tries to submit a Registration that is:

a. attached to a Parent Account; or

b. attached to a Location Account that has no Parent Account.

 

When we use Force.com explorer and query thusly:

 

 

select Billing_Account__r.ParentId from Registration__c 
where Billing_Account__r.ParentId = ''

 We get the desired result.

 

 

But when we try to call it in the following code,

 

alert("{!Registration__c.Billing_Account__r.ParentId}");

 it tells us

Error: Field Registration__c.Billing_Account__r.ParentId does not exist. Check spelling.

 

We get the same error whatever field on that Billing Account we are trying to access.

 

 

What are we doing wrong?

 

Thanks so much for all your help. :)

 

Hi there

 

Am a newb to Apex/VF.  I'm trying to populate a multi-select picklist "Site Categories", from a custom object - Site_Categories__c.

 

I want to add this field to the Lead object.

 

Thanks to some wonderful SF people out there, I've been able to succeed in the first part, however, I'm not sure how to add it to the Lead object, plus be able to edit and save the values chosen to the Lead records.

 

All help appreciated!  Code below:

 

Controller

 

public with sharing class MultiSelectPicklist {

    private final Site_Categories__c scats;

    public MultiSelectPicklist(ApexPages.StandardController controller) {
            
       this.scats= (Site_Categories__c)controller.getSubject();

    }

 
    //public Site_Categories__c scats;
    
    public List<SelectOption> LeftSelectList {get;set;}
    public List<SelectOption> RightSelectList {get;set;}
 
    public List<string> LeftSelectedValues {get;set;}
    public List<string> RightSelectedValues {get;set;}
 
    public MultiSelectPicklist()
    {
        LeftSelectList = new List<SelectOption>();
        RightSelectList = new List<SelectOption>();
        

        for(Site_Categories__c scats : [select id,category__c from site_categories__c order by category__c ASC])
        {
            LeftSelectList.add(new SelectOption(scats.Id, scats.category__c)) ;
        }
        
        RightSelectList.add(new SelectOption('-- None --','-- None --'));
    }
 
    public void MoveRight()
    {
        if (LeftSelectedValues != null && LeftSelectedValues.size() > 0)
        {
            
            //Clear RightSelectedValues
            RightSelectedValues = new List<string>();
            
            //Remove 'None' value from RightSelectList            
            if(RightSelectList != null)
            {
                for(integer i = 0; i < RightSelectList.size(); i++)
                {
                    RightSelectList[i].getValue();
                    RightSelectList.remove(i);
                }
            }
            
            for (integer i =0; i < LeftSelectList.size(); i++)
            {
                for (integer si =0; si < LeftSelectedValues.size(); si++)
                {
                    if (LeftSelectList[i].getValue() == LeftSelectedValues[si])
                    {
                        //Remove the SelectOption from LeftSelectList and add it to RightSelectList

                        RightSelectList.add(LeftSelectList.remove(i));
 
                        //Remove the SelectOption from LeftSelectedValues and add it to RightSelectedValues
                        RightSelectedValues.add(LeftSelectedValues[si]);
 
                    }
                }
 
            }
            //Clear LeftSelectedValues
            LeftSelectedValues = new List<string>();
            LeftSelectList.add(new SelectOption('-- None --','-- None --'));
        }
    }
 
    public void MoveLeft()
    {
        //Remove 'None' value from LeftSelectList
        if(LeftSelectList != null)
            {
                for(integer i = 0; i < LeftSelectList.size(); i++)
                {
                    LeftSelectList[i].getValue();
                    LeftSelectList.remove(i);
                }
            }
            
        if (RightSelectList != null && RightSelectList.size() > 0)
        {
            //Clear LeftSelectedValues
            LeftSelectedValues = new List<string>();

            for (integer i =0; i < RightSelectList.size(); i++)
            {
                for (integer si =0; si < RightSelectedValues.size(); si++)
                {
                    if (RightSelectList[i].getValue() == RightSelectedValues[si])
                    {
                        //Remove the None value from the LeftSelectList
                        //LeftSelectList.remove(i);
                                    
                        //Remove the SelectOption from RightSelectList and add it to LeftSelectList
                        LeftSelectList.add(RightSelectList.remove(i));

 
                        //Remove the SelectOption from RightSelectList and add it to LeftSelectedValues
                        LeftSelectedValues.add(RightSelectedValues[si]);
                    }
                }
 
            }
            //Clear RightSelectedValues
            RightSelectedValues = new List<string>();
            RightSelectList.add(new SelectOption('-- None --','-- None --'));
        }
    }
    

}

 

Page

 

<apex:page controller="MultiSelectPicklist" sidebar="false">
<apex:form >
     <apex:pageBlock mode="edit">
 
        <table cellpadding="3">
            <tr>
                <td colspan="2"><apex:outputLabel style="font-weight: bold;">Site Categories</apex:outputLabel></td>
            </tr>
            <tr>
                <td>
                    <apex:selectList size="5" multiselect="true" value="{!LeftSelectedValues}" id="LeftSelectList">
                        <apex:selectOptions value="{!LeftSelectList}"/>
                    </apex:selectList>
                </td>
                <td style="vertical-align:middle;text-align:center;">
                    <apex:commandButton value=">"  action="{!MoveRight}" reRender="LeftSelectList,RightSelectList"/>
                    <br />
                    <apex:commandButton value="<" action="{!MoveLeft}" reRender="LeftSelectList,RightSelectList"/>
                </td>
                <td>
                    <apex:selectList size="5" multiselect="true" value="{!RightSelectedValues}" id="RightSelectList">
                        <apex:selectOptions value="{!RightSelectList}"/>
                    </apex:selectList>
                </td>
 
            </tr>
        </table>
 
    </apex:pageBlock>
</apex:form>
</apex:page>

 

Please help!

 

Thank you :)

 

R

Hi,

 

I have few questions:

 

Is it possible to display the reports and dashboards in the visualforce page? If yes, can anybody provide me with some refernce.

 

Is it possible to mail the Reports and dashboards?  If yes, then who can be the reciepients. Is it only the salesforce users present in the org. or can we provide any email address?

 

How can we show reports and dashboards in a section of an objects page layout or in the related lists of the object?

 

Thanks.

hi all

 

We have a Registration object that hangs off Location Accounts.  Field on registration is called Billing Account.

 

All our accounts should have a Parent Account, however, users keep creating Registrations on Location Accounts, OR Parent Accounts.

 

We are trying to cause an error message to occur when someone tries to submit a Registration that is:

a. attached to a Parent Account; or

b. attached to a Location Account that has no Parent Account.

 

When we use Force.com explorer and query thusly:

 

 

select Billing_Account__r.ParentId from Registration__c 
where Billing_Account__r.ParentId = ''

 We get the desired result.

 

 

But when we try to call it in the following code,

 

alert("{!Registration__c.Billing_Account__r.ParentId}");

 it tells us

Error: Field Registration__c.Billing_Account__r.ParentId does not exist. Check spelling.

 

We get the same error whatever field on that Billing Account we are trying to access.

 

 

What are we doing wrong?

 

Thanks so much for all your help. :)

 

Is there a way to populate a multiselect pick list via workflow rules.  If it was a text field I would be able to say if record type = x then populate field with y.

 

If not does anyone know an alternative method of accomplishing the same thing.

 

David