• mauricio.ramos
  • NEWBIE
  • 75 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 12
    Replies

Hi all,

 

I am a beginner developing apex code in salesforce. Now I have a problem with deploying triggers.

 

I have a trigger that will prevent updating opportunity:

 

trigger LockDownOpportunity on Opportunity (before update) {
    Opportunity[] opps = [select stageName from Opportunity where id in :Trigger.new];
    Profile f = [select name from Profile where id=:UserInfo.getProfileId()];
    
    for(Opportunity opp:opps){
        if((opp.stageName=='Invoicing Complete'&&f.name=='xxxxx')||(opp.stageName=='Order Complete and Closed'&&f.name=='xxxxx')){
             Opportunity actualRecord = Trigger.newMap.get(opp.Id);
             actualRecord.adderror('You do not have administrative rights to reopen this closed opportunity.');
        }
    }

 I wrote a test method for it and got a 100% code coverage. But it won't let me to deploy it and the error is: Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 0067000000Str1qAAB; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You do not have administrative rights to reopen this closed opportunity.: []", Failure Stack Trace: "Class.testLockOpportunity.test: line 22, column 1"

 


It seems it stops me deploying it because of updating fail. But as I mentioned, I need the update to fail. How do I deploy the trigger? thank you all.

 

And here is my test code

@isTest

public class testLockOpportunity{
    static testMethod void test(){
        Profile p = [select id from Profile where name='xxxxxx'];
        User testUser = new User(alias = 'u1', email='u1@testorg.com',
                        emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                        localesidkey='en_US', profileid = p.Id, country='United States',
                        timezonesidkey='America/Los_Angeles', username='u1@testorg.com');
 
       insert testUser;
       Opportunity opp = new Opportunity(stageName = 'Invoicing Complete',
                                         closeDate = Date.today()+30,
                                         Name = 'test',
                                         OwnerId = testUser.id);
        
        insert opp;
       
       System.runAs(testUser){
           opp.Client_Email_Address__c = 'test@test.com';
           Test.startTest();
           update opp;
           Test.stopTest();
       }
    }
}

 

 

Hello,

 

I am having an issue with a snippet of javascript on a VF page where I am hoping someone can enlighten me where the code is flawing. To give a small background, the VF page has a picklist and an input field that are read/updated by the JS. There is jquery code in the script to autcomplete the Product input text field by retrieving the list of possible matches from the controller (via remoting call). To downsize the result   I pass in the pricebook Id and the lineType from the Line Type picklist. I am trying to get the linetype to execute the code on the onchange event so to "cache" the results before the user types them in the input field. In my soe so far the line type changing event is firing the code and based on the alerts, I can see that the method in the controller is getting called and returns the list, BUT there are 2 issues on the result:

 

1) The .change event is not firing more than once, so the first time I cahnge the picklist value, the code fires and executes the remoting call, but any subsequent change to the picklist is not firing the code again. Why is that? shouldn't the .change always fire when changes are made to the selection of the picklist?

 

2) The autocomplete is not suggesting values based on the reusult from the call, meaning I don't see the pop up with the suggestions returned from the remoting call.

 

Below is the relevant code (VF page, js and controller method). please someone give me a hand!

 

 VF + js code:

<script>
var pop, prodNames, pbId, lineType, availableProds;
$j = jQuery.noConflict();
$j(function() {

    $j("select[id$='fLineType']").change(function() {
        pbId =  $j("input[id$='pbid']").val();
        lineType = $j(this).val();
        alert('Line type selected' + $j(this).val() + ' - ' + pbId );
        
        // call remote apex method and get chache list of Prod Names:
        SalesDocumentManager_Controller.cacheProdNames(pbId, lineType,  
           function(result, event){
                alert('Result from remote call: ' + result);
                availableProds = result;
            }, 
            {escape: true}
        );
    });
    
    $j("input[id$='prodName']").autocomplete({
        source: availableProds,
        minLength: 3
    });
    
});

 controller remote method (currently returning dummy data):

//This seems to work since it returns the values created below:    
@RemoteAction
    public static String[] cacheProdNames (String pbId, String lineType) {
        system.debug('###remote action is executing');
        String[] prodNames = new List<String>();
        prodNames.add('testProd');
        prodNames.add('testProd 2');
        return prodNames;
    }

 

Hello,

 

I am having an issue with a snippet of javascript on a VF page where I am hoping someone can enlighten me where the code is flawing. To give a small background, the VF page has a picklist and an input field that are read/updated by the JS. There is jquery code in the script to autcomplete the Product input text field by retrieving the list of possible matches from the controller (via remoting call). To downsize the result   I pass in the pricebook Id and the lineType from the Line Type picklist. I am trying to get the linetype to execute the code on the onchange event so to "cache" the results before the user types them in the input field. In my soe so far the line type changing event is firing the code and based on the alerts, I can see that the method in the controller is getting called and returns the list, BUT there are 2 issues on the result:

 

1) The .change event is not firing more than once, so the first time I cahnge the picklist value, the code fires and executes the remoting call, but any subsequent change to the picklist is not firing the code again. Why is that? shouldn't the .change always fire when changes are made to the selection of the picklist?

 

2) The autocomplete is not suggesting values based on the reusult from the call, meaning I don't see the pop up with the suggestions returned from the remoting call.

 

Below is the relevant code (VF page, js and controller method). please someone give me a hand!

 

 VF + js code:

<script>
var pop, prodNames, pbId, lineType, availableProds;
$j = jQuery.noConflict();
$j(function() {

    $j("select[id$='fLineType']").change(function() {
        pbId =  $j("input[id$='pbid']").val();
        lineType = $j(this).val();
        alert('Line type selected' + $j(this).val() + ' - ' + pbId );
        
        // call remote apex method and get chache list of Prod Names:
        SalesDocumentManager_Controller.cacheProdNames(pbId, lineType,  
           function(result, event){
                alert('Result from remote call: ' + result);
                availableProds = result;
            }, 
            {escape: true}
        );
    });
    
    $j("input[id$='prodName']").autocomplete({
        source: availableProds,
        minLength: 3
    });
    
});

 controller remote method (currently returning dummy data):

