• MJRDeveloper
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies

The Web Services API Developers Guide says the following...

 

Use the BusinessProcess object to offer different subsets of picklist values to different users for the LeadStatus, CaseStatus, and OpportunityStage fields. Similar to a RecordType, a BusinessProcess identifies the type of a row in a Case, Lead, or Opportunity and implies a subset of picklist values for these three fields. The values for the remaining picklist fields are driven off of RecordType.

 

What it doesn't give is an EXAMPLE of HOW we can use the BusinessProcess object to determine the subset of picklist values. Can I get some guidence on this one?

I am trying to develop a custom component that will search on any field on an object, and I would like to do it without using any java code. I am really close. I've used a VF popup based on code from TehNrd and managed to get the component controller and the VF page controller talking to each other. The issue I am having is with the selectoption on the popup. It is being populated with a string array passed into the custom component. When I do the AssignTo="{!myList}" in the attribute, the go button and the close button on the popup work fine. When I do the assignto, they don't work. Any thoughts?

 

Custom Component

 

 

<apex:component controller="searchcomponentcontroller" >
  <apex:attribute name="pageController" 
      type="PageControllerBase" 
      assignTo="{!pageController}" 
      required="true" 
      description="The controller for the page." />
<apex:attribute description="" name="label" type="String" required="true"/>
<apex:attribute description="" name="Searchby" type="String[]" required="true" AssignTo="{!myList}"  />

<apex:outputlabel for="intxt" value="{!label}"/>
<apex:inputtext id="intxt" value="{!initValue}"/>
<img id="imglead" src="/s.gif"
class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" 
onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" 
onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onClick="showPopup()"></img>
<apex:actionfunction name="showPopup" action="{!showpopup}" rerender="popup"/>

<apex:outputPanel id="popup">
<apex:outputPanel styleClass="customPopup" layout="block" rendered="{!displayPopUp}">           
<div align="Right"><apex:commandButton value="X" action="{!closepopup}" rerender="popup"/></div>
<apex:sectionHeader title="Lookup" /><br/>
<apex:outputPanel id="searchmaterial" layout="block" rendered="true">
                <apex:outputLabel value="Search: " for="txtsearch" StyleClass="labelCol"/>
                <apex:inputText value="{!searchtext}" id="txtsearch"/>
                <apex:outputlabel for="Options" Value=" by: "/>
                <apex:selectList id="Options" value="{!selectedOption}" size="1" >
                    <apex:selectOptions value="{!Options}" />
                </apex:selectList>
<apex:Commandbutton Value="Go" action="{!updateValue}" />
<div style="overflow:auto; width:?px; height:?px"><br/>
</div>               
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>
  
     <style type="text/css">
       .customPopup{
            background-color: white;
            border-style: solid;
            border-width: 2px;
            left: 50%;
            padding:10px;
            position: absolute;
            z-index: 9999;
            /* These are the 3 css properties you will need to tweak so the pop 
            up displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can also add 
            the height property for a fixed size pop up.*/
            width: 800px;
            height: 400px;
            margin-left: -400px;
            top:100px;
        }
    </style>
</apex:component>

 

Custom Component Controller

 

public with sharing class searchcomponentcontroller extends componentcontrollerbase{  

  public String myValue = '';
  public string[] OptionList;
  public List<SelectOption> Options;
  boolean displaypopup;
  public void selectedoption{get; set;}
  public String searchtext{get;set;}
    
  public String getInitValue() {return myValue; }
  public void setInitValue(String s){myValue = s;}
  
  public void updateValue() {myvalue = searchtext; }
  
  public void setdisplaypopup(boolean b){displaypopup = true;}
  public Boolean getdisplaypopup(){return displaypopup;}
  public void showpopup(){displaypopup = true;}
  public void closepopup(){displaypopup = false;}

  public List<SelectOption> getOptions(){return Options;}
  
  public void setmyList(String[] sa){
  OptionList = sa;  
  Options = new List<SelectOption>();
  for(integer i=0; i<sa.size(); i++){
  Options.add(New SelectOption(sa[i],sa[i]));}
  }

  public String[] getmyList(){ return OptionList;}
 
}

 

 

