You need to sign in to do that
Don't have an account?
is it possible to save Picklist values in a Look Up Field?
Name | Text(80) |
child_item__c | Lookup(Item relation) |
parent_item__c | Lookup(Item relation) |
<apex:page controller="CreateMulItem" sidebar="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save Task" action="{!Save}" />
</apex:pageBlockButtons>
<apex:commandButton value="Save" action="{!Save}" />
</apex:pageBlockButtons> -->
<apex:pageBlockSection title="Create Items" >
<apex:outputLabel Value="Item Name" style="margin-left:10%;position:relative;top:10px;font-weight:bold" >
<apex:selectList value="{!ItemTemp}" size="1" >
<apex:selectOptions value="{!Itemname}"/>
</apex:selectList>
</apex:outputLabel>
</apex:pageBlockSection>
<apex:outputlabel value="Create New Item" for="newval" style="margin-left:4%;position:relative;top:20px;font-weight:bold" />
<apex:inputText value="{!newpicklistvalue}" id="newval" style="margin-left:4%;position:relative;top:15px;font-weight:bold" />
<apex:commandbutton action="{!saverec}" value="Add Item!" style="margin-left:4%;position:relative;top:15px;font-weight:bold" />
<apex:pageBlockSection title="Add parent and child Item">
<apex:outputLabel Value="Parent Items" style="margin-left:10%;position:relative;top:10px;font-weight:bold" >
<apex:selectList value="{!ParentTemp}" size="3" multiselect="true" >
<apex:selectOptions value="{!ParentItem}"/>
</apex:selectList>
</apex:outputLabel>
<apex:outputLabel Value="Child Items " style="margin-Right:1%;position:relative;top:10px;font-weight:bold" >
<apex:selectList value="{!ChildTemp}" size="3" multiselect="true" >
<apex:selectOptions value="{!ChildItem}"/>
</apex:selectList>
</apex:outputLabel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
public with sharing class CreateMulItem{
// Declare variables
public String ParentTemp { get; set; }
public String ChildTemp { get; set; }
public String ItemTemp{get; set;}
// Load Parent Items
public List<SelectOption> getParentItem() {
List<SelectOption> options = new List<SelectOption>();
for(Item_relation__c Itemrelation :[Select id,Name,parent_item__c,child_item__c from Item_relation__c ]){
options.add(new SelectOption(Itemrelation.id,Itemrelation.name));
}
return options;
}
// Load Child Items
public List<SelectOption> getChildItem() {
List<SelectOption> options = new List<SelectOption>();
// options.add(new SelectOption('--None--','--None--'));
for(Item_relation__c Itemrelation :[Select id,Name,parent_item__c,child_item__c from Item_relation__c ]){
options.add(new SelectOption(Itemrelation.id,Itemrelation.Name));
}
return options;
}
// Load Child Items
public List<SelectOption> getItemname() {
List<SelectOption> options = new List<SelectOption>();
// options.add(new SelectOption('--None--','--None--'));
for(Item_relation__c Itemrelation :[Select id,Name,parent_item__c,child_item__c from Item_relation__c where Name != 'None' ]){
options.add(new SelectOption(Itemrelation.id,Itemrelation.Name));
}
return options;
}
public String newpicklistvalue{get; set;}
public void saverec()
{
Item_relation__c newrec = new Item_relation__c(name = newpicklistvalue);
insert newrec;
newpicklistvalue=NULL;
}
// Save Item Relations
public List<Item_relation__c> saverelations {get; set;}
public PageReference Save() {
Item_relation__c Sitems = new Item_relation__c();
Sitems =[select id,name, parent_item__c,child_item__c from Item_relation__c where id =: ItemTemp];
Sitems.parent_item__c = ParentTemp;
Sitems.child_item__c = ChildTemp;
update Sitems;
PageReference parrec = new PageReference('https://ap1.salesforce.com/a0A/o');
parrec.setRedirect(true);
return parrec;
}
}
You mean Making a picklist a lookup field?
if that is the case, if you are on EE or UE then you can use the ApexDataLoader to do a lot of the heavy lifting for you.
Now with that being said, there is still going to be a little bit of Admin-ish/Develoer-ish stuff that needs to be done. But if I can figure this stuff out, then pretty much anyone (and probably a few of the higher order of Primates) can do it.
let me know if this works, or if you have any questions.
You can't. You need to use a picklist (multi-select) field to store multiple picklist values.
If you want to store multiple lookup values, you can either create multiple lookup fields - which I don't recommend - or a child object and related list.
Hope this helps,