//This seems to work since it returns the values created below:    
@RemoteAction
    public static String[] cacheProdNames (String pbId, String lineType) {
        system.debug('###remote action is executing');
        String[] prodNames = new List<String>();
        prodNames.add('testProd');
        prodNames.add('testProd 2');
        return prodNames;
    }

 

Hello,

 

I am having an issue with a snippet of javascript on a VF page where I am hoping someone can enlighten me where the code is flawing. To give a small background, the VF page has a picklist and an input field that are read/updated by the JS. There is jquery code in the script to autcomplete the Product input text field by retrieving the list of possible matches from the controller (via remoting call). To downsize the result   I pass in the pricebook Id and the lineType from the Line Type picklist. I am trying to get the linetype to execute the code on the onchange event so to "cache" the results before the user types them in the input field. In my soe so far the line type changing event is firing the code and based on the alerts, I can see that the method in the controller is getting called and returns the list, BUT there are 2 issues on the result:

 

1) The .change event is not firing more than once, so the first time I cahnge the picklist value, the code fires and executes the remoting call, but any subsequent change to the picklist is not firing the code again. Why is that? shouldn't the .change always fire when changes are made to the selection of the picklist?

 

2) The autocomplete is not suggesting values based on the reusult from the call, meaning I don't see the pop up with the suggestions returned from the remoting call.

 

Below is the relevant code (VF page, js and controller method). please someone give me a hand!

 

 VF + js code:

<script>
var pop, prodNames, pbId, lineType, availableProds;
$j = jQuery.noConflict();
$j(function() {

    $j("select[id$='fLineType']").change(function() {
        pbId =  $j("input[id$='pbid']").val();
        lineType = $j(this).val();
        alert('Line type selected' + $j(this).val() + ' - ' + pbId );
        
        // call remote apex method and get chache list of Prod Names:
        SalesDocumentManager_Controller.cacheProdNames(pbId, lineType,  
           function(result, event){
                alert('Result from remote call: ' + result);
                availableProds = result;
            }, 
            {escape: true}
        );
    });
    
    $j("input[id$='prodName']").autocomplete({
        source: availableProds,
        minLength: 3
    });
    
});

 controller remote method (currently returning dummy data):

//This seems to work since it returns the values created below:    
@RemoteAction
    public static String[] cacheProdNames (String pbId, String lineType) {
        system.debug('###remote action is executing');
        String[] prodNames = new List<String>();
        prodNames.add('testProd');
        prodNames.add('testProd 2');
        return prodNames;
    }

 

I have a pageblock with a picklist that should trigger a rerender of a dynamic component in another pageblock when a value of the picklist is changed. Depending on the value I will create diferent  fields to populate the dynamic component. BUT the problem is that when I select one of the values in the picklist the entire page is refreshed and not the dynamic component. I checked the debug logs and the params are being sent to the controller correctly but for some reason the entire page is refreshing.

 

<apex:column headerValue="Line type">
                  <apex:actionRegion id="lnTypeRgn">
                      <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType">
                          <apex:actionSupport event="onblur" reRender="detailBlock" action="{!dummyProp}" >
                                   <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                          </apex:actionSupport>
                      </apex:inputField>
                  </apex:actionRegion>
                </apex:column>

 CurrSOI would be the record in row being changed. The debug log show the ID is being passed correctly as well as the Line Type value:

 

these are the controller methods being invoked

 //Sales Order Item Detail Methods://////////////////////////////////////
   public PageReference dummyProp() {
    system.debug('###### CurrSOI: ' + currSOI);
        return null;
    }
   
    public  Component.Apex.PageBlockSection getLoadSOIDetComponent() {
       //Create teh dynamic component to populate with other components depending on the selected LineType
       Component.Apex.PageBlockSection section = new Component.Apex.PageBlockSection (collapsible = True,title = 'Sales Order Item Details: ',showHeader = True);
       List<Sales_Order_Item_Detail__c> SOIdets;
       system.debug('#### DETCOMP- CurrSOI: ' + currSOI);
      
       if(currSOI <> null) {
          //get curr LineType
          String lnType = getcurrLineType();
          System.debug('#### currLineType: ' + getcurrLineType());
          //validate which line type is selected and create the correct components:
          if(lnType == 'Course') {
              //load the required fields and also component to add contacts(course registrations)
              section.title = 'Sales Order Item Details: Course'; 
              Component.apex.PageBlockSectionItem pbsi = new Component.apex.PageBlockSectionItem ();
              //add the input fields of the SOI to the dynamic component:
              Component.apex.inputField courseNo = new component.apex.inputField(value = currSOI.Course_No__c);
              Component.apex.inputField courseStartDate = new component.apex.inputField(value = currSOI.Contract_Start_Date__c);
              pbsi.childComponents.add(courseNo);
              pbsi.childcomponents.add(courseStartDate);
              section.childComponents.add(pbsi);
              //then need to add a course registration component to link to contacts:
              system.debug('##### section: ' + section + ' -- ' + courseNo + ' - ' + courseStartDate); 
              return section;       
          }else if (lnType == 'Resource'){
               section.title = 'Sales Order Item Details: Resource';
               system.debug('##### section: ' + section);
               return section;  
          }else if (lnType == 'Item'){
              section.title = 'Sales Order Item Details: Item';
              system.debug('##### section: ' + section);
              return  section;  
          }
       }
        //it is a new Sales Order and therefore no SOIs loaded, send back null section
         section.title = 'Sales Order Item Details: NULL';
         system.debug('##### section: ' + section);
        return section;
    }

 

and this is a debug log written when the onchange is fired on the picklist. There is another debug log written immediately afterwards when the page is refreshed.

 

|DEBUG|#### DETCOMP- CurrSOI: SCRB_SalesOrderLineItem__c:{CurrencyIsoCode=DKK, ProductId__c=01tD0000002ZU9rIAG, Name=a07M0000000eOh4, Id=a07M0000000eOh4IAE, etc...
|DEBUG|#### currLineType: Course
|DEBUG|##### section: Component.apex.pageblocksection -- Component.apex.inputfield - Component.apex.inputfield

 

 

 