VF Page

 

<apex:page controller="MattTestController" >
<apex:form >
<c:CustomSearch pageController="{!this}" Searchby="{!filterlist}" label="My Label: "/>
</apex:form>
</apex:page>

 

 

Page Controller

 

public with sharing class MattTestController extends pagecontrollerbase {

  public searchcomponentcontroller myComponentController { get; set; }
    
  public override void setComponentController(ComponentControllerBase compController) {
    myComponentController = (searchcomponentcontroller)compController;
  }
    
  public override ComponentControllerBase getMyComponentController() {
    return myComponentController;
  }
  
  public String[] getfilterlist(){
      String[] s = new String[]{'This','That'};
      return s;      
  }
}

 

 

PageControllerBase

 

public with sharing virtual class PageControllerBase {
    
  private ComponentControllerBase myComponentController;
    
  public virtual ComponentControllerBase getMyComponentController() {
    return myComponentController;
  }

  public virtual void setComponentController(ComponentControllerBase compController) {
    myComponentController = compController;
  }
    
  public PageControllerBase getThis() {
    return this;
  }
    
}

 

 

 

ComponentControllerBase

 

 

public with sharing virtual class ComponentControllerBase {
  public PageControllerBase pageController { get; 
    set {
      if (value != null) {
    pageController = value;
    pageController.setComponentController(this);
      }
    }
  }
}

 

 

 

 

 

 

I know I have seen a solution using java, but I want to avoid that if possible. I created a visualforce page that uses the standard controller for the account object. It uses action to call the mypage function, which returns a pagereference.

 

<apex:page standardcontroller="account" extensions="recordtypeforwarderextension" action="{!mypage}"/>
 
 

 

public with sharing class recordtypeforwarderextension {    
public recordtypeforwarderextension(ApexPages.StandardController controller) {}        

public pagereference mypage(){return page.RT2;}    
}

 

Right now, the controller is not checking for record type. I just want to get the forwarder to forward properly. The issue that I have is that the forwarder page and RT2 both use the standard controller for the account object. When  I change RT2 to use a standard controller for any other object,, like Contact, the forwarder works. When both use the standard controller for Account, it doesn't. Any ideas? RT2 is just a dummy page. The code I am using is below. If I can get this to work, I can have the mypage function look at the Record Type and if it is the right one, it will go to the visualforce edit page. If it is any other record type, it will forward to the standard salesforce editor. Thanks!

 

<apex:page standardController="account">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page: rt2
  <!-- End Default Content REMOVE THIS -->
</apex:page>
		

 

I am getting thefollowing error when trying to insert a new custom object called bid__c. bid__c is essentially a collection of objects called bid_item__c. A master-detail relationship exists between bid and bid_item. New bid items require a reference to a bid. That is the only required field. Any help is appreciated.

 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Bid__c]: [Bid__c]

Class.bid_ext.additem: line 27, column 29 External entry point 

 

 

public pagereference additem(){ bid_item__c b = new bid_item__c(); b.setbid__c(bid); insert b; return null; }

 

 

 

 

 

Ok, I am stuck. I am working on a wizard to create a custom lead object. I've posted the entire VF page and controller extension. I can't figure out why the getaccount() function is not returning the account specified by the hidden inputfield on the visualforce page. Any help is appreciated. 

 

Here is the VF page:

 

<apex:page standardcontroller="My_Lead__c" extensions="myLeadExtension">

<apex:sectionHeader title="New Lead Capture" />

<apex:form >

<apex:pageBlock title="Page 1">

<apex:facet name="footer">

<apex:outputPanel id="footerbtn">

<apex:commandButton action="{!step1}" value="Back" styleClass="btn"/>

<apex:commandButton action="{!save}" value="Save" styleClass="btn"/>

</apex:outputPanel>

  </apex:facet>

<apex:inputField id="accountNum" value="{!mylead.Account__c}" rendered="false"/>

<apex:pageBlockSection title="Account Information">

