visualforce interface - salesforce

hi i want to create an interface like this in visualforce
where values in first column will come from apex controller
please give some idea of doing this in visualforce.Also the values which user will move to second column will be saved somewhere.I am thinking of using custom settings,what all are the options available.
Thanks

Unfortunately the only way to leverage the functionality that you're describing in VisualForce is to use an <apex:inputField> tag that binds to a multi-picklist field on an SObject. This option gives you a place to save the data, although you will need to specify the possible values beforehand in the configuration (which it doesn't sound like you want to do).
If you want to populate the values dynamically, you will need to create a list of SelectOptions in your controller and bind that list to an <apex:selectlist> tag with the multiselect attribute set (keep in mind that this won't give you the fancy left and right arrows that you showed in your screenshot, but it will allow a user to select multiple options by shift/ctrl-clicking).
VisualForce snippet:
<apex:selectList value="{!multiPicklistVal}" multiselect="true">
<apex:selectOptions value="{!multiPicklistOptions}"/>
</apex:selectList>
Apex controller snippet:
public String[] multiPicklistVal {public get; public set;}
public List<SelectOption> getMultiPicklistOptions() {
List<SelectOption> opts = new List<SelectOption>();
opts.add(new SelectOption('Red', 'Red'));
opts.add(new SelectOption('Green', 'Green'));
opts.add(new SelectOption('Blue', 'Blue'));
return opts;
}
This approach will allow you to reference multiPicklistVal in your action methods as an array of Strings, each of which have been selected by the user. From here, you could save these in a custom setting as you mentioned, or in a custom object (but if you're going to go the custom object route, you may as well just use the out-of-the-box functionality I described at the top of this post).

Related

View with small modifications for different types of article

I have one view for a type of article, I need to extends this view and if user open article type "Special" I need to show some new fields in this view.
I don't want to create a separate view for this type of form because differs only one field.
Also I need to save in database, in field "type" one different value if "Special" article is saved.
Please suggest me how I can do this.
Well, you should simply use a if statement in your view to display, or not, additional fields, and use beforeSave method in your model to handle your type attribute.
protected function beforeSave()
{
// if ('Special' article)
// $this->type = 'value';
parent::beforeSave();
}
You should also consider using scenario.
I resolved this by adding a public variable in Article model, in controller I set the variable with one string, and on view I verify this string.

How to Know in Apex Report is related to which object

i am trying to access the Report objects in apex but getting limited fields my apex source code is
public Class MyController{
public List<Report> getReports(){
List<Report> rep1 = new List<Report>();
rep1=[Select Id,Developername,Description,Name,OwnerId from Report];
return rep1;
}
}
but i want to get the value of the sObject type to which it is related to for example
1.i click on new Report
2.then select Opportunities
3.then click create
how to get this opportunity object and how to get filters applied to reports please explain it.
Unfortunately, you won't be able to get that information. According to Salesforce's doc that information isn't available via their API. Check out all the fields available here: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_report.htm

Can the Salesforce multi-select picklist be used for arbitrary data and not just sObjects?

I think I might be missing something, but I can't see how to use the built in multi-select picklist control for anything but sObject fields.
I'm talking about the control which features 2 list objects marked "Available" and "Selected" with arrows inbetween to moving items between the lists. This control is an easier and more discoverable way for a user to select several items then the selectList control, which needs Shift and Ctrl to select multiple items.
Page with pictured example
With a selectList I don't need a specific sObject - I can store the users selection in one off my controllers members, and I can even create a method to provide a list of valid values - this method could be hard coded, dynamically calculated or even use a query to lookup some live data.
Is there a way to use the fancy picklist control, only without any reference to a specific sObject, just a list of string values?
Unfortunately, the only way to use any of the standard field types, e.g., dates or multi-select picklists, is to have the field be backed by an SObject.
For me, when it becomes necessary to use these kinds of fields on a Visualforce page, I will create an Object specifically for the purpose of providing a back-end for the fields. In the Apex Controller, simply instantiate your Object (no need to supply any values) and reference that object's fields on the page.
While this may seem a little inefficient from the configuration side, it has a number of added benefits such as using the default UI (automatically subject to any improvements made by SFDC) and utilizing any built in validation.
If you are dead-set on not having the field be backed by an SObject, there might be some jquery multi-select options available. I've seen a lot around but haven't really tested any.
in your class:
public List<SelectOption> getStoryItems()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('SAM','Sam I Am'));
options.add(new SelectOption('GEORGE','George of the Jungle'));
options.add(new SelectOption('DORA','Dora the Explorer'));
return options;
}
String[] stories= new String[]{};
public String[] getStories()
{
return stories;
}
public void setStories(String[] stories)
{
this.stories= stories;
}
in your page:
<apex:selectList value="{!stories}" multiselect="true">
<apex:selectOptions value="{!getStoryItems}"/>
</apex:selectList>
The results will be comma delimited, if you don't want multiple select, just set multiselect to false

Custom Button to copy data from Opportunity into a related custom object