Can anyone figure out why the components are not rendering as they should????

 

Hello all,

 

I am working in adding a dynamic component to a vf page that loads a field set and some other stuff into a page section at the bottom of the mentioned VF page. The idea is that when the user focuses on a picklist field that is part of a row of records displayed in a pageblock table, the dynamic component should update with the correct set of field sets on a pageblocksection below the table. The thing is that it is not doing this because I cannot ge tthe current record id (the row in the table where the user is focusing) to be passed to the controller and therefore it is getting NULL Since the code in the controller has a validation to return null IF hte current record is null, nothing is happening. Yet if I perform changes to other fields on the row the record id is passed just fine back to the controller. can someone assist! Below is the VF page, the controller nad the debug result, where I highlight the relevant parts.

 

Thanks!

 

Debug log:

15:08:28.452 (452150000)|USER_DEBUG|[317]|DEBUG|#### DETCOMP- CurrSOI: null

 

VF PAGE:

<apex:page controller="VF_SalesDoc_CreateDoc_Controller_MR" tabStyle="SCRB_SalesOrder__c" >
<!--I'VE REMOVED PART OF THE PAGE DUE TO SIZE RESTRICTIONS ON THE POST, BUT IT IS NOT RELEVANT TO THE ISSUE>
<apex:sectionHeader title="Create Sales Document" subtitle="{!Account.Name}"/>
<apex:messages />
<apex:form id="theForm">

<apex:pageblock title="Sales Order Items" tabStyle="SCRB_SalesOrder__c" >
<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl" disabled="{!NOT(SOsaved)}" id="btnAddSOI" />
</apex:pageBlockButtons>

<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" columnsWidth="25px, 50px, 100px, 100px, 25px, 25px, 50px, 50px, 50px, 50px, 50px, 25px" columns="12" >

<apex:column headerValue="Action">
<apex:commandLink value="Del" action="{!del}" rerender="tablePnl" style="font-weight:bold" >&nbsp;|&nbsp;
<apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
<apex:outputLink title="" value="/{!SOI.id}" style="font-weight:bold" target="_blank" >View</apex:outputLink>
</apex:commandLink>
</apex:column>

<apex:column headerValue="Line type">
<apex:actionRegion id="lnTypeRgn">
<apex:inputField value="{!SOI.Line_Type__c}" id="fLineType">
<apex:actionSupport event="onblur" reRender="detailBlock" action="{!loadSOIDetComponent}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
{!SOI.id}
</apex:actionRegion>
</apex:column>


<apex:column headerValue="Product">
<apex:actionRegion id="prodRgn">
<apex:inputField value="{!SOI.ProductId__c}" id="fProd">
<apex:commandLink id="lknProduct" action="{!updateSOIProductData}" value="Refresh" reRender="tablePnl,fDiscAmt,fTotalPrice,fProfit,colProfit">
<apex:param name="currSOI" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:inputField>
</apex:actionRegion>
</apex:column>

<apex:column headerValue="Description">
<apex:inputField value="{!SOI.Description__c}" id="fDescr" />
</apex:column>

<apex:column headerValue="Quantity">
<apex:actionRegion >
<apex:inputField value="{!SOI.Quantity__c}" id="fQTY">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfi,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIQty" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Unit Cost" >
<apex:inputField value="{!SOI.Unit_Cost__c}" id="fUnitCost" />
</apex:column>
<apex:column headerValue="Sales Price ex VAT">
<apex:inputField value="{!SOI.SalesPrice__c}" id="fSalesPrice" >
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOISlsPr" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Pct.">
<apex:inputField value="{!SOI.Line_Discount_Pct__c}" id="fDiscPct">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIPct" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Amt.">
<apex:inputField value="{!SOI.Line_Discount_Amount__c}" id="fDiscAmt">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIPAmt" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Profit" id="colProfit" >
<apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>

</apex:column>
<apex:column headerValue="Total Price">
<apex:inputField value="{!SOI.TotalPrice__c}" id="fTotalPrice">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIPct" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Status" >
<apex:outputField value="{!SOI.Line_Status__c }" id="fLineStatus" />
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>

<!--Dynamic ajax rerender section that depends on above selected values for the table row. TO COMPLETE-->
<apex:outputPanel id="detailBlock">
<apex:dynamicComponent componentValue="{!SOIDetComponent}" />
</apex:outputPanel>

</apex:pageblock>

</apex:form>
</apex:page>

 

 

CONTROLLER CODE: PART OF THE CODE HAS BEEN REMOVED TO SIZE RESTRICTIONS

