You need to sign in to do that
Don't have an account?
azu.shaik1.3965080575576013E12
Urgent fix :when page loads the picklist value should need to be same as the formula field in same record
when the page loads the piclist value should be same formula field .
i have to display the data from two different objects i consist of formula fiels and the picklist value here i need keep the picklist value basedon the formula i differes for every record here mycode can someone can help will be appericate more
/
public List<SelectOption> getUnitOrders() {
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult = Catalog__c.Units__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}
// Constructor load the inventory Items to page based on the user profile
Public PlaceNeworders(){
theOrder =new Order__c();
inventoryList = new List<wrapNewOrder> ();
User lgdUsr=[select id,name ,Distributor__c,profileId from User where id=:UserInfo.getUserId()];
string profileName=[Select Id,Name from Profile where Id=: lgdUsr.profileId].Name;
inventoryList = new List<wrapNewOrder> ();
if(profileName == 'System Administrator'){
invItems = [SELECT Id,Cut_and_Size__c,Fresh_Frozen__c,Quantity_Available__c,Species__c,Price_per_Unit__c,Units__c FROM Inventory_Item__c where Quantity_Available__c > 0];
}
else{
invItems = [SELECT Id,Cut_and_Size__c,Fresh_Frozen__c,Quantity_Available__c,Species__c,Price_per_Unit__c,Units__c FROM Inventory_Item__c where Distributor_Name__c =: lgdUsr.Distributor__c AND Quantity_Available__c > 0];
}
for(Inventory_Item__c a: invItems) {
// As each Order is processed we create a new wrapAddOrder object and add it to the inventoryList
inventoryList.add(new wrapNewOrder(a));
}
System.debug(' Print enter'+inventoryList);
}
// Insert the order and order items
public PageReference confirmNewOrder() {
if(theOrder.id==null){
theOrder.Buyer__c = selectedRestaurantId;
theOrder.Requested_Delivery_Date__c = datename ;
insert theOrder;
system.debug('TheOrder inserted'+theOrder);
}
List<Order_Item__c> items = new List<Order_Item__c>();
for(wrapNewOrder wno : inventoryList) {
if(wno.selected==false){
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.FATAL,'Please select atleast one item');
ApexPages.addMessage(msg);
}
if(wno.selected == true) {
Order_Item__c oItem = new Order_Item__c();
oItem.Amount_Ordered__c = wno.amount;
oItem.Comments__c = wno.splInstructions;
oItem.Desired_Units__c = wno.selectDesiredUnit;
system.debug('@@oItem.Desired_Units__c'+oItem.Desired_Units__c);
oItem.Order__c = theOrder.Id;
oItem.Inventory__c = wno.invItem.Id;
items.add(oItem);
System.debug('Print Amount'+wno.amount);
System.debug('Print SpL'+wno.splInstructions);
System.debug('Print id'+theOrder.Id);
}
}
if(items.size()>0){
insert items;
System.debug(' -------item----------- '+ items);
PageReference orderPage = new PageReference('/apex/'+'/OrderFulfillment2?sfdc.tabName=01rF0000000VOWh');
orderPage.setRedirect(false);
return orderPage;
}
return null;
}
public PageReference Cancel() {
PageReference orderItemPage = new PageReference('/apex/'+'/OrderFulfillment2?sfdc.tabName=01rF0000000VOWh');
orderItemPage.setRedirect(true);
return orderItemPage;
}
// This is our wrapper/container class.
public class wrapNewOrder {
public Inventory_Item__c invItem {get; set;}
public Boolean selected {get; set;}
public String splInstructions { get; set; }
public Decimal amount { get; set; }
Public String selectDesiredUnit{get; set;}
public wrapNewOrder(Inventory_Item__c a) {
this.invItem = a;
this.selected = false;
}
}
}
i have to display the data from two different objects i consist of formula fiels and the picklist value here i need keep the picklist value basedon the formula i differes for every record here mycode can someone can help will be appericate more
/
public List<SelectOption> getUnitOrders() {
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult = Catalog__c.Units__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}
// Constructor load the inventory Items to page based on the user profile
Public PlaceNeworders(){
theOrder =new Order__c();
inventoryList = new List<wrapNewOrder> ();
User lgdUsr=[select id,name ,Distributor__c,profileId from User where id=:UserInfo.getUserId()];
string profileName=[Select Id,Name from Profile where Id=: lgdUsr.profileId].Name;
inventoryList = new List<wrapNewOrder> ();
if(profileName == 'System Administrator'){
invItems = [SELECT Id,Cut_and_Size__c,Fresh_Frozen__c,Quantity_Available__c,Species__c,Price_per_Unit__c,Units__c FROM Inventory_Item__c where Quantity_Available__c > 0];
}
else{
invItems = [SELECT Id,Cut_and_Size__c,Fresh_Frozen__c,Quantity_Available__c,Species__c,Price_per_Unit__c,Units__c FROM Inventory_Item__c where Distributor_Name__c =: lgdUsr.Distributor__c AND Quantity_Available__c > 0];
}
for(Inventory_Item__c a: invItems) {
// As each Order is processed we create a new wrapAddOrder object and add it to the inventoryList
inventoryList.add(new wrapNewOrder(a));
}
System.debug(' Print enter'+inventoryList);
}
// Insert the order and order items
public PageReference confirmNewOrder() {
if(theOrder.id==null){
theOrder.Buyer__c = selectedRestaurantId;
theOrder.Requested_Delivery_Date__c = datename ;
insert theOrder;
system.debug('TheOrder inserted'+theOrder);
}
List<Order_Item__c> items = new List<Order_Item__c>();
for(wrapNewOrder wno : inventoryList) {
if(wno.selected==false){
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.FATAL,'Please select atleast one item');
ApexPages.addMessage(msg);
}
if(wno.selected == true) {
Order_Item__c oItem = new Order_Item__c();
oItem.Amount_Ordered__c = wno.amount;
oItem.Comments__c = wno.splInstructions;
oItem.Desired_Units__c = wno.selectDesiredUnit;
system.debug('@@oItem.Desired_Units__c'+oItem.Desired_Units__c);
oItem.Order__c = theOrder.Id;
oItem.Inventory__c = wno.invItem.Id;
items.add(oItem);
System.debug('Print Amount'+wno.amount);
System.debug('Print SpL'+wno.splInstructions);
System.debug('Print id'+theOrder.Id);
}
}
if(items.size()>0){
insert items;
System.debug(' -------item----------- '+ items);
PageReference orderPage = new PageReference('/apex/'+'/OrderFulfillment2?sfdc.tabName=01rF0000000VOWh');
orderPage.setRedirect(false);
return orderPage;
}
return null;
}
public PageReference Cancel() {
PageReference orderItemPage = new PageReference('/apex/'+'/OrderFulfillment2?sfdc.tabName=01rF0000000VOWh');
orderItemPage.setRedirect(true);
return orderItemPage;
}
// This is our wrapper/container class.
public class wrapNewOrder {
public Inventory_Item__c invItem {get; set;}
public Boolean selected {get; set;}
public String splInstructions { get; set; }
public Decimal amount { get; set; }
Public String selectDesiredUnit{get; set;}
public wrapNewOrder(Inventory_Item__c a) {
this.invItem = a;
this.selected = false;
}
}
}
Need some more information regarding the use case here,
What are the significant fields?
Are These fields part of the same Object ?
How is the Other Object related to this object?
What is the formula in the formual field?
Are you getting any errors while compiling the code?
a picklist field can be updated the same way as a plain text field.
after you queried for the tasks, create a loop to go through them.
in the loop just do
task.Status = 'new status' ;
and after going through the loop, update the set of tasks.
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008z93IAA
Regards,
Ashish