I have a custom object that is used for product setup that is mapped to an opportunity. It's a one to many relationship - one opportunity maps to many setup objects, but one setup object is only mapped to one opportunity.
Opportunity has some setup fields that need to act as defaults for the related custom object. Unfortunately, I cannot just specify them in a formula - getting an error.
What I would like to do is have a custom button that would allow user to click and copy all of the related setup fields from the opportunity into the custom setup object and then edit them as needed.
Any pointers or sample code are greatly appreciated!
You can achieve this with a custom button on the related list for your custom object on the opportunity detail page.
All of the fields on a standard Salesforce new/edit screen have id's associated with them. You can specify values for fields by using these ids to set GET parameters on your URL. For example if the id on the name field on your opportunity is 'opp3', the following URL will populate the name field on your new opportunity page:
https://na2.salesforce.com/006/e?opp3=Hello+World
You would have to change na2 to the correct server for your org.
The new record page URL contains the 3 character id prefix for your particular object and then '/e'. 006 is the prefix for opportunities. You will have to attempt to create a new record to see what the 3 characters are for your custom object.
You will have to capture the id's of the fields you want to populate on your custom object. You can do this by viewing the source of the new record page. For custom fields these id's will take the form of a Salesforce Id (eg. 00N40000002QhEV).
Create a new list button on your custom object and set the behavior to without header and sidebar and set the source to URL. Build up your URL with id=value pairs separated by '&' using the id you got from the page source and the insert field functionality to select the opportunity fields your wish to add in. You should end up with something like this:
/a0U/e?00N40000002QhEV={!Opportunity.Name}&00N40000002QhEW={!Opportunity.StageName}
a0U should be replaced by the correct prefix for your custom object. Then add your button to the related list for your custom object under opportunity.

Salesforce SoftPhone - Relate Call to Records in Two Different Objects

I am trying to relate phone calls to multiple records in Salesforce. The records are in two different custom objects, but you can think of the records like a Lead or an Opportunity. Our salespeople call multiple people (Leads) for given Opportunities, and I'd like to capture both pieces of information.
Is this possible in Salesforce? My current layout has a "Related To" tab that populates when you navigate to a given record, but it forces you to choose one record before auto-saving. Is it possible to have a format that maps the Activity generated by the call to multiple records?
This could be a format with multiple drop-down "Relate To" menus. Better yet, I could use a field that allows you type a record number in to to a free-response field to relate it to an Opportunity.
Thanks!
Austin
P.S. We are running Salesforce Professional with API. We are using a CTI adapter from BroadSoft.
I don't know the BroadSoft adapter and I couldn't find it on Salesforce AppExchange to give it a test run. But assuming it's a typical plugin for Salesforce, you'll have little control over it (i.e. cannot add a helper junction object that would act like many-to-many relationship bridge).
You should have no problems writing a piece of Visualforce to suit your needs though (especially the later requirement - use some text filter to display list that matches this filter).
I'll write a quick example. My business requirement for the sake of this example is "I want to show all Activities whose Subject field matches text I've put on new field in Opportunity, regardless whether they are linked or not. This should appear as similar to normal related list on Opportunity".
Add text field called "record" to your Opportunity object.
Create an Apex class:
public class AustinTest {
private Opportunity o;
public AustinTest(ApexPages.StandardController controller) {}
public List<Event> getActivities() {
Opportunity o = [SELECT Id, Record__c
FROM Opportunity
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
String searchTerm = '%' + o.Record__c + '%';
return [SELECT Id, Subject, Type FROM Event WHERE Subject LIKE :searchTerm];
}
}
Create a Visualforce Page:
<apex:page standardController="Opportunity" extensions="AustinTest">
<apex:pageBlock>
<apex:pageBlockTable value="{!activities}" var="a">
<apex:column value="{!a.Id}" />
<apex:column value="{!a.Subject}" />
<apex:column value="{!a.Type}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Go to the Page Layout editor for Opportunities and drop the Visualforce somewhere on the page. We have to drop it in the "detail" area (like normal fields, not like Related Lists), that's fine for now.
Experiment with it, decide if it's worth spending time on. With extra bit of tweaking we can make it display similar to normal Related List. I'll write more if needed. How would you like to have this list of matching records accessible anyway? As a separate tab? Related List? Something else?
Is it possible to have a format that maps the Activity generated by the call to multiple records? This could be a format with multiple drop-down "Relate To" menus.
The most concise answer: no. The drop down list and association is not modifiable.
There are ways to do this, but it requires either customization, eyescream post- it has some great info on how to do that. And you may need your CTI vendor to do portions of the customization.
Note: make sure you use CTI 2.0+ (preferably CTI 3.0+). This has lots of improved features for improving call logging and handling. See the wiki here:
http://wiki.developerforce.com/index.php/CTI_Toolkit
Are the calls stored in their own object? If so, you could add lookup fields that look up to each object you want to link to the call. If the calls aren't saved in their own object, I would recommend using a custom object to store them in as separate records. You can use lookup fields to link them to whatever objects you want, and you can display them as items in a related list on the record pages of those objects.
As an example, say I have a custom object called "Calls". The object would contain the following fields:
Call name (text field)
Opportunity (lookup field)
Lead (lookup field)
etc...
Then you can add a "Calls" related list to both Opportunities and Leads, and all call records that look up to that Lead or Opportunity record will be displayed in the list on both records.
Hope this helps!

Resources