public class VF_SalesDoc_CreateDoc_Controller_MR {


//custom exceptions
public class SalesOrderItemsException extends Exception {}
public class SalesOrderItemDetailException extends Exception {}

//class variables
private salesOrderManager som; // TODO: MOVE ALL THE CODE RELEVANT TO THIS CLASS: SOQLs, DMLs and getter/setter methods for SO, SOIs and SOIDetails
private SCRB_SalesOrder__c so;
private List<SCRB_SalesOrderLineItem__c> SOIs = new List<SCRB_SalesOrderLineItem__c>();
public List<SCRB_SalesOrderLineItem__c> forDeletion = new List<SCRB_SalesOrderLineItem__c>();
private SCRB_SalesOrderLineItem__c currSOI;
private PriceBookEntry pbEntry;
public List <Sales_Order_Item_Detail__c> SOIDetails;
public Component.Apex.PageBlockSection SOIdetSection;

//page parameters //
private String PageAction;
private String DocType;
private Id accountId;
private Id contactId;
public String mPricebook;

public Account account {get; private set;}
public Opportunity opportunity {get; private set;}

public String getcurrLineType() {
return currSOI.Line_Type__c;
}

public String currSOIid {
get{
return currSOI.id;}
set {
if(value <> null ){
for(SCRB_SalesOrderLineItem__c soi: SOIs) {
if (soi.id == value) {
currSOI = soi;
}
}
} else {
currSOI = null;}
}
}


public PageReference cancel() {
PageReference sop= new ApexPages.StandardController(so).view();
sop.setRedirect(true);
return sop;
}

//**Controller constructor**///////////////////////////////////
public VF_SalesDoc_CreateDoc_Controller_MR() {
//check if its a new action, if so prepopulate fields:
Id id = ApexPages.currentPage().getParameters().get('id');
PageAction = ApexPages.currentPage().getParameters().get('PageAction');
DocType = ApexPages.currentPage().getParameters().get('DocType');
accountId = ApexPages.currentPage().getParameters().get('aId');
contactId = ApexPages.currentPage().getParameters().get('cId');

//create a Sales Order Manager and load new/existing Sales Order
som = new SalesOrderManager();
try{
so = loadSalesOrder(id);
}catch (Exception e) {
ApexPages.addMessages(e);
}
if (PageAction != null) {
if (PageAction == 'New') {
// we arrived from account so we load this account into the header
account = som.loadAccount(accountid);
this.populateSOwithAccount(account);
so.Pricebook__c = 'Standard Price Book';
}
}else {
//if SO exists then load SOIs
SOIs = som.loadSOIs (this.so.id);
for(SCRB_SalesOrderLineItem__c soi: SOIs){
if(soi.Productid__c <> null ) {
Product2 pProd = [Select id, name, ProductCode,Description, IsActive, Unit_Cost__c, Product_Type__c, License_Type__c From Product2 where id = :soi.Productid__c];
PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :pProd.Id AND PriceBook2Id = :pb.id Limit 1];
soi.SalesPrice__c = pbEntry.UnitPrice;
soi.Unit_Cost__c = pProd.Unit_Cost__c;
soi.Description__c = pProd.Description;
}
}
}
}
//**end of controller constructor**////////////////////////////

 




//Sales Order Item Detail Methods://////////////////////////////////////

public component.Apex.PageBlockSection getSOIDetComponent () {
return SOIdetSection;
}
public PageReference loadSOIDetComponent() {
//Create teh dynamic component to populate with other components depending on the selected LineType
Component.Apex.PageBlockSection section = new Component.Apex.PageBlockSection (collapsible = True,title = 'Sales Order Item Details: ',showHeader = True);
List<Sales_Order_Item_Detail__c> SOIdets;
system.debug('#### DETCOMP- CurrSOI: ' + currSOI);

if(currSOI <> null) {
//get curr LineType
String lnType = getcurrLineType();
System.debug('#### currLineType: ' + getcurrLineType());
//validate which line type is selected and create the correct components:
if(lnType == 'Course') {
//load the required fields and also component to add contacts(course registrations)
Component.apex.PageBlockSectionItem pbsi = new Component.apex.PageBlockSectionItem ();
List<Schema.FieldSetMember> fs = SObjectType.SCRB_SalesOrderLineItem__c.FieldSets.Courses.getFields();
for(Schema.FieldSetMember f :fs ){
Component.apex.inputField ff = new Component.apex.inputField(value = f.getFieldPath());
section.childComponents.add(ff);
}
SOIdetSection = section;
}else if (lnType == 'Resource'){
SOIdetSection = section;
}else if (lnType == 'Item'){
SOIdetSection = section;
}
}
//it is a new Sales Order and therefore no SOIs loaded, send back null section
return null;
}
}

Hello,

 