<apex:pageblocksectionitem >

<apex:outputlabel for="anum" value="Account Number"/>

<apex:outputfield id="anum" value="{!account.accountnumber}"/>

</apex:pageblocksectionitem>

<apex:pageblocksectionitem >

<apex:outputlabel for="aphone" value="Account Phone"/>

<apex:outputfield id="aphone" value="{!account.phone}"/>

</apex:pageblocksectionitem>

<apex:pageblocksectionitem >

<apex:outputlabel for="aname" value="Account Name"/>

<apex:outputfield id="aname" value="{!account.name}"/>

</apex:pageblocksectionitem>

</apex:pageblocksection>

 

<apex:pageBlockSection title="Select Contact">

<apex:pageblocksectionitem >

<apex:outputlabel for="cname" value="Contact Name"/>

<apex:selectList id="cname" size="1" value="{!myobj.contact}">

<apex:selectoption itemLabel="-Select One-" itemValue="-Select One-"/>

<apex:selectoptions value="{!contactname}"></apex:selectoptions>

<apex:actionSupport event="onchange" rerender="details"/>

</apex:selectList>

</apex:pageblocksectionitem>

<apex:pageblocksectionitem >

<apex:commandButton action="{!newcontact}" value="New Contact" styleClass="btn"/>

</apex:pageblocksectionitem>

</apex:pageblocksection>

<apex:pageblocksection id="details" title="Contact Details">

<apex:pageblocksectionitem >

<apex:outputlabel for="cphone" value="Contact Phone"/>

<apex:outputfield id="cphone" value="{!selectedcontact.phone}"/>

</apex:pageblocksectionitem>

</apex:pageblocksection>

<apex:pageblockSection title="Lead Information">

<apex:pageblocksectionitem >

<apex:panelGrid columns="4">

<apex:outputlabel value="Product" for="prod" />

<apex:inputtext id="prod" value="{!mylead.myproduct__c}"/>

<apex:outputlabel value="Quantity" for="qty"/>

<apex:inputtext id="qty" value="{!mylead.Quantity__c}"/>

<apex:outputlabel value="In Stock" for="is"/>

<apex:selectList id="is" value="{!mylead.In_Stock__c}" size="1">

<apex:selectoption itemLabel="No" itemValue="No"/>

<apex:selectoption itemLabel="Yes" itemValue="Yes"/>

</apex:selectlist>

<apex:outputlabel value="Sample Requested" for="sample"/>

<apex:selectList id="Sample" value="{!mylead.Sample__c}" size="1">

<apex:selectoption itemLabel="No" itemValue="No"/>

<apex:selectoption itemLabel="Yes" itemValue="Yes"/>

</apex:selectList>

</apex:panelgrid>

</apex:pageblocksectionitem>

</apex:pageblocksection>

<apex:pageblocksection >

<apex:pageblocksectionitem >

<apex:panelGrid columns="2" width="100%">

<apex:outputlabel value="End Use" for="end"/>

<apex:inputTextarea id="end" cols="60" rows="5" value="{!mylead.End_Use__c}"/>

<apex:outputlabel value="Notes" for="notes"/>

<apex:inputTextarea id="nots" cols="90" rows="10" value="{!mylead.notes__c}"/>

</apex:panelgrid>

</apex:pageblocksectionitem>

</apex:pageblockSection>

</apex:pageblock>

</apex:form>

</apex:page> 

 

 


And the controller:

public with sharing class myLeadExtension {

My_Lead__c newLead = new My_Lead__c();

String accountnum;

myObj my_obj = new myobj();

public myLeadExtension(ApexPages.StandardController controller) { }

 

public class myObj{

string account = null;

string contact = null;

contact c = new contact();

account a = new account();

 

public contact getcontactobj(){return c;}

public void setcontactobj(contact data){c = data;}

 

public account getaccountobj(){return a;}

public void setaccountobj(account data){a = data;}

 

public string getaccount(){return account;}

public void setaccount(string data){account = data;}

 

public string getcontact(){return contact;}

public void setcontact(string data){contact = data;}

}

 

public myObj getmyObj() {

if (my_obj == null) { my_obj = new myObj(); }

return my_obj;

}

 

public my_lead__c getmylead(){return newLead;}

 

public void setmylead(my_lead__c data){ newlead = data;}

 

public Account getAccount() {

list<account> a = [SELECT name, accountnumber, phone FROM account where id = :newlead.account__c limit 1 ];

if(a.size() != 0) {my_obj.a = a[0];}

return my_obj.a;

}

 

public list<selectoption> getContactName() {

string selectedaccount = my_obj.a.accountnumber;

list<contact> c = [SELECT name FROM contact where Account.accountnumber = :selectedaccount order by lastname];

List<SelectOption> option = new List<SelectOption>();

 

for(integer i=0; i < c.size(); i++) {

option.add(new SelectOption(c[i].name,c[i].name));}

 

return option;

}

 

public contact getselectedcontact(){

string scontact = null;

string sAccount = my_obj.a.accountnumber;

if (my_obj != null){ scontact = my_obj.contact;}

else{ scontact = 'test';}

 

list<contact> c = [SELECT name,phone,firstname,lastname, fax, email FROM contact where Account.accountnumber = :saccount and name = :scontact limit 1];

 

if(c.size() != 0) {my_obj.c = c[0];}

else{return new contact();}

return my_obj.c;

}

 

public String getAcctNum(){ return accountNum; }

public void setAcctNum(String a){ accountNum = a;}

 

public PageReference step1() { return Page.MyLeadsPG1; }

public PageReference step2() { return Page.myLeadspg2; }

public PageReference step3() { return Page.MyLeadsPG3; }

 

public PageReference newcontact() {

my_obj.c = new contact();

return Page.MyLeadsContact; }

 

public PageReference save() {

newlead.account__c = my_obj.a.id;

newlead.contact__c = my_obj.c.id;

insert newLead;

PageReference redirectPage = new PageReference('/' + newLead.ID);

return redirectPage;

}

 

public pagereference savecontact(){

my_obj.c.accountid = my_obj.a.id;

insert my_obj.c;

my_obj.contact = my_obj.c.name;

return page.MyLeadsPG2; }

 

 

 
 
Message Edited by MJRDeveloper on 06-28-2009 02:07 PM

Hi. Long time reader, first time poster. I am having a problem associating a contact object with an account object in my custom controller extension. I have two objects, a contact and an account. I am creating a new contact and want it associated with the active account. When the contact gets inserted, it has all of the correct information (name, phone, ect.), but the account field is empty. I've posted the insert function here. Any help is appreciated.

 

 

public pagereference savecontact(){ my_obj.c.account = my_obj.a; insert my_obj.c; return page.MyPagePG2; }

 

The Web Services API Developers Guide says the following...

 

Use the BusinessProcess object to offer different subsets of picklist values to different users for the LeadStatus, CaseStatus, and OpportunityStage fields. Similar to a RecordType, a BusinessProcess identifies the type of a row in a Case, Lead, or Opportunity and implies a subset of picklist values for these three fields. The values for the remaining picklist fields are driven off of RecordType.

 

What it doesn't give is an EXAMPLE of HOW we can use the BusinessProcess object to determine the subset of picklist values. Can I get some guidence on this one?

I know I have seen a solution using java, but I want to avoid that if possible. I created a visualforce page that uses the standard controller for the account object. It uses action to call the mypage function, which returns a pagereference.

 

<apex:page standardcontroller="account" extensions="recordtypeforwarderextension" action="{!mypage}"/>
 
 

 

public with sharing class recordtypeforwarderextension {    
public recordtypeforwarderextension(ApexPages.StandardController controller) {}        

public pagereference mypage(){return page.RT2;}    
}

 

Right now, the controller is not checking for record type. I just want to get the forwarder to forward properly. The issue that I have is that the forwarder page and RT2 both use the standard controller for the account object. When  I change RT2 to use a standard controller for any other object,, like Contact, the forwarder works. When both use the standard controller for Account, it doesn't. Any ideas? RT2 is just a dummy page. The code I am using is below. If I can get this to work, I can have the mypage function look at the Record Type and if it is the right one, it will go to the visualforce edit page. If it is any other record type, it will forward to the standard salesforce editor. Thanks!

 

<apex:page standardController="account">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page: rt2
  <!-- End Default Content REMOVE THIS -->
</apex:page>
		

 

I am getting thefollowing error when trying to insert a new custom object called bid__c. bid__c is essentially a collection of objects called bid_item__c. A master-detail relationship exists between bid and bid_item. New bid items require a reference to a bid. That is the only required field. Any help is appreciated.

 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Bid__c]: [Bid__c]