I have a VF page with a button that should be hidden while the Id of its parent record is null (meaning until the Save buton higher up in the page is clicked and a save method is executed which will persist the object in the DB. At that point I want to have the button farther down (which creates instances of child records to appear again so that releated items can be added.  See the code below:

 

This is at the top of the page where a save buton is placed to execute the saving of the Sales Order (parent object)

 

<apex:pageblockButtons >
<apex:commandButton action="{!saveSO}" value="Save Changes" reRender="out,btnAddSOI" status="saveStatus">
</apex:commandButton>

  then at the bottom of the page in another pageblock I have the following:

 

    <apex:pageBlockButtons >
    <apex:outputPanel id="btnAddSOI" rendered="{!SOsaved}">
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl"  />
    </apex:outputPanel>
    </apex:pageBlockButtons>

 This is the button that should dissapear if the parent record has not been saved yet and should magically reapear once the button has been saved. Currently on page load the visibility reflect correctly(e.g. if editing an existing record via the VF page then the button is visible, else if its a new record via the same VF page then the button is hidden) The problem lies in that the button doesn't REAPPEAR once the record is saved.  Below is the controller method in use (SOsaved):

 

    public Boolean SOsaved {
        get { 
        boolean bool;
        bool= so.Id <> null ? True : False;
        System.debug('SO saved ' + bool + ' - ' + so.Id);
        return bool;
        }
    }

 Can someone please assist???

I havea  pageblocktable in a VF page that contains a list of Sales Order Items which among other fields contain a lookup to product(<apex:inputField value="{!SOI.ProductId__c}" />). I want to be able to update the fields in that row when I change the product in the lookup field. I only want to rerender that row and not the entire table. Below is the code I was able to put together, can anyone assist:

 

VF page code:

 

<apex:actionFunction status="outStatus" name="reload" rerender="SOIList" />
    <apex:pageblock title="Sales Order Items"  tabStyle="SCRB_SalesOrder__c" >
    <apex:pageBlockButtons >
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="SOIList" />
    </apex:pageBlockButtons>
    <apex:pageMessages /> 
     <apex:outputPanel >
     <apex:actionRegion id="table">
            <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
                <apex:column headerValue="Action">
                    <apex:commandLink value="Del" action="{!del}" rerender="SOIList" style="font-weight:bold"  >&nbsp;|&nbsp;
                        <apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
                        <apex:outputLink title="" value="/{!SOI.id}" style="font-weight:bold" target="_blank" >View</apex:outputLink>
                    </apex:commandLink>
                </apex:column>
                
                <apex:column headerValue="Line type">
                    <apex:inputField value="{!SOI.Line_Type__c}" />
                </apex:column>
                
                <apex:column headerValue="Product">
                    <apex:inputField value="{!SOI.ProductId__c}" />
                </apex:column>
                
                <apex:column headerValue="Description">
                    <apex:inputField value="{!SOI.Description__c}" />
                </apex:column>
                <apex:column headerValue="Quantity">
                    <apex:inputField value="{!SOI.Quantity__c}" />
                </apex:column>
                
                <apex:column headerValue="Unit Cost" >
                    <apex:outputField value="{!SOI.Unit_Cost__c}" />
                </apex:column>
                <apex:column headerValue="Sales Price ex VAT">
                    <apex:inputField value="{!SOI.SalesPrice__c}" />
                </apex:column>
                <apex:column headerValue="Line Disc Pct.">
                    <apex:inputField value="{!SOI.Line_Discount_Pct__c}" />
                </apex:column>
                <apex:column headerValue="Line Disc Amt.">
                    <apex:inputField value="{!SOI.Line_Discount_Amount__c}" />
                </apex:column>
                <apex:column headerValue="Total Price">
                    <apex:inputField value="{!SOI.TotalPrice__c}" />
                </apex:column>
                <apex:column headerValue="Line Status">
                    <apex:inputField value="{!SOI.Line_Status__c }" />
                </apex:column>  
            </apex:pageBlockTable>
        </apex:actionRegion>
        </apex:outputPanel>
            <apex:actionregion >
            
            <apex:pageBlockSection title="Sale Order Item Detail" columns="2" collapsible="true" id="SOIs" showHeader="true" >
            
            </apex:pageBlockSection>
            </apex:actionregion>
    </apex:pageblock>

 Thanks!!

Hello I have been trying to get a Select List to populate the options into the dropdown and have been able to retrieve the list and load it into the picklist, BUT, it does not seem to pass the value for the currently selected option back to the controller. The idea is to get the list of pricebooks for the org and let the user select one, then a variable String in the controller should be updated with the selection the user made. below is the code and vf mark up, if anyone knows what is going on??

 

<apex:form >
<apex:actionRegion id="detail">
<apex:pageBlock tabStyle="SCRB_SalesOrder__c" title="Create Sales Document" >
<apex:pageblockButtons >
       <apex:commandButton action="{!saveSO}" value="Save Sales Order" />
</apex:pageblockButtons>

<apex:pageblockSection collapsible="true" id="docInfo" showHeader="true" title="Document Information"  columns="2"  >
    <apex:pageBlockSectionItem >          
               <!--Load Pricebooks for the Org-->             
                <apex:pageblocksectionItem >
              
                <apex:selectList id="pb" value="{!priceBook}"  multiselect="false" >
                    <apex:selectOptions value="{!PriceBookItems}"/>
                </apex:selectList>
                <a>Currently selected priceBook: {!pricebook}</a>            
                </apex:pageblocksectionItem>

 and the controller code

 

Public String mPricebook;

//load/create list of Pricebooks for the ORG Then load into select list
     public List<SelectOption> getPriceBookItems() {
        List<SelectOption> options = new List<SelectOption>();
        Map<id,PriceBook2> pbs = som.queryPriceBooks(); //this get the list from another class, this is working.
         system.debug('###PriceBooks for Org; ' + pbs);
        for(String pbKey: pbs.keyset()) {
             options.add(new SelectOption(String.valueOf(pbKey),String.valueOf(pbs.get(pbkey).name)));
          }
         }
         return options;
    }
    public String getPriceBook() {
        return mPricebook;
    }
 
    public void setPriceBook(String pPricebook) {
        this.mPricebook = pPriceBook;
    }

 

Hi

I have a VF page with 5 input File attachment. I want 5 different attachment on the each of them. eg: Their are 3 different fields 1. Name, 2. Job, 3. Resume . So like this their are 5 fields. If 1st Name = Anu, Job = SFDC dev , resume = attachment1 2nd Name = ram, job = SFDC dev, resume = attachment2 etc. Their is no field called attachment in object. I need to attach the attachment to the record we create. Is it possible. Please help me to solve this issue.

Thanks

Anu

Hi all,

 

I am a beginner developing apex code in salesforce. Now I have a problem with deploying triggers.

 

I have a trigger that will prevent updating opportunity:

 

trigger LockDownOpportunity on Opportunity (before update) {
    Opportunity[] opps = [select stageName from Opportunity where id in :Trigger.new];
    Profile f = [select name from Profile where id=:UserInfo.getProfileId()];
    
    for(Opportunity opp:opps){
        if((opp.stageName=='Invoicing Complete'&&f.name=='xxxxx')||(opp.stageName=='Order Complete and Closed'&&f.name=='xxxxx')){
             Opportunity actualRecord = Trigger.newMap.get(opp.Id);
             actualRecord.adderror('You do not have administrative rights to reopen this closed opportunity.');
        }
    }

 I wrote a test method for it and got a 100% code coverage. But it won't let me to deploy it and the error is: Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 0067000000Str1qAAB; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You do not have administrative rights to reopen this closed opportunity.: []", Failure Stack Trace: "Class.testLockOpportunity.test: line 22, column 1"

 


It seems it stops me deploying it because of updating fail. But as I mentioned, I need the update to fail. How do I deploy the trigger? thank you all.

 

And here is my test code

@isTest

public class testLockOpportunity{
    static testMethod void test(){
        Profile p = [select id from Profile where name='xxxxxx'];
        User testUser = new User(alias = 'u1', email='u1@testorg.com',
                        emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
                        localesidkey='en_US', profileid = p.Id, country='United States',
                        timezonesidkey='America/Los_Angeles', username='u1@testorg.com');
 
       insert testUser;
       Opportunity opp = new Opportunity(stageName = 'Invoicing Complete',
                                         closeDate = Date.today()+30,
                                         Name = 'test',
                                         OwnerId = testUser.id);
        
        insert opp;
       
       System.runAs(testUser){
           opp.Client_Email_Address__c = 'test@test.com';
           Test.startTest();
           update opp;
           Test.stopTest();
       }
    }
}

 

 

Hello, below is a small trigger code I created on the FeedItem to try and catch when a new FeedItem of type TrackedChange is created for a change on a tracked field in the contact. The idea is that whenever a value changes on a field that is feedtracked on the contact, I need to catch this change and do something with it, in this case woudl be sending an email, but the important thing is to be able to "catch" the event and changed data, the action to take afterwards is not important, could also be just a system.debug() See code below and let me know WHY this is not firing when I make a change to a contact record that has some of its fields tracked:

 

this is the trigger on the feed item:

 

trigger FeedItem_Trigger on FeedItem (after insert) {
List<FeedTrackedChange> lstFTC ;
List<FeedItem> feeds, contFeeds;
    //check on insert IF item is for a FeedTrackedChange for Contact (used as POC for Ole Lyngaard)

    
    if(trigger.isAfter){
    	lstFTC = new List<FeedTrackedChange>();
    	feeds = new List<FeedItem>();
    	contFeeds = new List<FeedItem>();
    	
    	//get info needed from trigger.new
    	 feeds = [Select f.ParentId, f.Id, f.Type, 
                                  (Select FieldName, OldValue, NewValue From FeedTrackedChanges) 
                                  From FeedItem f Where f.Id IN :trigger.new];
   
    	//for each result check if the parentId is from an contact, if so then get records
        contFeeds = new List<FeedItem>();
        for(FeedItem f:feeds) {
            String fId = f.ParentId;
            if(fId.left(3)== '003') contFeeds.add(f);
        }
        
        //for each contact feed, get any feedtrackedchanges records (these belong to feeds from tracked fields on contact)
        for(FeedItem f: contFeeds) {
        	//get feedtrackedchanges records:
        	for(FeedTrackedChange ftc:f.FeedTrackedChanges) {
        		FeedTrackedChange newftc = ftc; 
        		lstFTC.add(newftc);
        	}
        	
        	for(FeedTrackedChange ftc: lstFTC) {
        		Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        		mail.setSubject('New field tracked item created');
        		List<String> toAddr = new List<String> ();
        		toAddr.add('mr@corpital.com');
        		mail.setToAddresses(toAddr);
            	mail.setPlainTextBody ('The following Feed has changed: ' + ftc.FieldName + ', from ' + ftc.OldValue + ' to ' + ftc.NewValue);
            	Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });    
        	
        	
        	}
        	        }
        
        System.debug('###contFeeds:'+contFeeds);
    }
}

 Again, the important issue here is that this is not generating either an email OR a system debug entry It is as if the trigger is not even firing!  Help please!!

 