Class.bid_ext.additem: line 27, column 29 External entry point 

 

 

public pagereference additem(){ bid_item__c b = new bid_item__c(); b.setbid__c(bid); insert b; return null; }

 

 

 

 

 

Ok, I am stuck. I am working on a wizard to create a custom lead object. I've posted the entire VF page and controller extension. I can't figure out why the getaccount() function is not returning the account specified by the hidden inputfield on the visualforce page. Any help is appreciated. 

 

Here is the VF page:

 

<apex:page standardcontroller="My_Lead__c" extensions="myLeadExtension">

<apex:sectionHeader title="New Lead Capture" />

<apex:form >

<apex:pageBlock title="Page 1">

<apex:facet name="footer">

<apex:outputPanel id="footerbtn">

<apex:commandButton action="{!step1}" value="Back" styleClass="btn"/>

<apex:commandButton action="{!save}" value="Save" styleClass="btn"/>

</apex:outputPanel>

  </apex:facet>

<apex:inputField id="accountNum" value="{!mylead.Account__c}" rendered="false"/>

<apex:pageBlockSection title="Account Information">

<apex:pageblocksectionitem >

<apex:outputlabel for="anum" value="Account Number"/>

<apex:outputfield id="anum" value="{!account.accountnumber}"/>

</apex:pageblocksectionitem>

<apex:pageblocksectionitem >

<apex:outputlabel for="aphone" value="Account Phone"/>

<apex:outputfield id="aphone" value="{!account.phone}"/>

</apex:pageblocksectionitem>

<apex:pageblocksectionitem >

<apex:outputlabel for="aname" value="Account Name"/>

<apex:outputfield id="aname" value="{!account.name}"/>

</apex:pageblocksectionitem>

</apex:pageblocksection>

 

<apex:pageBlockSection title="Select Contact">

<apex:pageblocksectionitem >

<apex:outputlabel for="cname" value="Contact Name"/>

<apex:selectList id="cname" size="1" value="{!myobj.contact}">

<apex:selectoption itemLabel="-Select One-" itemValue="-Select One-"/>

<apex:selectoptions value="{!contactname}"></apex:selectoptions>

<apex:actionSupport event="onchange" rerender="details"/>

</apex:selectList>

</apex:pageblocksectionitem>

<apex:pageblocksectionitem >

<apex:commandButton action="{!newcontact}" value="New Contact" styleClass="btn"/>

</apex:pageblocksectionitem>

</apex:pageblocksection>

<apex:pageblocksection id="details" title="Contact Details">

<apex:pageblocksectionitem >

<apex:outputlabel for="cphone" value="Contact Phone"/>

<apex:outputfield id="cphone" value="{!selectedcontact.phone}"/>

</apex:pageblocksectionitem>

</apex:pageblocksection>

<apex:pageblockSection title="Lead Information">

<apex:pageblocksectionitem >

<apex:panelGrid columns="4">

<apex:outputlabel value="Product" for="prod" />

<apex:inputtext id="prod" value="{!mylead.myproduct__c}"/>

<apex:outputlabel value="Quantity" for="qty"/>

<apex:inputtext id="qty" value="{!mylead.Quantity__c}"/>

<apex:outputlabel value="In Stock" for="is"/>

<apex:selectList id="is" value="{!mylead.In_Stock__c}" size="1">

<apex:selectoption itemLabel="No" itemValue="No"/>

<apex:selectoption itemLabel="Yes" itemValue="Yes"/>

</apex:selectlist>

<apex:outputlabel value="Sample Requested" for="sample"/>

<apex:selectList id="Sample" value="{!mylead.Sample__c}" size="1">

<apex:selectoption itemLabel="No" itemValue="No"/>

<apex:selectoption itemLabel="Yes" itemValue="Yes"/>

</apex:selectList>

</apex:panelgrid>

</apex:pageblocksectionitem>

</apex:pageblocksection>

<apex:pageblocksection >

<apex:pageblocksectionitem >

<apex:panelGrid columns="2" width="100%">

<apex:outputlabel value="End Use" for="end"/>

<apex:inputTextarea id="end" cols="60" rows="5" value="{!mylead.End_Use__c}"/>

<apex:outputlabel value="Notes" for="notes"/>

<apex:inputTextarea id="nots" cols="90" rows="10" value="{!mylead.notes__c}"/>

</apex:panelgrid>

</apex:pageblocksectionitem>

</apex:pageblockSection>

</apex:pageblock>

</apex:form>

</apex:page> 

 

 


And the controller:

public with sharing class myLeadExtension {

My_Lead__c newLead = new My_Lead__c();

String accountnum;

myObj my_obj = new myobj();

public myLeadExtension(ApexPages.StandardController controller) { }

 

public class myObj{

string account = null;

string contact = null;

contact c = new contact();

account a = new account();

 

public contact getcontactobj(){return c;}

public void setcontactobj(contact data){c = data;}

 

public account getaccountobj(){return a;}

public void setaccountobj(account data){a = data;}

 

public string getaccount(){return account;}

public void setaccount(string data){account = data;}

 

public string getcontact(){return contact;}

public void setcontact(string data){contact = data;}

}

 

public myObj getmyObj() {

if (my_obj == null) { my_obj = new myObj(); }

return my_obj;

}

 

public my_lead__c getmylead(){return newLead;}

 

public void setmylead(my_lead__c data){ newlead = data;}

 

public Account getAccount() {

list<account> a = [SELECT name, accountnumber, phone FROM account where id = :newlead.account__c limit 1 ];

if(a.size() != 0) {my_obj.a = a[0];}

return my_obj.a;

}

 

public list<selectoption> getContactName() {

string selectedaccount = my_obj.a.accountnumber;

list<contact> c = [SELECT name FROM contact where Account.accountnumber = :selectedaccount order by lastname];

List<SelectOption> option = new List<SelectOption>();

 

for(integer i=0; i < c.size(); i++) {

option.add(new SelectOption(c[i].name,c[i].name));}

 

return option;

}

 

public contact getselectedcontact(){

string scontact = null;

string sAccount = my_obj.a.accountnumber;

if (my_obj != null){ scontact = my_obj.contact;}

else{ scontact = 'test';}

 

list<contact> c = [SELECT name,phone,firstname,lastname, fax, email FROM contact where Account.accountnumber = :saccount and name = :scontact limit 1];

 

if(c.size() != 0) {my_obj.c = c[0];}

else{return new contact();}

return my_obj.c;

}

 

public String getAcctNum(){ return accountNum; }

public void setAcctNum(String a){ accountNum = a;}

 

public PageReference step1() { return Page.MyLeadsPG1; }

public PageReference step2() { return Page.myLeadspg2; }

public PageReference step3() { return Page.MyLeadsPG3; }

 

public PageReference newcontact() {

my_obj.c = new contact();

return Page.MyLeadsContact; }

 

public PageReference save() {

newlead.account__c = my_obj.a.id;

newlead.contact__c = my_obj.c.id;

insert newLead;

PageReference redirectPage = new PageReference('/' + newLead.ID);

return redirectPage;

}

 

public pagereference savecontact(){

my_obj.c.accountid = my_obj.a.id;

insert my_obj.c;

my_obj.contact = my_obj.c.name;

return page.MyLeadsPG2; }

 

 

 
 
Message Edited by MJRDeveloper on 06-28-2009 02:07 PM