Hello all,

 

I am working in adding a dynamic component to a vf page that loads a field set and some other stuff into a page section at the bottom of the mentioned VF page. The idea is that when the user focuses on a picklist field that is part of a row of records displayed in a pageblock table, the dynamic component should update with the correct set of field sets on a pageblocksection below the table. The thing is that it is not doing this because I cannot ge tthe current record id (the row in the table where the user is focusing) to be passed to the controller and therefore it is getting NULL Since the code in the controller has a validation to return null IF hte current record is null, nothing is happening. Yet if I perform changes to other fields on the row the record id is passed just fine back to the controller. can someone assist! Below is the VF page, the controller nad the debug result, where I highlight the relevant parts.

 

Thanks!

 

Debug log:

15:08:28.452 (452150000)|USER_DEBUG|[317]|DEBUG|#### DETCOMP- CurrSOI: null

 

VF PAGE:

<apex:page controller="VF_SalesDoc_CreateDoc_Controller_MR" tabStyle="SCRB_SalesOrder__c" >
<!--I'VE REMOVED PART OF THE PAGE DUE TO SIZE RESTRICTIONS ON THE POST, BUT IT IS NOT RELEVANT TO THE ISSUE>
<apex:sectionHeader title="Create Sales Document" subtitle="{!Account.Name}"/>
<apex:messages />
<apex:form id="theForm">

<apex:pageblock title="Sales Order Items" tabStyle="SCRB_SalesOrder__c" >
<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl" disabled="{!NOT(SOsaved)}" id="btnAddSOI" />
</apex:pageBlockButtons>

<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" columnsWidth="25px, 50px, 100px, 100px, 25px, 25px, 50px, 50px, 50px, 50px, 50px, 25px" columns="12" >

<apex:column headerValue="Action">
<apex:commandLink value="Del" action="{!del}" rerender="tablePnl" style="font-weight:bold" >&nbsp;|&nbsp;
<apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
<apex:outputLink title="" value="/{!SOI.id}" style="font-weight:bold" target="_blank" >View</apex:outputLink>
</apex:commandLink>
</apex:column>

<apex:column headerValue="Line type">
<apex:actionRegion id="lnTypeRgn">
<apex:inputField value="{!SOI.Line_Type__c}" id="fLineType">
<apex:actionSupport event="onblur" reRender="detailBlock" action="{!loadSOIDetComponent}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
{!SOI.id}
</apex:actionRegion>
</apex:column>


<apex:column headerValue="Product">
<apex:actionRegion id="prodRgn">
<apex:inputField value="{!SOI.ProductId__c}" id="fProd">
<apex:commandLink id="lknProduct" action="{!updateSOIProductData}" value="Refresh" reRender="tablePnl,fDiscAmt,fTotalPrice,fProfit,colProfit">
<apex:param name="currSOI" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:inputField>
</apex:actionRegion>
</apex:column>

<apex:column headerValue="Description">
<apex:inputField value="{!SOI.Description__c}" id="fDescr" />
</apex:column>

<apex:column headerValue="Quantity">
<apex:actionRegion >
<apex:inputField value="{!SOI.Quantity__c}" id="fQTY">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfi,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIQty" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Unit Cost" >
<apex:inputField value="{!SOI.Unit_Cost__c}" id="fUnitCost" />
</apex:column>
<apex:column headerValue="Sales Price ex VAT">
<apex:inputField value="{!SOI.SalesPrice__c}" id="fSalesPrice" >
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOISlsPr" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Pct.">
<apex:inputField value="{!SOI.Line_Discount_Pct__c}" id="fDiscPct">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIPct" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Amt.">
<apex:inputField value="{!SOI.Line_Discount_Amount__c}" id="fDiscAmt">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIPAmt" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Profit" id="colProfit" >
<apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>

</apex:column>
<apex:column headerValue="Total Price">
<apex:inputField value="{!SOI.TotalPrice__c}" id="fTotalPrice">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit,colProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIPct" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Status" >
<apex:outputField value="{!SOI.Line_Status__c }" id="fLineStatus" />
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>

<!--Dynamic ajax rerender section that depends on above selected values for the table row. TO COMPLETE-->
<apex:outputPanel id="detailBlock">
<apex:dynamicComponent componentValue="{!SOIDetComponent}" />
</apex:outputPanel>

</apex:pageblock>

</apex:form>
</apex:page>

 

 

CONTROLLER CODE: PART OF THE CODE HAS BEEN REMOVED TO SIZE RESTRICTIONS

public class VF_SalesDoc_CreateDoc_Controller_MR {


//custom exceptions
public class SalesOrderItemsException extends Exception {}
public class SalesOrderItemDetailException extends Exception {}

//class variables
private salesOrderManager som; // TODO: MOVE ALL THE CODE RELEVANT TO THIS CLASS: SOQLs, DMLs and getter/setter methods for SO, SOIs and SOIDetails
private SCRB_SalesOrder__c so;
private List<SCRB_SalesOrderLineItem__c> SOIs = new List<SCRB_SalesOrderLineItem__c>();
public List<SCRB_SalesOrderLineItem__c> forDeletion = new List<SCRB_SalesOrderLineItem__c>();
private SCRB_SalesOrderLineItem__c currSOI;
private PriceBookEntry pbEntry;
public List <Sales_Order_Item_Detail__c> SOIDetails;
public Component.Apex.PageBlockSection SOIdetSection;

//page parameters //
private String PageAction;
private String DocType;
private Id accountId;
private Id contactId;
public String mPricebook;

public Account account {get; private set;}
public Opportunity opportunity {get; private set;}

public String getcurrLineType() {
return currSOI.Line_Type__c;
}

public String currSOIid {
get{
return currSOI.id;}
set {
if(value <> null ){
for(SCRB_SalesOrderLineItem__c soi: SOIs) {
if (soi.id == value) {
currSOI = soi;
}
}
} else {
currSOI = null;}
}
}


public PageReference cancel() {
PageReference sop= new ApexPages.StandardController(so).view();
sop.setRedirect(true);
return sop;
}

//**Controller constructor**///////////////////////////////////
public VF_SalesDoc_CreateDoc_Controller_MR() {
//check if its a new action, if so prepopulate fields:
Id id = ApexPages.currentPage().getParameters().get('id');
PageAction = ApexPages.currentPage().getParameters().get('PageAction');
DocType = ApexPages.currentPage().getParameters().get('DocType');
accountId = ApexPages.currentPage().getParameters().get('aId');
contactId = ApexPages.currentPage().getParameters().get('cId');

//create a Sales Order Manager and load new/existing Sales Order
som = new SalesOrderManager();
try{
so = loadSalesOrder(id);
}catch (Exception e) {
ApexPages.addMessages(e);
}
if (PageAction != null) {
if (PageAction == 'New') {
// we arrived from account so we load this account into the header
account = som.loadAccount(accountid);
this.populateSOwithAccount(account);
so.Pricebook__c = 'Standard Price Book';
}
}else {
//if SO exists then load SOIs
SOIs = som.loadSOIs (this.so.id);
for(SCRB_SalesOrderLineItem__c soi: SOIs){
if(soi.Productid__c <> null ) {
Product2 pProd = [Select id, name, ProductCode,Description, IsActive, Unit_Cost__c, Product_Type__c, License_Type__c From Product2 where id = :soi.Productid__c];
PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :pProd.Id AND PriceBook2Id = :pb.id Limit 1];
soi.SalesPrice__c = pbEntry.UnitPrice;
soi.Unit_Cost__c = pProd.Unit_Cost__c;
soi.Description__c = pProd.Description;
}
}
}
}
//**end of controller constructor**////////////////////////////

 




//Sales Order Item Detail Methods://////////////////////////////////////

public component.Apex.PageBlockSection getSOIDetComponent () {
return SOIdetSection;
}
public PageReference loadSOIDetComponent() {
//Create teh dynamic component to populate with other components depending on the selected LineType
Component.Apex.PageBlockSection section = new Component.Apex.PageBlockSection (collapsible = True,title = 'Sales Order Item Details: ',showHeader = True);
List<Sales_Order_Item_Detail__c> SOIdets;
system.debug('#### DETCOMP- CurrSOI: ' + currSOI);

if(currSOI <> null) {
//get curr LineType
String lnType = getcurrLineType();
System.debug('#### currLineType: ' + getcurrLineType());
//validate which line type is selected and create the correct components:
if(lnType == 'Course') {
//load the required fields and also component to add contacts(course registrations)
Component.apex.PageBlockSectionItem pbsi = new Component.apex.PageBlockSectionItem ();
List<Schema.FieldSetMember> fs = SObjectType.SCRB_SalesOrderLineItem__c.FieldSets.Courses.getFields();
for(Schema.FieldSetMember f :fs ){
Component.apex.inputField ff = new Component.apex.inputField(value = f.getFieldPath());
section.childComponents.add(ff);
}
SOIdetSection = section;
}else if (lnType == 'Resource'){
SOIdetSection = section;
}else if (lnType == 'Item'){
SOIdetSection = section;
}
}
//it is a new Sales Order and therefore no SOIs loaded, send back null section
return null;
}
}

Hello,

 

I have a VF page with a button that should be hidden while the Id of its parent record is null (meaning until the Save buton higher up in the page is clicked and a save method is executed which will persist the object in the DB. At that point I want to have the button farther down (which creates instances of child records to appear again so that releated items can be added.  See the code below:

 

This is at the top of the page where a save buton is placed to execute the saving of the Sales Order (parent object)

 

<apex:pageblockButtons >
<apex:commandButton action="{!saveSO}" value="Save Changes" reRender="out,btnAddSOI" status="saveStatus">
</apex:commandButton>

  then at the bottom of the page in another pageblock I have the following:

 

    <apex:pageBlockButtons >
    <apex:outputPanel id="btnAddSOI" rendered="{!SOsaved}">
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl"  />
    </apex:outputPanel>
    </apex:pageBlockButtons>

 This is the button that should dissapear if the parent record has not been saved yet and should magically reapear once the button has been saved. Currently on page load the visibility reflect correctly(e.g. if editing an existing record via the VF page then the button is visible, else if its a new record via the same VF page then the button is hidden) The problem lies in that the button doesn't REAPPEAR once the record is saved.  Below is the controller method in use (SOsaved):

 

    public Boolean SOsaved {
        get { 
        boolean bool;
        bool= so.Id <> null ? True : False;
        System.debug('SO saved ' + bool + ' - ' + so.Id);
        return bool;
        }
    }

 Can someone please assist???

I havea  pageblocktable in a VF page that contains a list of Sales Order Items which among other fields contain a lookup to product(<apex:inputField value="{!SOI.ProductId__c}" />). I want to be able to update the fields in that row when I change the product in the lookup field. I only want to rerender that row and not the entire table. Below is the code I was able to put together, can anyone assist:

 

VF page code:

 

<apex:actionFunction status="outStatus" name="reload" rerender="SOIList" />
    <apex:pageblock title="Sales Order Items"  tabStyle="SCRB_SalesOrder__c" >
    <apex:pageBlockButtons >
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="SOIList" />
    </apex:pageBlockButtons>
    <apex:pageMessages /> 
     <apex:outputPanel >
     <apex:actionRegion id="table">
            <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
                <apex:column headerValue="Action">
                    <apex:commandLink value="Del" action="{!del}" rerender="SOIList" style="font-weight:bold"  >&nbsp;|&nbsp;
                        <apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
                        <apex:outputLink title="" value="/{!SOI.id}" style="font-weight:bold" target="_blank" >View</apex:outputLink>
                    </apex:commandLink>
                </apex:column>
                
                <apex:column headerValue="Line type">
                    <apex:inputField value="{!SOI.Line_Type__c}" />
                </apex:column>
                
                <apex:column headerValue="Product">
                    <apex:inputField value="{!SOI.ProductId__c}" />
                </apex:column>
                
                <apex:column headerValue="Description">
                    <apex:inputField value="{!SOI.Description__c}" />
                </apex:column>
                <apex:column headerValue="Quantity">
                    <apex:inputField value="{!SOI.Quantity__c}" />
                </apex:column>
                
                <apex:column headerValue="Unit Cost" >
                    <apex:outputField value="{!SOI.Unit_Cost__c}" />
                </apex:column>
                <apex:column headerValue="Sales Price ex VAT">
                    <apex:inputField value="{!SOI.SalesPrice__c}" />
                </apex:column>
                <apex:column headerValue="Line Disc Pct.">
                    <apex:inputField value="{!SOI.Line_Discount_Pct__c}" />
                </apex:column>
                <apex:column headerValue="Line Disc Amt.">
                    <apex:inputField value="{!SOI.Line_Discount_Amount__c}" />
                </apex:column>
                <apex:column headerValue="Total Price">
                    <apex:inputField value="{!SOI.TotalPrice__c}" />
                </apex:column>
                <apex:column headerValue="Line Status">
                    <apex:inputField value="{!SOI.Line_Status__c }" />
                </apex:column>  
            </apex:pageBlockTable>
        </apex:actionRegion>
        </apex:outputPanel>
            <apex:actionregion >
            
            <apex:pageBlockSection title="Sale Order Item Detail" columns="2" collapsible="true" id="SOIs" showHeader="true" >
            
            </apex:pageBlockSection>
            </apex:actionregion>
    </apex:pageblock>

 Thanks!!

Hello I have been trying to get a Select List to populate the options into the dropdown and have been able to retrieve the list and load it into the picklist, BUT, it does not seem to pass the value for the currently selected option back to the controller. The idea is to get the list of pricebooks for the org and let the user select one, then a variable String in the controller should be updated with the selection the user made. below is the code and vf mark up, if anyone knows what is going on??

 

<apex:form >
<apex:actionRegion id="detail">
<apex:pageBlock tabStyle="SCRB_SalesOrder__c" title="Create Sales Document" >
<apex:pageblockButtons >
       <apex:commandButton action="{!saveSO}" value="Save Sales Order" />
</apex:pageblockButtons>

<apex:pageblockSection collapsible="true" id="docInfo" showHeader="true" title="Document Information"  columns="2"  >
    <apex:pageBlockSectionItem >          
               <!--Load Pricebooks for the Org-->             
                <apex:pageblocksectionItem >
              
                <apex:selectList id="pb" value="{!priceBook}"  multiselect="false" >
                    <apex:selectOptions value="{!PriceBookItems}"/>
                </apex:selectList>
                <a>Currently selected priceBook: {!pricebook}</a>            
                </apex:pageblocksectionItem>

 and the controller code

 

Public String mPricebook;

//load/create list of Pricebooks for the ORG Then load into select list
     public List<SelectOption> getPriceBookItems() {
        List<SelectOption> options = new List<SelectOption>();
        Map<id,PriceBook2> pbs = som.queryPriceBooks(); //this get the list from another class, this is working.
         system.debug('###PriceBooks for Org; ' + pbs);
        for(String pbKey: pbs.keyset()) {
             options.add(new SelectOption(String.valueOf(pbKey),String.valueOf(pbs.get(pbkey).name)));
          }
         }
         return options;
    }
    public String getPriceBook() {
        return mPricebook;
    }
 
    public void setPriceBook(String pPricebook) {
        this.mPricebook = pPriceBook;
    }