• mauricio.ramos@corpital
  • NEWBIE
  • 130 Points
  • Member since 2012

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

I have a pageblocktable with a list of OpportunityLineItems which present key fields in either input or output field, one of these is a Profit__c field which gets calculated and rerended in the table via controller method. When making changes to the line item such as the quantity or the unit price, the profit get calculated correctly and debugs show that the line item contains the correct value, BUT when i click finish button ,which navigates back to the Opportunity view page, the Profit value is not passed back to the server, instead it updates with the old value which was last saved to the DB. All other values are calculated and saved accordingly.

 

Note: If I open the page and do not add discount, then the profit is saved correctly in the DB when the finish button is clicked.

 

VF page (partial code, too long for all):

.....
<apex:pageblockButtons >
<apex:commandButton value="Finish" action="{!finish}"  />
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageblockButtons>
<apex:outputPanel id="tablePnl"  >
<div id="backDropBkg" class="backdrop"></div>
<apex:messages id="msgs" />   
<apex:pageblockTable value="{!OLIs}" var="OLI" id="OLIList" onrowclick="highlightOLIrow(this);" >
    <apex:column id="DelCol" width="11%;" headerValue="Action"> 
        <apex:outputPanel style="margin-right:10px;" >
            <apex:commandButton value="Delete" action="{!del}" rerender="OppLinesContainer,tablePnl, backDropBkg"   id="Del_BTN"  >
                <apex:param name="delname" value="{!OLI.id}" assignTo="{!currOLIid}"/> 
            </apex:commandButton>
        </apex:outputPanel>    
        <apex:outputPanel style="vertical-align:middle;" >
            <apex:image value="{!URLFOR($Resource.web_icons, '/arrow-up.png')}" alt="Move Up"  title="Up" >
            <apex:actionSupport event="onclick" action="{!moveOliUP}" status="sortStatus" rerender="OLIList, tablePnl, backDropBkg" >
                <apex:param name="sortUpId" value="{!OLI.id}" assignTo="{!currOLIid}"/> 
            </apex:actionSupport>
        </apex:image>    
        <apex:image value="{!URLFOR($Resource.web_icons, '/arrow-down.png')}" alt="Move Down"  title="Down">
            <apex:actionSupport event="onclick" action="{!moveOliDOWN}" status="sortStatus" rerender="OLIList, tablePnl, backDropBkg" >
                <apex:param name="sortDownId" value="{!OLI.id}" assignTo="{!currOLIid}"/> 
            </apex:actionSupport>
        </apex:image>
        </apex:outputPanel> 
    </apex:column>            
    <apex:column headerValue="Line type" id="ltcol" width="6%;">
        <apex:outputField value="{!OLI.Product_Type__c}" />     
    </apex:column>
    <apex:column headerValue="Product Name" id="prodCol" width="14%;" >
        <apex:outputText value="{!OLI.PriceBookEntry.Product2.Name}"/> 
    </apex:column>
    <apex:column headerValue="Description" width="25%"  >
        <apex:inputField value="{!OLI.Description}" id="fDescr" style="width:95%;" >
        </apex:inputField>
    </apex:column>
    <apex:column headerValue="Quantity" width="4%;" > 
    <apex:inputField value="{!OLI.Quantity_Temp__c}"  id="fQTY"  required="false" rendered="{!OLI.Product_Type__c != 'Text'}">
        <apex:actionSupport event="onchange" rerender="msgs,tablePanel,fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt,fQTY" action="{!calculatePricing_ResetDiscount}" >
            <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
        </apex:actionSupport>
    </apex:inputField>       
    </apex:column>             
<apex:column headerValue="Unit Cost" width="5%;"  >
<apex:inputField value="{!OLI.Unit_cost_2__c}" id="fUnitCost"   rendered="{!OLI.Product_Type__c != 'Text'}">
    <apex:actionSupport event="onchange" rerender="msgs,tablePanel,fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!updateOLI_Pricing}" >
        <apex:param name="currOLIUC" value="{!OLI.Id}" assignTo="{!currOLIid}"/>       
    </apex:actionSupport>
</apex:inputField> 
</apex:column>
<apex:column headerValue="Sales Price" width="6%;">
    <apex:inputField value="{!OLI.SalesPrice_Temp__c}" required="true" id="fSalesPrice" rendered="{!OLI.Product_Type__c != 'Text'}">
        <apex:actionSupport event="onchange" rerender="msgs,tablePanel,fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt,fSalesPrice" action="{!calculatePricing_ResetDiscount}" >
            <apex:param name="currOLISP" value="{!OLI.Id}" assignTo="{!currOLIid}"/>           
        </apex:actionSupport>
    </apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc. Pct." width="6%;">
    <apex:inputField value="{!OLI.Discount_Temp__c}" id="fDiscPct" rendered="{!OLI.Product_Type__c != 'Text'}">
        <apex:actionSupport event="onchange" rerender="msgs, fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!calculateOLIDiscountAmt}" >
            <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
        </apex:actionSupport>
    </apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc." width="6%;">
    <apex:inputField value="{!OLI.Line_Discount_Amount__c}" id="fDiscAmt"rendered="{!OLI.Product_Type__c != 'Text'}">
        <apex:actionSupport event="onchange" rerender="msgs, fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!calculateOLIDiscountPct}" >
            <apex:param name="currOLIAmt" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
        </apex:actionSupport>
    </apex:inputField>
</apex:column>  
<apex:column headerValue="Line Profit" style="text-align:center;" width="5%;">
    <apex:outputField value="{!OLI.Profit__c}" id="fProfit"  style="width:95%" rendered="{!OLI.Product_Type__c != 'Text'}"/>       
</apex:column>
<apex:column headerValue="Line Amount" style="text-align:center;" width="12%;">
    <apex:outputPanel id="fTotalPrice">
        <apex:outputField value="{!OLI.Total_Price_Temp__c}" rendered="{!OLI.Product_Type__c != 'Text'}" />
    </apex:outputPanel>
</apex:column>         
</apex:pageBlockTable>
</apex:outputPanel>
.....

 Controller code:

private List<OpportunityLineItem> OLIs;

//currently selected Opp Line Item(oli)
public OpportunityLineItem currOLI {get;set;}
public List<OpportunityLineItem> getOLIs (){ return OLIs; }

    //CURRENTLY SELECTED OLI ID ( sets the currently selected opportunity Product)
    public String currOLIId { 
         get{ return currOLI.id; }
         set{
             currOLI  = null;
             for(OpportunityLineItem oli:OLIs) {
                 if(oli.id == value) currOLI = oli;
             }  
         } 
     }

	 //method called by Finish button to save all Opp Lines and redirect to Opp view page
    public PageReference finish() {
        if(OLIs.size()>0){
            for(OpportunityLineItem oli:OLIs){ 
            }
            try{ 
                 saveOLIs(); 
            }catch (exception e) {
              ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error saving Products: ' + e.getMessage());
              ApexPages.addMessage(myMsg);   
            }    
        }
        PageReference olip;
        olip = new ApexPages.StandardController(mOpp).view();
        olip.setRedirect(true);
        return olip;
    }
	
	  //save currOLI to OLIs to prevent additional info from being reset on blur
    public PageReference saveOLI2List() {
        for(OpportunityLineItem oli:OLIs){
            if(oli.id == currOLI.id) {
                update currOLI;
                oli = currOLI;
            } 
        }
        return null;
    }
    
/* check all price fields and set to 0 if null (to avoid errors in calculations*/
    public OpportunityLineItem checkPricingFields(OpportunityLineItem oli) {
        //if any of the pricing fields is null, then set to 0
        if(oli.quantity_Temp__c == null || oli.quantity_Temp__c == 0) oli.quantity_Temp__c = 1;
        if(oli.SalesPrice_Temp__c == null) oli.SalesPrice_Temp__c = 0;
        if(oli.Profit__c == null) oli.Profit__c = 0;
        if(oli.Discount_Temp__c == null || oli.Discount_Temp__c < 0) oli.discount_Temp__c = 0;
        if(oli.Unit_Cost_2__c == null) oli.Unit_Cost_2__c = 0;
        if(oli.Line_Discount_Amount__c == null) oli.Line_Discount_Amount__c = 0;
        return oli;
    }
    
    public pagereference calculatePricing_ResetDiscount() {
        calculateOLIDiscountAmt ();
        // currOLI.Line_Discount_Amount__c = 0;
        //currOLI.Discount = 0;
        updateOLI_Pricing ();
        return null;
    }
    /*Used to calculate values for Total Price*/
    public PageReference updateOLI_Pricing (){
        checkPricingFields(currOLI);
        currOLI = calculateTotalPrice(currOLI);
        currOLI = calculateOLIProfit(currOLI);
        //save currOLI to OLI list
        for(OpportunityLineItem oli:OLIs){
            if(oli.id == currOLI.id) {
                oli = currOLI;
            } 
        }
        return null;
    }
    
    private OpportunityLineItem calculateTotalPrice (OpportunityLineItem oli){
        decimal subtotal = oli.quantity_Temp__c * oli.SalesPrice_Temp__c ;
        decimal totalPrice =  subtotal - oli.Line_Discount_Amount__c; 
        oli.total_Price_temp__c = totalPrice;
        return oli;
    }
    
    private OpportunityLineItem calculateOLIProfit (OpportunityLineItem pOLI) {
        Decimal cost = pOLI.Unit_Cost_2__c ; 
        if(pOLI.Line_Discount_Amount__c != null || pOLI.Line_Discount_Amount__c != 0 ) 
            pOLI.Profit__c = (pOLI.Quantity_Temp__c * pOLI.SalesPrice_Temp__c - pOLI.Line_Discount_Amount__c ) - (pOLI.Quantity_Temp__c * cost);
        else
             pOLI.Profit__c = (pOLI.Quantity_Temp__c * pOLI.SalesPrice_Temp__c) - (pOLI.Quantity_Temp__c * cost);
        return pOLI;
    }

    public PageReference calculateOLIDiscountPct (){
        checkPricingFields(currOLI);
        decimal subtotal = currOLI.Quantity_Temp__c * currOLI.SalesPrice_Temp__c;
        currOLI.Discount_Temp__c = currOLI.Line_Discount_Amount__c != 0 ? (currOLI.Line_Discount_Amount__c / subtotal ) * 100: 0 ;
        updateOLI_Pricing();        
        return null;
    }
    
    public PageReference calculateOLIDiscountAmt () {
        checkPricingFields(currOLI);
        decimal subtotal = currOLI.Quantity_Temp__c * currOLI.SalesPrice_Temp__c;
        currOLI.Line_Discount_Amount__c = subtotal != null || subtotal != 0 ? (subtotal / 100) * currOLI.Discount_Temp__c : 0;
        updateOLI_Pricing();
        return null;
    } 

    //this method is used when adding a new Opp Line from a list of PricebookEntries from the selected Pricebook of the Opp
    public PageReference addOLI() {
        try{
            /*Add a new Opp Line from pPBE*/
            if(currPBE != null){
                OpportunityLineItem oli = new OpportunityLineItem();
                if(currPBE.Product2.Product_Type__c != 'Text'){
                  //  if (checkIfProductAddedAlready(currPBEId )) return null;
                }
                oli = initOLI_withDefaults(currPBE);
                OLIs.add(oli);
                newOLIsAdded.add(oli);
                currOLI = oli; 
            }
        }catch (Exception e) {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error adding Product to Opportunity: ' + e.getMessage());
            ApexPages.addMessage(myMsg); 
        }
        return null; 
        
    }
    
    private OpportunityLineItem initOLI_withDefaults(PricebookEntry pbe) {
            OpportunityLineItem oli = new OpportunityLineItem();  
            oli.Quantity_Temp__c = 1;
            oli.Quantity = 1;
            oli.PricebookEntry = pbe;
            oli.PricebookEntryId = pbe.id;
            oli.OpportunityId = mOpp.id;
            oli.UnitPrice =  pbe.UnitPrice;
            oli.SalesPrice_Temp__c = pbe.UnitPrice;
            oli.Unit_cost_2__c = getProdUnitCost(pbe);
            oli.discount_Temp__c = 0;
            oli.Discount = 0;
            oli.Total_Price_Temp__c = oli.UnitPrice;
            oli.Profit__c = oli.UnitPrice - oli.Unit_Cost_2__c;
            oli.Profit__c =  oli.UnitPrice - oli.Unit_Cost_2__c;
            oli.Description = getOLIDescription_FromAccount();
            oli.Line_Discount_Amount__c = 0;
            oli.Line_sorting__c = getNewLineSortingNumber(); // method not shown BUT working as expected
            insert oli;
            oli = loadOLI(oli);
            return oli;
    }
	
    public PageReference saveOLIs() {
        try{
            if(OLIs.size()>0){
                //update each OLI price fields wih temp pricing fields:
                for(opportunityLineItem oli:OLIs){
                    oli.quantity = oli.quantity_temp__c;
                    oli.UnitPrice = oli.SalesPrice_temp__c;
                    oli.Discount = oli.Discount_Temp__c;
                    //oli.Profit__c = oli.Profit__c; 
                }
                //save all olis in list
                upsert OLIs;
            }
        }catch(Exception e){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error saving Opportunity Line Items: ' + e.getMessage());
            ApexPages.addMessage(myMsg);        
        }
        return null;
    }
	
	private void loadOLIs(){
	   OLIs = [Select id, ...and all the needed fields From OpportunityLineItem Where OpportunityId = :mOpp.Id Order by Line_Sorting__c ASC];
	   for(opportunityLineItem o:OLIs){
		   o.Total_Price_Temp__c = o.TotalPrice;
		   o.Quantity_Temp__c = o.Quantity;
		   o.SalesPrice_Temp__c  = o.UnitPrice;
		   o.Discount_Temp__c = o.Discount;
    }
	 
  

 Only relevant code is shown since all other code is for other purposes, such as searching for products, etc. Also removed all debug lines to shorten the amount of code submitted. To note is that I set  standard field values such as Quantity, UnitPrice and Discount all together at the end since from temporary fields.

Hello,

 

I have come across an issue I am struggling to solve but not sure how to approach a solution. The issue is as follows:

 

I have a Vf page that mimics the Multi Product page (the one that is used to add products to an Opp). The main difference is that I also give users the option to enter Discount AMount then recalculate the discount percent so when saving to the database SF will calculate the total price. BUT I have come across an issue when entering a discount amount that translates to a discount percent with more than 2 digits of scale (for example: 365-235 will yield 39,16666666666664%, but SF rounds up to 39,17). This causes an issue because when I save the record to the database the auto calculated total price is 364,98 and not 365. This is because when SF rounds up to 39,17 it translates to 235,02 as the amount discounted.

 

Does anyone know how to  work around this issue?

Hello,

 

Looking for help solving a simple issue that will most likely be a quick fix but yet I've spent too much time trying to crack it. The issue is that I have a pageblocktable with OpportunityLineItems, these can have their fields updated such as Qty and Discount. on the Qty and Discount field's onblur event  I perform an upsert of the OppLine so that the server can calculate the TotalPrice and other relevant fields. Once the save is done, I requery for the record to show the latest updated values from the server, BUT even though in the debug log I see that the record got updated, when I rerender the field (even tried rerendering the entire table) the value simply disappears as if by "magic". 

 

How can I get the row rerendered with the new values in the record??? Please assist! Below is code for controller and VF page where the issue seems to be happening:

 

VF page table: (NOTE: some fields that are static and do not get updated have been removed to downsize post length)

 <apex:outputPanel id="tablePnl">  
        <apex:pageblockTable value="{!OLIs}" var="OLI" id="OLIList" >
            <apex:column id="DelCol"> 
                {!OLI.Id}  -- {!OLI.TotalPrice}                   
                <apex:commandButton value="Delete" action="{!del}" rerender="tablePnl,detailPanel">
                    <apex:param name="delname" value="{!OLI.id}" assignTo="{!currOLIid}"/> 
                </apex:commandButton>          
            </apex:column>                    
            <apex:column headerValue="Quantity"> 
                <apex:inputField value="{!OLI.Quantity}"  id="fQTY" required="{!OLI.PriceBookEntry.Product2.Name != null}"  >
                    <apex:actionSupport event="onblur" rerender="tablePnl,fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!saveOLI}" disabled="{!(OLI.Quantity == null || OLI.Quantity <= 0) || (OLI.UnitPrice == null || OLI.UnitPrice <= 0)}"  >
                        <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
                    </apex:actionSupport>
                </apex:inputField>
            </apex:column>             
            <apex:column headerValue="Unit Cost" >
                <apex:inputField value="{!OLI.Unit_Cost__c}" id="fUnitCost"/>       
            </apex:column>
            <apex:column headerValue="Sales Price ex VAT"">
                <apex:inputField value="{!OLI.UnitPrice}"/>
            </apex:column>
            <apex:column headerValue="Line Disc Pct.">
                <apex:inputField value="{!OLI.Discount}" id="fDiscPct">
                <apex:actionSupport event="onblur" rerender="fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!saveOLI}" disabled="{!(OLI.Quantity == null || OLI.Quantity <= 0) || (OLI.UnitPrice == null || OLI.UnitPrice <= 0)}"  >
                        <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
                    </apex:actionSupport>
                </apex:inputField>
            </apex:column>
            <apex:column headerValue="Total Price">
                    <apex:outputField value="{!OLI.TotalPrice}" id="fTotalPrice"  />
            </apex:column>         
        </apex:pageBlockTable>
    </apex:outputPanel>

 And this is the code in the controller that performs the saveOLI action (saving the record):

    public PageReference saveOLI() {
        system.debug('###currOLI: ' + currOLI);
        currOLI.TotalPrice = null;
        try{
        upsert currOLI;
        currOLI = loadOLI(currOLI);
        for(OpportunityLineItem o: OLIs) {
            if(o.id == currOLI.id) {
                o = currOLI;
                system.debug('###After saveOLI OLIs(o) from currOLI: ' + o);
            }
        }
        }catch(Exception e) {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error saving Opportunity Product: ' + e.getMessage());
            ApexPages.addMessage(myMsg);
        }
        return null;
    }

 

Hello all,

 

I am trying to create a VF page that will list products (product2) in a table BUT I want to be able to select cetain rows. For this I am using a wrapper class to create the Product with a selected boolean. The problem is that I need to create a table where the fields shown are defined in a Product field set. I have been able to get the controller to load all the products I need and also to create the wrapper products (wProds) BUT I am not sure how to build the table, can someone assist??? Below is my best shot at it.....

 

Upon saving the page I get this error:

 
Error: Invalid field for SObject Product2

 

 

I know the error is in this line: 

 

<apex:outputText value="{!w.Product.[f.fieldPath]}"/>

 

But not sure what im doing wrong OR how to fix it.

 

VF PAGE:

<apex:page controller="opportunityList2Con" tabStyle="Opportunity" >
    <apex:form >
        <apex:pageBlock tabStyle="Opportunity"  >
        <apex:sectionHeader subtitle="{!Opp.Name}" title="Add products to "  />
        <apex:pageblocksection title="Opportunity Line Items" >
        </apex:pageblocksection>
        
        <apex:pageblocksection title="Select Products" columns="1" >
          
          <apex:pageBlockTable value="{!wProds}" var="w">
              <apex:column headerValue="Selected" width="30px;">
                  <apex:inputCheckbox value="{!w.selected}"/>
              </apex:column>
              <apex:repeat value="{!fields}" var="f">
                  <apex:column >
                     <!-- <apex:outputText value="{!w.Product.[f.fieldPath]}"/> COMMENTED OUT SINCE IT WILL NOT SAVE AS IS-->
                  </apex:column>
              </apex:repeat> 
               
          </apex:pageBlockTable>
        </apex:pageblocksection>
        
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

 CONTROLLER: 

 

public class opportunityList2Con {

//Product and Oli Field Names Map
//Map<String, Schema.SObjectField> prodFields = Schema.SObjectType.Product2.fields.getMap();
Map<String, Schema.SObjectField> OliFields = Schema.SObjectType.OpportunityLineItem.fields.getMap();
Map<String, Schema.SObjectField> PbEntryFields = Schema.SObjectType.PriceBookEntry.fields.getMap();

public Opportunity Opp {get;set;}
private List<PricebookEntry> lstPBEs {get;set;}
private set<id> setProdIds {get;set;}
public List<Product2> lstProducts {get;set;}
private String oId;
public List<wProd> wProds {get;set;}

public opportunityList2Con () {
    
    oId = ApexPages.currentPage().getParameters().get('oId');
    //get Opp Id and Pricebook2Id
    Opp = [Select id, Name, Pricebook2Id, CloseDate From Opportunity where id = :oId LIMIT 1];
    
    //Get all Pricebookentries available for Opportuniy Pricebook Id:
    lstPBEs = [Select IsActive, Product2Id, Pricebook2Id, Id From PricebookEntry where isActive = true and PriceBook2Id = :Opp.Pricebook2Id];
    
    // Get all products using dynamic query:
    setProdIds = new set<id>();
    for(PricebookEntry pb:lstPBEs) { this.setProdIds.add(pb.Product2Id); }
    lstProducts = new List<Product2>();
    lstProducts = this.loadProducts();
    buildWProds();
    system.debug('###wProds: ' + wProds);
     
}

    public List<Schema.FieldSetMember> getFields() { return SObjectType.Product2.FieldSets.ALL_FIELDS.getFields(); }

    private List<Product2> loadProducts() {
        String query;
        String fieldQuery = '';
        String fieldsStr = '';
        for(Schema.FieldSetMember f :SObjectType.Product2.FieldSets.ALL_FIELDS.getFields()) {
            fieldsStr += f.getFieldPath() + ',';
        }
        fieldsStr.trim();
        Integer len = fieldsStr.length();
        fieldQuery= fieldsStr.left(len-1);
        query = 'SELECT ' + fieldQuery + ' FROM Product2 WHERE IsActive = true AND id in:setProdIds';
        lstProducts = Database.query(query);
        return lstProducts;
    }
    
    private void buildWProds() {
        wProds = new List<wProd>();
        for(Product2 p:lstProducts) {
            wProd wp = new wProd(p);
            wProds.add(wp);
        }
    }
    
    //Product wrapper class
    public class wProd {
        public Boolean selected {get;set;}
        public Product2 Product {get;set;}
        
        public wProd (Product2 pProd) {
            selected = false;
            Product = pProd;
        }
    }
        
 
    
}

 

 

 

 

Kind regards,

Mauricio

 

Hello,

 

I have a custom Time object to track timesheet info for cases, accounts and other objects. Part of the entry is to enter the start and end times, but this is a normal text field, so I updated the functionality putting together a visualforce that uses jquery to create a time spinner on both time entries, this way you can easily select an hour and minute for start and end times. My problem lies on the component to be used for inputting the time. Since jquery styles the input to add the sppinner arrows all I need is an <input>. So I tried this BUT I cannot get the html input text to pass in the values to the controller, although the inputs layout correctly in the page. See below pic and code:

 

VF page:

<apex:pageBlockSection title="Time and conditions" columns="2">
            <apex:inputField value="{!time.Date__c}" required="true"/>
            <apex:inputField value="{!time.Workplace__c}" required="true"/>
            <apex:pageBlockSection showHeader="false" columns="4">
                <apex:outputLabel style="align:right;float:right;text-align:right;font-size: 91%;font-weight: bold;color:rgb(66, 66, 51);" >Time Start:</apex:outputlabel>
                <input id="hourSpinnerStart" class="hourSpinner" value="{!startTimeHrs}" style="width:20px;height:11px;float:left;"/>
                <input id="minuteSpinnerStart"  class="minuteSpinner"  value="{!startTimeMins}" style="width:20px;height:11px;"/>
            </apex:pageBlockSection>
            <apex:inputField value="{!time.Own_car_used__c}"/>
            <apex:inputField value="{!time.Lunchtime__c}"/>
            <apex:inputField value="{!time.Full_day_purchased__c}"/>
                 <apex:pageBlockSection showHeader="false" columns="4">
                    <apex:outputLabel style="align:right;float:right;text-align:right;font-size: 91%;font-weight: bold;color:rgb(66, 66, 51);" >Time End:</apex:outputlabel>
                    <input id="hourSpinnerEnd" class="hourSpinner" value="{!endTimeHrs}" style="width:20px;height:11px;"/>
                    <input id="minuteSpinnerEnd"  class="minuteSpinner"  value="{!endTimeMins}" style="width:20px;height:11px;"/>
                  </apex:pageBlockSection>

            <apex:inputField value="{!time.Urgent_Request__c}"/>
            <apex:inputField value="{!time.Unspecified__c}"/>
            <apex:inputField value="{!time.Incoming_mobile_call__c}"/>
            <apex:inputField value="{!time.Unspecified_Time__c}"/>
            <apex:inputField value="{!time.Standby_Time__c}"/>     
        </apex:pageBlockSection>

jquery in VF page:

    <script>
    var ptime;
        $j = jQuery.noConflict();
        $j(function() {
            ptime = $j("input[id$='hourSpinner']").val(); 
            $j(".hourSpinner").spinner({min: 0,max: 23,step: 1,start: 0,precision: 0,width: '2em'});
            $j(".minuteSpinner").spinner({min: 0,max: 45,step: 15,start:0,precision: 0,width: '2em'});
        });
    </script>

 

 

 This renders correctly in the page since both the spinners are one right beside the other. The inputs are binded to a properties in the controller so to receive the values.

 

Controller code:

public class Time_NewEntry {
    private SFL5_time__c mTime;
    public String retURL;
    //Time fields, these will map to Start and End time fields on the Time object
    public String startTimeHrs {get;set;}
    public String endTimeHrs {get;set;}
    public String startTimeMins {get;set;}
    public String endTimeMins {get;set;}

    public Time_NewEntry() {
        mTime = new SFl5_Time__c();
       // List<RecordType> recType = [Select id From RecordType Where Name = 'Project Time Read Write' LIMIT 1];
       // mTime.RecordTypeId = string.valueOf(recType[0].id).left(15);
        retURL =  ApexPages.currentPage().getParameters().get('retURL');
    }

    public SFL5_Time__c getTime() {
        return mTime;
    }
    
    public PageReference save(){
        if(mTime.Unspecified__c == true) {
            if(mTime.Unspecified_Time__c == null) mTime.Unspecified_Time__c.addError('If Unspecified is checked, then must specify a Time');
        }else{
            //ELSE Time start/end must be inserted:
            system.debug('###startTimeHrs:' +startTimeHrs);
            system.debug('###startTimeHrs is blank:' + String.isBlank(startTimeHrs));
            if(startTimeHrs == null) {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Must enter Start time hour');
                ApexPages.addMessage(myMsg);
                return null;
            }else if(endTimeHrs == null) {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Must enter End time hour');
                ApexPages.addMessage(myMsg);
                return null;
            }else if(startTimeMins == null){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Must enter Start time minutes');
                ApexPages.addMessage(myMsg);
                return null;
            }else if(endTimeMins == null){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Must enter End time minutes');
                ApexPages.addMessage(myMsg);
                return null;
            }           

            system.debug('###BEFORE Entered start time: ' + startTimeHrs +':'+ startTimeMins );
            system.debug('###BEFORE Entered end time: ' + endTimeHrs +':'+ endTimeMins );
            
            if(startTimeHrs.length() == 1) startTimeHrs = '0' + startTimeHrs;
            if(endTimeHrs.length() == 1) endTimeHrs = '0' + endTimeHrs;
            if(startTimeMins.length() == 1) startTimeMins = '0' + startTimeMins;
            if(endTimeMins.length() == 1) endTimeMins = '0' + endTimeMins;
            
            system.debug('###Entered start time: ' + startTimeHrs +':'+ startTimeMins );
            system.debug('###Entered end time: ' + endTimeHrs +':'+ endTimeMins );
            mTime.Time_start_txt__c = startTimeHrs +':'+ startTimeMins ;
            mTime.Time_end_txt__c =  endTimeHrs +':'+ endTimeMins;
           
            system.debug('###Start time: ' + mTime.Time_start_txt__c );
            system.debug('###End time: ' + mTime.Time_end_txt__c);
            system.debug('### Inserting new time: ' + mTime);
        }
            try{
                insert mTime;
                PageReference timeView = new PageReference('/'+mTime.id);
                timeView.setRedirect(true);
                return timeView;
            }catch(Exception e) {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error saving Time record: ' + e.getMessage());
                ApexPages.addMessage(myMsg);
                return null;
            }
    }

}

 

If I create a Time and assign a time to the spinner it gives NULL, see debug log:

 

23:16:54.091 (91199000)|USER_DEBUG|[30]|DEBUG|###startTimeHrs:null
23:16:54.091 (91295000)|USER_DEBUG|[31]|DEBUG|###startTimeHrs is blank:true

 

HOW CAN I GET THE CONTROLLER TO USE THE TIME I ENTER IN THE TIME SPINNER(S)?????

 

 

I tried changing the input tags to apex:inputText but this screws up the layout, but the value does get passed to the controller correctly and the time record is created successfully. The problem with this is that the two spinners are not one beside the other, but rather equally spaced causing it to look awkward.

 

 

PLEASE HELP!!!! THANK YOU

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,

 

I have a button I am trying to use to callout to an external web service but it is giving me a 'No operation available for request' error.  basically I have a custom button with an Execute Javascript behavior. The button code is here:

 

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
sforce.debug.trace=true;

var result = sforce.apex.execute("NAV_Webservice_Functions_MR","sendSO2NAV_buildStream", {pSOId:"{!SCRB_SalesOrder__c.Id}"});

 

The class code is as follows: (i've removed alot of the element additions to the xml stream writer to save space)

 

global class NAV_Webservice_Functions_MR {
    private static SCRB_SalesOrder__c mSO;
    private static List<SCRB_SalesOrderLineItem__c> mSOIs; 

    
// Local method to build Create SO request.
public static void sendSO2NAV_buildStream (String pSOid) {
    string ErrStr;
    string XMLIn;         
    XmlStreamWriter w = new XmlStreamWriter();
    mSO = getSO(pSOid);
    mSOIs = getSOIs(pSOid); 
        w.writeStartDocument(null, '1.0');
        w.writeStartElement(null, 'SendSalesDocumentRequest', null);
        w.writeStartElement(null, 'action', null); 
    //Open main element (Sales Document Info)
    system.debug('### mSO ' + mSO);
        w.writeStartElement(null, 'SalesHeader', null);                      
            AddElementToXMLStream(w,null,'AccountId__c',mSO.AccountId__c,null);                           
            AddElementToXMLStream(w,null,'Currency_Code__c',mSO.Currency_Code__c,null);
            AddElementToXMLStream(w,null,'ShippingStreet__c',mSO.ShippingStreet__c,null);                               
        w.writeEndElement(); //end salesheader
        
    //Open SOIs element holder (inside all SOIs for SO)   
        w.writeStartElement(null, 'SalesLines', null); 
            for(SCRB_SalesOrderLineItem__c soi: mSOIs){
            w.writeStartElement(null, 'SalesLine', null);
            AddElementToXMLStream(w,null,'ProductId__c',soi.ProductId__c,null);
        AddElementToXMLStream(w,null,'Contract_Payment_Start_Date__c',String.valueOf(soi.Contract_Payment_Start_Date__c),null);
            AddElementToXMLStream(w,null,'VAT_Prod_Posting_Group__c',soi.VAT_Prod_Posting_Group__c,null);                                                                                                                                                                                                                                                                          
            //Open SOID elements holder (contacts for SOIs)
            w.writeStartElement(null, 'SalesLineDetails', null);
                for(Sales_Order_Item_Detail__c  soid : [SELECT Id, Name, Sales_Order_Item__c, Contact__c, Contact__r.NAV_Contact_No__c FROM Sales_Order_Item_Detail__c WHERE  Sales_Order_Item__c = : soi.id]) {  
                  w.writeStartElement(null, 'SalesLineDetail', null);
                  AddElementToXMLStream(w,null,'NAV_Contact_No__c',soid.Contact__r.NAV_Contact_No__c,null);
                  w.writeEndElement(); //end saleslinedetail
                }
            w.writeEndElement(); //end saleslinedetails
        w.writeEndElement(); //end salesline   
        }
            w.writeEndElement(); //end saleslines      
        w.writeEndDocument();
        XMLIn = w.getXmlString();
        w.close();  
    //THE ACTUAL METHOD THAT CALLS THE WEB SERVICE IS COMMENTED OUT BUT THE ERROR STILL APPEARS!!!!
    //sendSO2NAV_sendRequest(mSO, XMLIn);   
}


// Web service callout  to send the request. Callback to local methodto process results
 WebService Static void sendSO2NAV_sendRequest(SCRB_SalesOrder__c pSO, String strXML) {
    String xmlresponse = SendNAVSoapDoc(pSO.ERP_Company_Id__c,'wssalesmethods','UpsertSalesDocFromXML_TEST',strXML);         
    //process response from Callout. COMENTED OUT AND REMOVED FROM CLASS TO SAVE SPACE
    //sendSO2NAV_processResponse(xmlresponse);
} 


//////////////////////////////////////////////////////////////////////
    
        public static string SendNAVSoapDoc(string NAVCompanyName, string CUName,string CUFunction,string XMLIn) {
        

        CP_NAVWebservice__c CPSetup = CP_NAVWebservice__c.getInstance('CPSetup');        
        if (NAVCompanyName=='' || NAVCompanyName==null) {NAVCompanyName = CPSetup.NAVWS_Company_Name__c;}
             
        Http http = new Http();
     
        HttpRequest req = new HttpRequest();
     
        req.setMethod('POST');
        req.setEndpoint(CPSetup.Proxy_Base_URL__c + ':' + String.valueOf(Integer.valueOf(CPSetup.Proxy_Port__c)) + '/service');  
        req.setTimeout(Integer.valueOf(CPSetup.Proxy_Timeout_ms__c));  
        Blob headerValue = Blob.valueOf(CPSetup.Proxy_Username__c + ':' + CPSetup.Proxy_Password__c);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        req.setHeader('Content-type', 'text/xml; charset="utf-8"');
        req.setHeader('SOAPAction', '"urn:INavWinService/RunNAVCodeunit"');
    
        string SoapDoc = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/>'+
                  '<soapenv:Body><RunNAVCodeunit><NAVWSEndpoint>'+
                  CPSetup.NAVWS_Endpoint__c + NAVCompanyName +'/Codeunit/'+CUName+
                  '</NAVWSEndpoint><CodeunitName>'+CUName+'</CodeunitName>'+
                  '<CodeunitFunction>'+CUFunction+'</CodeunitFunction><XMLIn><![CDATA['+XMLIn+']]></XMLIn>'+
                  '</RunNAVCodeunit></soapenv:Body></soapenv:Envelope>'; 
                  
        req.setbody(SoapDoc);
        System.debug('Trying ' + req.getEndpoint());
        System.debug('Auth Header: ' + req.getHeader('Authorization'));
        System.debug('SOAP Boudy: '+SoapDoc);
        HttpResponse resp = http.send(req);
        System.debug('XML RESPONSE: \n\n' + resp.getBody());           
                  
        return resp.getBody();
    }
     
    
    
    //utility method to add an element to a streamwriter
    public static void AddElementToXMLStream(XmlStreamWriter w, string prefix, string name, string value, string namespaceURI){
        w.writeStartElement(prefix, name, namespaceURI);
        if (value==Null) { value =''; } 
        w.writeCharacters(value);
        w.writeEndElement(); 
    } 

    //Utility methods to get object data from SF. REMOVED MANY FIELDS FROM SOQL FOR SPACE SAVING REASONS IN POST
    public  static List<SCRB_SalesOrderLineItem__c> getSOIs (id pSOId) {
        List<SCRB_SalesOrderLineItem__c> SOItems = new List<SCRB_SalesOrderLineItem__c>();
        SOItems = [SELECT Contract_Manager__c,Contract_Payment_Start_Date__c,Contract_Start_Date__c,Contract_Template__c,
                Contract__Id, Name, Quantity__c  FROM SCRB_SalesOrderLineItem__c WHERE SalesOrderId__c = :pSOId];
        return SOItems; 
    }    
    public static SCRB_SalesOrder__c getSO(id pSOid){
           if(pSOid == null) {
                    mSO = new SCRB_SalesOrder__c() ;                    
           }else{  
                 mSO = [SELECT   Account_PriceBookId__c, AccountId__c, BillingCity__c,BillingCountry__c, BillingFax__c, BillingPhone__c, BillingPostalCode__c, BillingStreet__c, Billing_Account__c, Billing_Contact__c, CreatedById, CreatedDate, CurrencyIsoCode FROM SCRB_SalesOrder__c WHERE id = :pSOid]; 
            }     
            return mSO;
   }
   
   
}

 

This is the trace response I get from the button:

 


<textarea cols=80 rows=5 wrap=hard>
?xml version="1.0" encoding="UTF-8"?

soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
soapenv:Body
soapenv:Fault
faultcode
soapenv:Client
/faultcode

faultstring
No operation available for request {http://soap.sforce.com/schemas/package/NAV_Webservice_Functions_MR}sendSO2NAV_buildStream, please check the WSDL for the service.
/faultstring

/soapenv:Fault
/soapenv:Body
/soapenv:Envelope
</textarea>

 

 

 The callout is broken up in three methods, one to build the request, another to execute it and another to process and parse the results. I've removed some of the processing logic since it is irrelevant at this point (web service is not even being called). I also commented out the actual call to the web service method so the issue is with the button or the method that builds the XML stream. Could the issue be in the URL? Shouldn't it be pointing to the http://soap.sforce.com/schemas/class/NAV_Webservice.....

 

Please assist!!!!! It is urgent!!!!!

Hello ,

 

I am usinga VF page to override the Edit page of Opportunity but I want to be able to control which users can see it and which are rerouted to the standard edit page. To do this I added an If to the Action parameter of the VF page tag.

 

So in this example I would reroute spaniard users to the standard Edit page and everyone else to the VF page.

 

action= "{!if($User.Country <>'Spain', null, URLFOR($Action.Opportunity.Edit, Opportunity.id, null, true))}"

 

BUT I also need to recreate the functionality for the new Opportunity.

 

I wanted to do the same for the New Opportunity VF page, BUT, I have to call the "goToQuoteOverride" method in the same action tag. So I wrote the following (without succes):


action= "{!if($User.Country <>'Spain', goToQuoteOverride, URLFOR($Action.Opportunity.New, Opportunity.id, null, true))}"

 

I also tried to put parenthesis () but also did not work.

 


action= "{!if($User.Country <>'Spain', goToQuoteOverride(), URLFOR($Action.Opportunity.New Opportunity.id, null, true))}"

 

Any idea how to acomplish this???

HEllo,

 

I havea visualforce page that I am trying to create a bar chart. I am using js remoting to call a method in the controller to get the result data BUT it is giving me a Null reference error when trying to access the account variable in the controller to use as a query parameter in the @RemoteACtion method.

 

 

CVF page:

<apex:page extensions="GoogleChartsController" sidebar="false" standardController="Account" showHeader="false" pageStyle="Account"  > 
    <apex:includeScript id="a" value="https://www.google.com/jsapi" />     
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(initCharts);
        //load all the charts..
        function initCharts() { 
              GoogleChartsController.loadChildCases(function(resultCase, event){  
                  var visualization = new google.visualization.ColumnChart(document.getElementById('caseChart'));
                  var data1 = new google.visualization.DataTable();  
                  data1.addColumn('string', 'Cases');
                  data1.addColumn('number', 'Cases');       
                  //add rows from the remoting results
                  for(var i =0; i < resultCase.length; i++){
                      var r = resultCase[i];
                      data1.addRow([r.Id, r.expr0]); 
                   }
                    // all done, lets draw the chart with some options to make it look nice.
                    visualization.draw(data1, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:150,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
              }, {escape:true});
              
          } 
    </script>
     <div id="caseChart" />
</apex:page>

 And this is the controller:

global class GoogleChartsController {
 global static Account acc; 
 
    public GoogleChartsController(ApexPages.StandardController controller) {
        acc = (Account)controller.getRecord();
    }

    @RemoteAction   
    global static AggregateResult[] loadChildCases() {
        AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case  WHERE AccountId = :acc.id Group By ParentId ];
        return caseLst;
    }
}

 

Please let me know where I am making an error in this.

 

 

 

Hello,

 

I am trying to get the AccId of the current page record to pass into (or get it in the method somehow) so that i can use it as a parameter for a query. Basically I have the following code in a VF page:

 

 

  <apex:includeScript id="a" value="https://www.google.com/jsapi" />     
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(initCharts);

        //load all the charts..
        function initCharts() { 

              var param =  location.search.substring(1);
              var vars = param.split("&");
              var pair = vars[0].split("=");
              
              var aID = pair[1];
              alert (aID);
              //LOAD CASE CHART DATA
              GoogleChartsController.loadChildCases(aId, function(resultCase, event){
                   
                   alert('Data1 set: ' + resultCase);
                  var visualization = new google.visualization.ColumnChart(document.getElementById('caseChart'));
                   alert('div:'+ document.getElementById('caseChart'));
                  var data1 = new google.visualization.DataTable();  
                  data1.addColumn('string', 'Cases');
                  data1.addColumn('number', 'Cases');       
                  //add rows from the remoting results
                  for(var i =0; i < resultCase.length; i++){
                      var r = resultCase[i];
                   // alert('result item:'+r);
                   // alert('result item:'+r.Id + ' - '+  r.expr0);
                      data1.addRow([r.Id, r.expr0]); 
                   }
                    // all done, lets draw the chart with some options to make it look nice.
                    visualization.draw(data1, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:150,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
              }, {escape:true});
              
          } 
    </script>
        <div id="caseChart" />

 It works fine if I don't pass any parameter to it. but as soon as I add the var aId in the remoting call, it fails miserably! I have also tried to use the Apexpages.currentPage parameters to get the ID but it fails as a null reference.

 

This is the controller code:

 

global with sharing class GoogleChartsController {
 global static Account acc;
 
    public GoogleChartsController(ApexPages.StandardController controller) {
        acc = (Account)controller.getRecord();
        //system.debug('###Acid: ' + acc);
    }


    @RemoteAction   
    global static AggregateResult[] loadChildCases(String aId) {
        system.debug('##Page Param: ' + aId);
        AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case  Group By ParentId];
        system.debug('##Case Aggregate list: ' + caseLst);
        return caseLst;

    }

 Referencing the static acc account gives null, so I am not sure how to achieve this. Please assist!!

 

 

 

 

 

 

 

I have a custom button on a custom object that executes some javascript which calls a web service method and populates parameters to call the EmailAuthor link in SF. In sandbox it is working just fine and the code I cannot see any difference. The problem is when I click the button in production I get the following message:

 

The value of the "p3_lkid" parameter contains a character that is not allowed or the value exceeds the maximum allowed length

 

This is the code of the button:

 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var docId = sforce.apex.execute("SalesDoc_PDFAttachment","getSalesDoc_PDFDocument", {salesDoc_ID:"{!SCRB_SalesOrder__c.Id}",pAttID:"{!SCRB_SalesOrder__c.Active_PDF_Attachment_ID__c}" });

 

location.replace('/_ui/core/email/author/EmailAuthor?retURL=/{!SCRB_SalesOrder__c.Id}&p2_lkid={!SCRB_SalesOrder__c.Selling_ContactId__c}&rtype=003&p3_lkid={!SCRB_SalesOrder__c.Id}&doc_id='+docId);

 

I cannot see any errors and when the link is executed the values populated into the url are:

 

 

retURL= the id of the custom record

p2_lkid= the contact to send the email to

p3_lkid= the id of the custom record

doc_id= the ID value of the SF document returned by the web service method.

 

Can anyone spot where this is failing?

I have an urgent requirement to create a visuaforce template (or other similar solution) where I can email an attached PDF from a custom object. Basically I have a Sales Order object and create a pdf for that record then would want to email it from a button. I know I can code a visualforce page with all the code logic but did not have enough time to complete. Therefore I am using the EmailAuth functionality from Salesforce BUT I do not know how to add this PDF attachment to the email. 

 

I tried using the doc_id= parameter but it receives a document record and I have an attachment instead. I therefore created a visualforce template but I have no idea how to use the messaging:attachment tab to add the PDF to the email.

 

Below is what I have created

 

The custom button code:

"/_ui/core/email/author/EmailAuthor?p2_lkid="{!SCRB_SalesOrder__c.Selling_ContactId__c}"&rtype=003&p3_lkid="{!SCRB_SalesOrder__c.Id}"&new_template=1&template_id=00XM0000000Dglk

 

VF email template:

<messaging:emailTemplate subject="Sales Doc Email PDF" recipientType="Contact" relatedToType="SCRB_SalesOrder__c">
<messaging:plainTextEmailBody >


Dear {!recipient.FirstName} {!recipient.LastName},

I have attached the {!relatedTo.Id}, as we discussed. 

Please call me if you have any questions.

Sincerely,
{!$User.FirstName} {!$User.LastName}
{!$User.Phone}


</messaging:plainTextEmailBody>

<messaging:attachment filename="Sales Doc (Quote) Attachment" renderAs="pdf"  >
   <c:PDF_Attachment SalesDoc_ID="{!relatedTo.Id}" rendered="true"> </c:PDF_Attachment> 
</messaging:attachment>

</messaging:emailTemplate>

 

VF component:

<apex:component controller="SalesDoc_PDFAttachment_Controller" access="global" >
<apex:attribute name="SalesDoc_ID" Description="reference to Parent Sales Document" type="ID" assignTo="{!salesDoc_ID}" />
</apex:component>

  and the controller for the component: 

global class SalesDoc_PDFAttachment_Controller {

SCRB_SalesOrder__c SD {get;set;}
Blob salesDoc_PDF {get;set;}
Attachment att {get;set;}
Id salesDoc_ID {get;set;}



    global SalesDoc_PDFAttachment_Controller() {
    system.debug('###PDF Attach -SD id: ' + salesDoc_ID ); 
    //Set parent Sales Doc
    SD = [SELECT id, Active_PDF_Attachment_ID__c FROM SCRB_SalesOrder__c WHERE Id = :salesDoc_ID LIMIT 1];
    salesDoc_ID = SD.id;
    
    if(SD <> null) {
    //get attachment if exists;
    Attachment att = [SELECT id, Body FROM Attachment WHERE id= :salesDoc_ID LIMIT 1 ];
    salesDoc_PDF = att <> null ? att.Body : null;
    System.debug('##PDF Attach -att: ' + att);
    }
    }

}

 

This code gives me a "List has no rows for assignment to SObject" error but I am sure I am not doing things correctly.

Hello,

 

I am trying to reproduce the EmailAuthor functionality to send an attachment of a custom object from a button without having to recode the entire email features.  I added a button with some parameters and I am able to get all except the attachment itself.

 

I added a field to the custom object that is populated via integration when the server generates a PDF file and attaches it to the Sales Document (the custom object). I added the &doc_id= parameter with the Id from the field but I am not getting the attachment added to the email page. See code below:

 

 

"/_ui/core/email/author/EmailAuthor?p2_lkid="{!SCRB_SalesOrder__c.Selling_ContactId__c}"&rtype=003&p3_lkid="{!SCRB_SalesOrder__c.Id}&doc_id={!SCRB_SalesOrder__c.Active_PDF_Attachment_ID__c}

 

Where {!SCRB_SalesOrder__c.Active_PDF_Attachment_ID__c} represent the text field populated with the attachment ID. This is the file that should be attached to the email when the button is pressed in the Sales Document (custom object). What am I doing wrong that I cannot get this file attached to the email????

 

Thank you

Hello,

 

I have tried everything I can think of and I cannot get a pageblocktable to modify the column width to custom sizes and this is having a negative impact on the usability of the page. I have tried adding the width tag to the columns, I also tried using a style tag with a width parameter. I also tried defining the columns width in the pageblocktable definition but NO LUCK.  I am not sure what is causing the columns not to change their sizes, although I have a feeling that some of the inner tags in the columns may have something to do with it. I say this because I also tried changing their width without any tag other than the label and the column tag and it works. Please see code below, the first is the working example i have tried where columns do expand/contract to the respective width. The second example is the one I need to use in my VF page and the one that does not want to cooperate and change column widths. Please assist!

 

the table in blue is the example table adn the red one is the one I need for it to expand contract, right now it is trying to set widths using a style tag, but as I mentioned already, other methods are not working either.

 

 

<apex:page controller="SalesDocumentManager_Controller" tabStyle="SCRB_SalesOrder__c" id="thePage" >
<apex:sectionHeader title="Create Sales Document" subtitle="{!mAccount.Name}"/>
<apex:form id="theForm">
<apex:outputPanel id="msgs" >
<apex:messages style="font-weight:bold; color:red; font-size:medium; text-align:center; " />
<apex:actionStatus startText="Saving changes......" id="saveStatus" startstyle="font-weight:bold; color:green; font-size:medium; text-align:center; " layout="block" />
</apex:outputPanel>

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

<!----------------------------->
<!--SALES ORDER ITEMS SECTION-->
<!----------------------------->

<apex:pageblock title="TEST table">
<apex:pageBlockTable style="width:100%" value="{!SOItems}" var="SOI" >
<apex:column headerValue="Action" style="width:150px">
<apex:commandLink value="Del" action="{!del}" rerender="tablePnl,detailPanel" style="font-weight:bold" >
<apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
&nbsp;|&nbsp;
<apex:commandLink value="Save" action="{!saveSOI}" rerender="tablePnl,detailPanel" style="font-weight:bold" status="saveSOIstatus" >
<apex:param name="savename" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:column>
<apex:column style="width:250px" value="{!SOI.Product_Name_Custom__c}"/>
<apex:column style="width:250px" value="{!SOI.Line_Type__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>

<apex:pageblock title="Sales Order Items" tabStyle="SCRB_SalesOrder__c" id="SOIpgblk" >

<apex:messages style="font-weight:bold; color:red; font-size:medium; text-align:center; " />
<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl" disabled="{!NOT(SOsaved)}" id="btnAddSOI" />

</apex:pageBlockButtons>
<apex:actionStatus startText="Saving record......" id="saveSOIstatus" startstyle="font-weight:bold; color:green; font-size:small; text-align:center; " layout="block" />
<apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel, tablePnl" immediate="true">
<apex:param id="prodId" value="" name="prodId"/>
</apex:actionFunction>

<apex:actionRegion id="prodUpdate" renderRegionOnly="false">
<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" style="width:100%">
<apex:column headerValue="Action" >
<apex:commandLink value="Del" action="{!del}" rerender="tablePnl,detailPanel" style="width:150px" >
<apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
&nbsp;|&nbsp;
<apex:commandLink value="Save" action="{!saveSOI}" rerender="tablePnl,detailPanel" style="font-weight:bold" status="saveSOIstatus" >
<apex:param name="savename" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Line type" id="ltcol" style="width:50px">
<apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
<apex:inputField value="{!SOI.Line_Type__c}" id="fLineType" required="true" >
<apex:actionSupport event="onchange" rerender="tablePnl" action="{!resetRowData}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>

</apex:inputField>
</apex:actionRegion>
</apex:column>

<apex:column headerValue="Product" id="prodCol" style="width:50px">
<apex:actionRegion id="prodRgn">
<apex:inputField value="{!SOI.Product_Name_Custom__c}" id="fProd" onFocus="this.blur()" >
<apex:actionSupport event="onchange" reRender="detailPanel" action="{!loadSOIDs}" >
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
</apex:inputField>


<apex:commandLink onclick="prodLookup(this.parentNode.parentNode)" reRender="fProd">
<apex:image value="{!$Resource.lookupIcon}"/>
<apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Description" style="width:50px">
<apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
<apex:inputField value="{!SOI.Description__c}" id="fDescr" >
<apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Quantity" style="width:50px">
<apex:actionRegion >
<apex:inputField value="{!SOI.Quantity__c}" id="fQTY" required="{!SOI.Product_Name_Custom__c <> null}" >
<apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
<apex:actionSupport event="onchange" rerender="fDiscAmt,colTest,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIQty" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Unit Cost" style="width:50px" >
<apex:inputField value="{!SOI.Unit_Cost__c}" id="fUnitCost">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIUC" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Sales Price ex VAT" style="width:50px">
<apex:inputField value="{!SOI.SalesPrice__c}" id="fSalesPrice" >
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOISP" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Pct." style="width:50px">
<apex:inputField value="{!SOI.Line_Discount_Pct__c}" id="fDiscPct">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIDP" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Amt." style="width:50px">
<apex:inputField value="{!SOI.Line_Discount_Amount__c}" id="fDiscAmt">
<apex:actionSupport event="onchange" rerender="fDiscPct,fTotalPrice,fProfit" action="{!calculateDiscPct}">
<apex:param name="currSOIDA" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Profit" style="width:50px">
<apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>
</apex:column>
<apex:column headerValue="Total Price" style="width:50px">
<apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
</apex:column>
<apex:column headerValue="Line Status" style="width:50px">
<apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus" />
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:actionRegion>


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

Hello,

 

I havea pageblocktable updated from the controller where I list order items. One of the fields is the product lookup (custom made, not the standarad one from SF). I point the inputText of the lookup to a productID__r.Name field of the product and also update some other fields in teh table when teh user changes the product reference. Alont htese rerenders should also be the product name field, but only the other fields are rerendering (description, and price fields). Can anyone tell me where I am coding this wrong???

 

debugging behind the scenes show taht tthe values are correct so the rerendering should be showing the correct values, so therefore I think the problem is in the actual rerendering of the field.

 

 

VF page:

 

 <apex:pageblock title="Sales Order Items"  tabStyle="SCRB_SalesOrder__c" id="SOIpgblk" >  
      <div style="text-align: center;"> <apex:messages style="font-weight: bold; color:red;" /></div>
    <apex:pageBlockButtons location="top" >
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl"  disabled="{!NOT(SOsaved)}" id="btnAddSOI" />
    </apex:pageBlockButtons>  
    <apex:actionRegion id="prodUpdate" renderRegionOnly="false">
    <apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel,tablePnl">
            <apex:param id="prodId" value="" name="prodId"/>     
    </apex:actionFunction>
    </apex:actionRegion>
        
    <apex:outputPanel id="tablePnl">  
        <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
            
            <apex:column headerValue="Line type" id="ltcol">
              <apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
                  <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType"  required="true" >
                      <apex:actionSupport event="onblur" reRender="detailPanel,currLineTypefld" action="{!loadSOIDs}" >
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                  </apex:inputField>                     
              </apex:actionRegion>
            </apex:column>
            
            <apex:column headerValue="Product" id="prodCol">         
               <apex:actionRegion id="prodRgn">
                    <apex:inputText value="{!SOI.ProductId__r.name}" id="fProd" onFocus="this.blur()" />
                   <apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd">
                        <apex:image value="{!$Resource.lookupIcon}"/>
                        <apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
                    </apex:commandLink>  
               </apex:actionRegion>
            </apex:column>  
            <apex:column headerValue="Description">
                <apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
                <apex:inputField value="{!SOI.Description__c}" id="fDescr" >
                        <apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                   </apex:inputField>
                     </apex:actionRegion>
            </apex:column>               

 

        REMOVED SOME COLUMNS TO SAVE SPACE


            <apex:column headerValue="Profit" >
                <apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>    
            </apex:column>
            <apex:column headerValue="Total Price">
                <apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
            </apex:column>
            <apex:column headerValue="Line Status" >
                <apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus"  />
            </apex:column>          
        </apex:pageBlockTable>
    </apex:outputPanel>
   

Hello I am trying to pass two parameters into a javascript function from a table row but I am not getting the values , see below:

 

The VF page markup calling the function:

 

<apex:inputHidden id="fprodId" value="{!prod.Id}" rendered="true"/>
     <apex:column headerValue="Name">
<apex:outputLink id="fprodName" onclick="closeWin('{!$Component.fprodId}', '{!$Component.fprodName}');" >
{!prod.Name}
        </apex:outputLink>
     </apex:column>

 

 

The javascript function called:

<script>
function closeWin(prodId,prodName) {

alert('ProdID: ' + prodId + ' ProdName: ' + prodName);

// var winMain=window.opener;
// if (winMain ==null){winMain=window.parent.opener;}
// winMain.closeLookupPopup(prodId, prodName);
}
</script>

 

RESULTS:

 

when I click the link I see the following: 


ProdId:

j_id0:theMainBlocktheForm:theBlock:prodList:fprodId

ProdName: 

j_id0:theMainBlocktheForm:theBlock:prodList:0:fprodName

 

I need to get the actual values from those two fields, I have tried to use all types of combinations of .value .text .innerHTML but with no luck. Any ideas as to what may be the issue??

Hello,

 

I have a pageblocktable that for one of the fields I have a lookup that I am trying to override with my own custom lookup. Basically I have an input text and a link with an image to resemble the SF lookup. I havea onclick event on the command link and I am calling a JS function in a script tag but for some reason it is not working. If I comment out the line where I assign the elementById then the popo page is opened, but when I uncomment the var assignment lines then nothing happens as if there was an error. below is the relevant pieces of the code and I have commented out some lines since it is not working. I dont know if the issue is because of the table where the function does not know which value from which row to assign but I am very incompetent when it comes to JS..

 

<script>
function prodLookup()
{
  // var txtId = document.getElementById($Component.thePage.theForm.SOIpgblk.tablePnl.SOIList.prodCol.prodRgn.fProd).value; //this doesnt work
  / /var txtId = document.getElementById("fProd").value;    //this doesnt work
  // var x= document.getElementById("fLineType").selectedIndex;
  // var y= document.getElementById("fLineType").options;
   //var lineType = document.getelementById(y[x].text); //uncommented this doesnt work either.
 

// alert('To select a Product, first select the Line Type: ' + y);
         
    alert('didnt work!' );
    
    baseURL = "/apex/customProdSearchPopup?"; // how do I assign the variables above to this url????
    
    var pop = window.open(baseURL, "lookup", 350, 480, "width=350,height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true);
  //  doUpdateProdData();
}
</script>

 

 

 

the call from the visualforce field I think is OK because if I comment out everything the alert(didnt work!) pop up is shown, so means the method gets called. see below

 

 <apex:column headerValue="Line type" id="ltcol">
              <apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
                  <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType"  required="true" >
                      <apex:actionSupport event="onblur" reRender="detailPanel" action="{!loadSOIDs}" >
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                  </apex:inputField>                     
              </apex:actionRegion>
            </apex:column>

 <apex:column headerValue="Product" id="prodCol">
               <apex:actionRegion id="prodRgn">
                <apex:inputText value="{!SOIProdTxt}" id="fProd" />
                   <apex:commandLink onclick="prodLookup()" reRender="detailPanel,tablePnl,fDiscAmt,fTotalPrice,fProfit,colProfit">
                       <apex:image value="{!$Resource.lookupIcon}"/>
                   </apex:commandLink>
               </apex:actionRegion>

 

 


Hello,

 

I have a picklist that should load some records and do some stuff to a page section futher below then rerender it. I have added a rendered tag to the page section so that only when a specific value is selected it should be visible, but with the rendered tag it is not working at all. Basically nothing happens, the page section never renders into view. If I take out the rendered tag then the page is updated and records loaded correctly. The currLineType is updated correctly and therefore the rendered expression should be true and the page section refreshed.  So something going on with the render tag, please assist!

 

VF code:

 

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

             
              
 <!--This is the part that should be rendered into view when Course is selected in the picklist above-->               
    <apex:outputPanel id="detailPanel" >
          <apex:outputPanel rendered="{!currSOI.Line_Type__c == 'Course'}">
               <apex:pageBlocksection title="Sales Order Item Details"   >

                       ......some VF inputfields.....

               </apex:pageBlocksection>
          </apex:outputPanel>
    </apex:outputPanel>

Hello,

 

I have come across an issue I am struggling to solve but not sure how to approach a solution. The issue is as follows:

 

I have a Vf page that mimics the Multi Product page (the one that is used to add products to an Opp). The main difference is that I also give users the option to enter Discount AMount then recalculate the discount percent so when saving to the database SF will calculate the total price. BUT I have come across an issue when entering a discount amount that translates to a discount percent with more than 2 digits of scale (for example: 365-235 will yield 39,16666666666664%, but SF rounds up to 39,17). This causes an issue because when I save the record to the database the auto calculated total price is 364,98 and not 365. This is because when SF rounds up to 39,17 it translates to 235,02 as the amount discounted.

 

Does anyone know how to  work around this issue?

Hello,

 

Looking for help solving a simple issue that will most likely be a quick fix but yet I've spent too much time trying to crack it. The issue is that I have a pageblocktable with OpportunityLineItems, these can have their fields updated such as Qty and Discount. on the Qty and Discount field's onblur event  I perform an upsert of the OppLine so that the server can calculate the TotalPrice and other relevant fields. Once the save is done, I requery for the record to show the latest updated values from the server, BUT even though in the debug log I see that the record got updated, when I rerender the field (even tried rerendering the entire table) the value simply disappears as if by "magic". 

 

How can I get the row rerendered with the new values in the record??? Please assist! Below is code for controller and VF page where the issue seems to be happening:

 

VF page table: (NOTE: some fields that are static and do not get updated have been removed to downsize post length)

 <apex:outputPanel id="tablePnl">  
        <apex:pageblockTable value="{!OLIs}" var="OLI" id="OLIList" >
            <apex:column id="DelCol"> 
                {!OLI.Id}  -- {!OLI.TotalPrice}                   
                <apex:commandButton value="Delete" action="{!del}" rerender="tablePnl,detailPanel">
                    <apex:param name="delname" value="{!OLI.id}" assignTo="{!currOLIid}"/> 
                </apex:commandButton>          
            </apex:column>                    
            <apex:column headerValue="Quantity"> 
                <apex:inputField value="{!OLI.Quantity}"  id="fQTY" required="{!OLI.PriceBookEntry.Product2.Name != null}"  >
                    <apex:actionSupport event="onblur" rerender="tablePnl,fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!saveOLI}" disabled="{!(OLI.Quantity == null || OLI.Quantity <= 0) || (OLI.UnitPrice == null || OLI.UnitPrice <= 0)}"  >
                        <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
                    </apex:actionSupport>
                </apex:inputField>
            </apex:column>             
            <apex:column headerValue="Unit Cost" >
                <apex:inputField value="{!OLI.Unit_Cost__c}" id="fUnitCost"/>       
            </apex:column>
            <apex:column headerValue="Sales Price ex VAT"">
                <apex:inputField value="{!OLI.UnitPrice}"/>
            </apex:column>
            <apex:column headerValue="Line Disc Pct.">
                <apex:inputField value="{!OLI.Discount}" id="fDiscPct">
                <apex:actionSupport event="onblur" rerender="fUnitCost,fProfit,fTotalPrice,fDiscPct,fDiscAmt" action="{!saveOLI}" disabled="{!(OLI.Quantity == null || OLI.Quantity <= 0) || (OLI.UnitPrice == null || OLI.UnitPrice <= 0)}"  >
                        <apex:param name="currOLIQty" value="{!OLI.Id}" assignTo="{!currOLIid}"/>
                    </apex:actionSupport>
                </apex:inputField>
            </apex:column>
            <apex:column headerValue="Total Price">
                    <apex:outputField value="{!OLI.TotalPrice}" id="fTotalPrice"  />
            </apex:column>         
        </apex:pageBlockTable>
    </apex:outputPanel>

 And this is the code in the controller that performs the saveOLI action (saving the record):

    public PageReference saveOLI() {
        system.debug('###currOLI: ' + currOLI);
        currOLI.TotalPrice = null;
        try{
        upsert currOLI;
        currOLI = loadOLI(currOLI);
        for(OpportunityLineItem o: OLIs) {
            if(o.id == currOLI.id) {
                o = currOLI;
                system.debug('###After saveOLI OLIs(o) from currOLI: ' + o);
            }
        }
        }catch(Exception e) {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error saving Opportunity Product: ' + e.getMessage());
            ApexPages.addMessage(myMsg);
        }
        return null;
    }

 

Hello,

 

I have a button I am trying to use to callout to an external web service but it is giving me a 'No operation available for request' error.  basically I have a custom button with an Execute Javascript behavior. The button code is here:

 

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
sforce.debug.trace=true;

var result = sforce.apex.execute("NAV_Webservice_Functions_MR","sendSO2NAV_buildStream", {pSOId:"{!SCRB_SalesOrder__c.Id}"});

 

The class code is as follows: (i've removed alot of the element additions to the xml stream writer to save space)

 

global class NAV_Webservice_Functions_MR {
    private static SCRB_SalesOrder__c mSO;
    private static List<SCRB_SalesOrderLineItem__c> mSOIs; 

    
// Local method to build Create SO request.
public static void sendSO2NAV_buildStream (String pSOid) {
    string ErrStr;
    string XMLIn;         
    XmlStreamWriter w = new XmlStreamWriter();
    mSO = getSO(pSOid);
    mSOIs = getSOIs(pSOid); 
        w.writeStartDocument(null, '1.0');
        w.writeStartElement(null, 'SendSalesDocumentRequest', null);
        w.writeStartElement(null, 'action', null); 
    //Open main element (Sales Document Info)
    system.debug('### mSO ' + mSO);
        w.writeStartElement(null, 'SalesHeader', null);                      
            AddElementToXMLStream(w,null,'AccountId__c',mSO.AccountId__c,null);                           
            AddElementToXMLStream(w,null,'Currency_Code__c',mSO.Currency_Code__c,null);
            AddElementToXMLStream(w,null,'ShippingStreet__c',mSO.ShippingStreet__c,null);                               
        w.writeEndElement(); //end salesheader
        
    //Open SOIs element holder (inside all SOIs for SO)   
        w.writeStartElement(null, 'SalesLines', null); 
            for(SCRB_SalesOrderLineItem__c soi: mSOIs){
            w.writeStartElement(null, 'SalesLine', null);
            AddElementToXMLStream(w,null,'ProductId__c',soi.ProductId__c,null);
        AddElementToXMLStream(w,null,'Contract_Payment_Start_Date__c',String.valueOf(soi.Contract_Payment_Start_Date__c),null);
            AddElementToXMLStream(w,null,'VAT_Prod_Posting_Group__c',soi.VAT_Prod_Posting_Group__c,null);                                                                                                                                                                                                                                                                          
            //Open SOID elements holder (contacts for SOIs)
            w.writeStartElement(null, 'SalesLineDetails', null);
                for(Sales_Order_Item_Detail__c  soid : [SELECT Id, Name, Sales_Order_Item__c, Contact__c, Contact__r.NAV_Contact_No__c FROM Sales_Order_Item_Detail__c WHERE  Sales_Order_Item__c = : soi.id]) {  
                  w.writeStartElement(null, 'SalesLineDetail', null);
                  AddElementToXMLStream(w,null,'NAV_Contact_No__c',soid.Contact__r.NAV_Contact_No__c,null);
                  w.writeEndElement(); //end saleslinedetail
                }
            w.writeEndElement(); //end saleslinedetails
        w.writeEndElement(); //end salesline   
        }
            w.writeEndElement(); //end saleslines      
        w.writeEndDocument();
        XMLIn = w.getXmlString();
        w.close();  
    //THE ACTUAL METHOD THAT CALLS THE WEB SERVICE IS COMMENTED OUT BUT THE ERROR STILL APPEARS!!!!
    //sendSO2NAV_sendRequest(mSO, XMLIn);   
}


// Web service callout  to send the request. Callback to local methodto process results
 WebService Static void sendSO2NAV_sendRequest(SCRB_SalesOrder__c pSO, String strXML) {
    String xmlresponse = SendNAVSoapDoc(pSO.ERP_Company_Id__c,'wssalesmethods','UpsertSalesDocFromXML_TEST',strXML);         
    //process response from Callout. COMENTED OUT AND REMOVED FROM CLASS TO SAVE SPACE
    //sendSO2NAV_processResponse(xmlresponse);
} 


//////////////////////////////////////////////////////////////////////
    
        public static string SendNAVSoapDoc(string NAVCompanyName, string CUName,string CUFunction,string XMLIn) {
        

        CP_NAVWebservice__c CPSetup = CP_NAVWebservice__c.getInstance('CPSetup');        
        if (NAVCompanyName=='' || NAVCompanyName==null) {NAVCompanyName = CPSetup.NAVWS_Company_Name__c;}
             
        Http http = new Http();
     
        HttpRequest req = new HttpRequest();
     
        req.setMethod('POST');
        req.setEndpoint(CPSetup.Proxy_Base_URL__c + ':' + String.valueOf(Integer.valueOf(CPSetup.Proxy_Port__c)) + '/service');  
        req.setTimeout(Integer.valueOf(CPSetup.Proxy_Timeout_ms__c));  
        Blob headerValue = Blob.valueOf(CPSetup.Proxy_Username__c + ':' + CPSetup.Proxy_Password__c);
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        req.setHeader('Content-type', 'text/xml; charset="utf-8"');
        req.setHeader('SOAPAction', '"urn:INavWinService/RunNAVCodeunit"');
    
        string SoapDoc = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/>'+
                  '<soapenv:Body><RunNAVCodeunit><NAVWSEndpoint>'+
                  CPSetup.NAVWS_Endpoint__c + NAVCompanyName +'/Codeunit/'+CUName+
                  '</NAVWSEndpoint><CodeunitName>'+CUName+'</CodeunitName>'+
                  '<CodeunitFunction>'+CUFunction+'</CodeunitFunction><XMLIn><![CDATA['+XMLIn+']]></XMLIn>'+
                  '</RunNAVCodeunit></soapenv:Body></soapenv:Envelope>'; 
                  
        req.setbody(SoapDoc);
        System.debug('Trying ' + req.getEndpoint());
        System.debug('Auth Header: ' + req.getHeader('Authorization'));
        System.debug('SOAP Boudy: '+SoapDoc);
        HttpResponse resp = http.send(req);
        System.debug('XML RESPONSE: \n\n' + resp.getBody());           
                  
        return resp.getBody();
    }
     
    
    
    //utility method to add an element to a streamwriter
    public static void AddElementToXMLStream(XmlStreamWriter w, string prefix, string name, string value, string namespaceURI){
        w.writeStartElement(prefix, name, namespaceURI);
        if (value==Null) { value =''; } 
        w.writeCharacters(value);
        w.writeEndElement(); 
    } 

    //Utility methods to get object data from SF. REMOVED MANY FIELDS FROM SOQL FOR SPACE SAVING REASONS IN POST
    public  static List<SCRB_SalesOrderLineItem__c> getSOIs (id pSOId) {
        List<SCRB_SalesOrderLineItem__c> SOItems = new List<SCRB_SalesOrderLineItem__c>();
        SOItems = [SELECT Contract_Manager__c,Contract_Payment_Start_Date__c,Contract_Start_Date__c,Contract_Template__c,
                Contract__Id, Name, Quantity__c  FROM SCRB_SalesOrderLineItem__c WHERE SalesOrderId__c = :pSOId];
        return SOItems; 
    }    
    public static SCRB_SalesOrder__c getSO(id pSOid){
           if(pSOid == null) {
                    mSO = new SCRB_SalesOrder__c() ;                    
           }else{  
                 mSO = [SELECT   Account_PriceBookId__c, AccountId__c, BillingCity__c,BillingCountry__c, BillingFax__c, BillingPhone__c, BillingPostalCode__c, BillingStreet__c, Billing_Account__c, Billing_Contact__c, CreatedById, CreatedDate, CurrencyIsoCode FROM SCRB_SalesOrder__c WHERE id = :pSOid]; 
            }     
            return mSO;
   }
   
   
}

 

This is the trace response I get from the button:

 


<textarea cols=80 rows=5 wrap=hard>
?xml version="1.0" encoding="UTF-8"?

soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
soapenv:Body
soapenv:Fault
faultcode
soapenv:Client
/faultcode

faultstring
No operation available for request {http://soap.sforce.com/schemas/package/NAV_Webservice_Functions_MR}sendSO2NAV_buildStream, please check the WSDL for the service.
/faultstring

/soapenv:Fault
/soapenv:Body
/soapenv:Envelope
</textarea>

 

 

 The callout is broken up in three methods, one to build the request, another to execute it and another to process and parse the results. I've removed some of the processing logic since it is irrelevant at this point (web service is not even being called). I also commented out the actual call to the web service method so the issue is with the button or the method that builds the XML stream. Could the issue be in the URL? Shouldn't it be pointing to the http://soap.sforce.com/schemas/class/NAV_Webservice.....

 

Please assist!!!!! It is urgent!!!!!

Hi guys.

 

Need a bit help from you people.

i want a pop up window show up when i click a radio button. when that pop up is shown no other button can be clicked in the page . The requirement is i have several radio button and input field in a page . when i click a radio button the background process is running , within that time i have to show the pop up window. For this i am using action status, action function . i am partially successful in this but the problem is while the pop up window shows on the screen i can click other button.

 

 

Please give me answers its very urgent requirement...

 

 

thanks for youe help

 

 

HEllo,

 

I havea visualforce page that I am trying to create a bar chart. I am using js remoting to call a method in the controller to get the result data BUT it is giving me a Null reference error when trying to access the account variable in the controller to use as a query parameter in the @RemoteACtion method.

 

 

CVF page:

<apex:page extensions="GoogleChartsController" sidebar="false" standardController="Account" showHeader="false" pageStyle="Account"  > 
    <apex:includeScript id="a" value="https://www.google.com/jsapi" />     
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(initCharts);
        //load all the charts..
        function initCharts() { 
              GoogleChartsController.loadChildCases(function(resultCase, event){  
                  var visualization = new google.visualization.ColumnChart(document.getElementById('caseChart'));
                  var data1 = new google.visualization.DataTable();  
                  data1.addColumn('string', 'Cases');
                  data1.addColumn('number', 'Cases');       
                  //add rows from the remoting results
                  for(var i =0; i < resultCase.length; i++){
                      var r = resultCase[i];
                      data1.addRow([r.Id, r.expr0]); 
                   }
                    // all done, lets draw the chart with some options to make it look nice.
                    visualization.draw(data1, {legend : {position: 'top', textStyle: {color: 'blue', fontSize: 10}}, width:150,vAxis:{textStyle:{fontSize: 10}},hAxis:{textStyle:{fontSize: 10},showTextEvery:1,slantedText:false}});
              }, {escape:true});
              
          } 
    </script>
     <div id="caseChart" />
</apex:page>

 And this is the controller:

global class GoogleChartsController {
 global static Account acc; 
 
    public GoogleChartsController(ApexPages.StandardController controller) {
        acc = (Account)controller.getRecord();
    }

    @RemoteAction   
    global static AggregateResult[] loadChildCases() {
        AggregateResult[] caseLst = [Select ParentId, count(Id) FROM Case  WHERE AccountId = :acc.id Group By ParentId ];
        return caseLst;
    }
}

 

Please let me know where I am making an error in this.

 

 

 

I have a custom button on a custom object that executes some javascript which calls a web service method and populates parameters to call the EmailAuthor link in SF. In sandbox it is working just fine and the code I cannot see any difference. The problem is when I click the button in production I get the following message:

 

The value of the "p3_lkid" parameter contains a character that is not allowed or the value exceeds the maximum allowed length

 

This is the code of the button:

 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var docId = sforce.apex.execute("SalesDoc_PDFAttachment","getSalesDoc_PDFDocument", {salesDoc_ID:"{!SCRB_SalesOrder__c.Id}",pAttID:"{!SCRB_SalesOrder__c.Active_PDF_Attachment_ID__c}" });

 

location.replace('/_ui/core/email/author/EmailAuthor?retURL=/{!SCRB_SalesOrder__c.Id}&p2_lkid={!SCRB_SalesOrder__c.Selling_ContactId__c}&rtype=003&p3_lkid={!SCRB_SalesOrder__c.Id}&doc_id='+docId);

 

I cannot see any errors and when the link is executed the values populated into the url are:

 

 

retURL= the id of the custom record

p2_lkid= the contact to send the email to

p3_lkid= the id of the custom record

doc_id= the ID value of the SF document returned by the web service method.

 

Can anyone spot where this is failing?

Hi,

 

I having a class where i am calling another method in that class. for some reason i am getting this error

Method does not exist or incorrect signature: createCGM(SET<String>, LIST<User>)

 I am sure i am missing something very silly.

Here is how the class is defined

 

public class helper_User 
{
   public static List<User> syncUsingEmail()
   {
Set<String>    setDivision = new Set<String>();
        List<user>    u = new List<user>();
 // do something

 createCGM(setDep, u); // Errors out here } public void createCGM(Set<String> setDep, List<User> u) { // do something } }

 

Hi,

 

Requirement I got is like there will be a mass delete on an object based on a condition and I have to export all the values to be deleted in an excel and have to sent it in a mail to an user

 

 

can this be implemented, if so plz help me...

 

Thanks in advance

Shank_dhel

Hello,

 

I have tried everything I can think of and I cannot get a pageblocktable to modify the column width to custom sizes and this is having a negative impact on the usability of the page. I have tried adding the width tag to the columns, I also tried using a style tag with a width parameter. I also tried defining the columns width in the pageblocktable definition but NO LUCK.  I am not sure what is causing the columns not to change their sizes, although I have a feeling that some of the inner tags in the columns may have something to do with it. I say this because I also tried changing their width without any tag other than the label and the column tag and it works. Please see code below, the first is the working example i have tried where columns do expand/contract to the respective width. The second example is the one I need to use in my VF page and the one that does not want to cooperate and change column widths. Please assist!

 

the table in blue is the example table adn the red one is the one I need for it to expand contract, right now it is trying to set widths using a style tag, but as I mentioned already, other methods are not working either.

 

 

<apex:page controller="SalesDocumentManager_Controller" tabStyle="SCRB_SalesOrder__c" id="thePage" >
<apex:sectionHeader title="Create Sales Document" subtitle="{!mAccount.Name}"/>
<apex:form id="theForm">
<apex:outputPanel id="msgs" >
<apex:messages style="font-weight:bold; color:red; font-size:medium; text-align:center; " />
<apex:actionStatus startText="Saving changes......" id="saveStatus" startstyle="font-weight:bold; color:green; font-size:medium; text-align:center; " layout="block" />
</apex:outputPanel>

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

<!----------------------------->
<!--SALES ORDER ITEMS SECTION-->
<!----------------------------->

<apex:pageblock title="TEST table">
<apex:pageBlockTable style="width:100%" value="{!SOItems}" var="SOI" >
<apex:column headerValue="Action" style="width:150px">
<apex:commandLink value="Del" action="{!del}" rerender="tablePnl,detailPanel" style="font-weight:bold" >
<apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
&nbsp;|&nbsp;
<apex:commandLink value="Save" action="{!saveSOI}" rerender="tablePnl,detailPanel" style="font-weight:bold" status="saveSOIstatus" >
<apex:param name="savename" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:column>
<apex:column style="width:250px" value="{!SOI.Product_Name_Custom__c}"/>
<apex:column style="width:250px" value="{!SOI.Line_Type__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>

<apex:pageblock title="Sales Order Items" tabStyle="SCRB_SalesOrder__c" id="SOIpgblk" >

<apex:messages style="font-weight:bold; color:red; font-size:medium; text-align:center; " />
<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl" disabled="{!NOT(SOsaved)}" id="btnAddSOI" />

</apex:pageBlockButtons>
<apex:actionStatus startText="Saving record......" id="saveSOIstatus" startstyle="font-weight:bold; color:green; font-size:small; text-align:center; " layout="block" />
<apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel, tablePnl" immediate="true">
<apex:param id="prodId" value="" name="prodId"/>
</apex:actionFunction>

<apex:actionRegion id="prodUpdate" renderRegionOnly="false">
<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" style="width:100%">
<apex:column headerValue="Action" >
<apex:commandLink value="Del" action="{!del}" rerender="tablePnl,detailPanel" style="width:150px" >
<apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
&nbsp;|&nbsp;
<apex:commandLink value="Save" action="{!saveSOI}" rerender="tablePnl,detailPanel" style="font-weight:bold" status="saveSOIstatus" >
<apex:param name="savename" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Line type" id="ltcol" style="width:50px">
<apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
<apex:inputField value="{!SOI.Line_Type__c}" id="fLineType" required="true" >
<apex:actionSupport event="onchange" rerender="tablePnl" action="{!resetRowData}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>

</apex:inputField>
</apex:actionRegion>
</apex:column>

<apex:column headerValue="Product" id="prodCol" style="width:50px">
<apex:actionRegion id="prodRgn">
<apex:inputField value="{!SOI.Product_Name_Custom__c}" id="fProd" onFocus="this.blur()" >
<apex:actionSupport event="onchange" reRender="detailPanel" action="{!loadSOIDs}" >
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
</apex:inputField>


<apex:commandLink onclick="prodLookup(this.parentNode.parentNode)" reRender="fProd">
<apex:image value="{!$Resource.lookupIcon}"/>
<apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Description" style="width:50px">
<apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
<apex:inputField value="{!SOI.Description__c}" id="fDescr" >
<apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Quantity" style="width:50px">
<apex:actionRegion >
<apex:inputField value="{!SOI.Quantity__c}" id="fQTY" required="{!SOI.Product_Name_Custom__c <> null}" >
<apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
<apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
<apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
</apex:actionSupport>
<apex:actionSupport event="onchange" rerender="fDiscAmt,colTest,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIQty" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:actionRegion>
</apex:column>
<apex:column headerValue="Unit Cost" style="width:50px" >
<apex:inputField value="{!SOI.Unit_Cost__c}" id="fUnitCost">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIUC" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Sales Price ex VAT" style="width:50px">
<apex:inputField value="{!SOI.SalesPrice__c}" id="fSalesPrice" >
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOISP" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Pct." style="width:50px">
<apex:inputField value="{!SOI.Line_Discount_Pct__c}" id="fDiscPct">
<apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
<apex:param name="currSOIDP" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Line Disc Amt." style="width:50px">
<apex:inputField value="{!SOI.Line_Discount_Amount__c}" id="fDiscAmt">
<apex:actionSupport event="onchange" rerender="fDiscPct,fTotalPrice,fProfit" action="{!calculateDiscPct}">
<apex:param name="currSOIDA" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Profit" style="width:50px">
<apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>
</apex:column>
<apex:column headerValue="Total Price" style="width:50px">
<apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
</apex:column>
<apex:column headerValue="Line Status" style="width:50px">
<apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus" />
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:actionRegion>


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

Hello,

 

I havea pageblocktable updated from the controller where I list order items. One of the fields is the product lookup (custom made, not the standarad one from SF). I point the inputText of the lookup to a productID__r.Name field of the product and also update some other fields in teh table when teh user changes the product reference. Alont htese rerenders should also be the product name field, but only the other fields are rerendering (description, and price fields). Can anyone tell me where I am coding this wrong???

 

debugging behind the scenes show taht tthe values are correct so the rerendering should be showing the correct values, so therefore I think the problem is in the actual rerendering of the field.

 

 

VF page:

 

 <apex:pageblock title="Sales Order Items"  tabStyle="SCRB_SalesOrder__c" id="SOIpgblk" >  
      <div style="text-align: center;"> <apex:messages style="font-weight: bold; color:red;" /></div>
    <apex:pageBlockButtons location="top" >
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl"  disabled="{!NOT(SOsaved)}" id="btnAddSOI" />
    </apex:pageBlockButtons>  
    <apex:actionRegion id="prodUpdate" renderRegionOnly="false">
    <apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel,tablePnl">
            <apex:param id="prodId" value="" name="prodId"/>     
    </apex:actionFunction>
    </apex:actionRegion>
        
    <apex:outputPanel id="tablePnl">  
        <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
            
            <apex:column headerValue="Line type" id="ltcol">
              <apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
                  <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType"  required="true" >
                      <apex:actionSupport event="onblur" reRender="detailPanel,currLineTypefld" action="{!loadSOIDs}" >
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                  </apex:inputField>                     
              </apex:actionRegion>
            </apex:column>
            
            <apex:column headerValue="Product" id="prodCol">         
               <apex:actionRegion id="prodRgn">
                    <apex:inputText value="{!SOI.ProductId__r.name}" id="fProd" onFocus="this.blur()" />
                   <apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd">
                        <apex:image value="{!$Resource.lookupIcon}"/>
                        <apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
                    </apex:commandLink>  
               </apex:actionRegion>
            </apex:column>  
            <apex:column headerValue="Description">
                <apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
                <apex:inputField value="{!SOI.Description__c}" id="fDescr" >
                        <apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                   </apex:inputField>
                     </apex:actionRegion>
            </apex:column>               

 

        REMOVED SOME COLUMNS TO SAVE SPACE


            <apex:column headerValue="Profit" >
                <apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>    
            </apex:column>
            <apex:column headerValue="Total Price">
                <apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
            </apex:column>
            <apex:column headerValue="Line Status" >
                <apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus"  />
            </apex:column>          
        </apex:pageBlockTable>
    </apex:outputPanel>
   

Hello,

 

I have a pageblocktable that for one of the fields I have a lookup that I am trying to override with my own custom lookup. Basically I have an input text and a link with an image to resemble the SF lookup. I havea onclick event on the command link and I am calling a JS function in a script tag but for some reason it is not working. If I comment out the line where I assign the elementById then the popo page is opened, but when I uncomment the var assignment lines then nothing happens as if there was an error. below is the relevant pieces of the code and I have commented out some lines since it is not working. I dont know if the issue is because of the table where the function does not know which value from which row to assign but I am very incompetent when it comes to JS..

 

<script>
function prodLookup()
{
  // var txtId = document.getElementById($Component.thePage.theForm.SOIpgblk.tablePnl.SOIList.prodCol.prodRgn.fProd).value; //this doesnt work
  / /var txtId = document.getElementById("fProd").value;    //this doesnt work
  // var x= document.getElementById("fLineType").selectedIndex;
  // var y= document.getElementById("fLineType").options;
   //var lineType = document.getelementById(y[x].text); //uncommented this doesnt work either.
 

// alert('To select a Product, first select the Line Type: ' + y);
         
    alert('didnt work!' );
    
    baseURL = "/apex/customProdSearchPopup?"; // how do I assign the variables above to this url????
    
    var pop = window.open(baseURL, "lookup", 350, 480, "width=350,height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true);
  //  doUpdateProdData();
}
</script>

 

 

 

the call from the visualforce field I think is OK because if I comment out everything the alert(didnt work!) pop up is shown, so means the method gets called. see below

 

 <apex:column headerValue="Line type" id="ltcol">
              <apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
                  <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType"  required="true" >
                      <apex:actionSupport event="onblur" reRender="detailPanel" action="{!loadSOIDs}" >
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                  </apex:inputField>                     
              </apex:actionRegion>
            </apex:column>

 <apex:column headerValue="Product" id="prodCol">
               <apex:actionRegion id="prodRgn">
                <apex:inputText value="{!SOIProdTxt}" id="fProd" />
                   <apex:commandLink onclick="prodLookup()" reRender="detailPanel,tablePnl,fDiscAmt,fTotalPrice,fProfit,colProfit">
                       <apex:image value="{!$Resource.lookupIcon}"/>
                   </apex:commandLink>
               </apex:actionRegion>

 

 


Hi All,

 

can any one please tell me how to write test code for java script remoting method in Apex class.And I am passing argument from page.

 

sample codes are appriciated.

Ok,

Looking for some shorthand on setting a value to zero if null in an assignment statement....

I have this :

    for(Account A: Accts) {
        MyObject__c MO = new MyObject__c(
           ...,
           MO.MyField__c = A.FieldA__c + A.FieldB__c //Errors when either FieldA or B is Null
        );
        MOsToInsert.add(MO);
    }

MyField, and Account fields FieldA and FieldB are all integers.  The above, of course, fails if either FieldA or FieldB is Null.  My sloppy work-around is to define variables for FieldA and FieldB, swapping in a zero if either is null, (requires about 10 additional lines of code).  I know there must be an easier way - perhaps an inline edit to this line to handle the null condition?  ::

(I thought this would work, but this fails too... perhaps my syntax is off?)

           MO.MyField__c = A.FieldA__c == null?0:A.FieldA__c + A.FieldB__c == null? 0:A.FieldB__c

Thanks for any assistance!

Pete

I have created a Visualforce email template that automatically attaches a PDF rendering of a quote from the opportunity object. It works fine when manually selecting the template from the email author page.

However, if I create a custom button on the opportunity page to take me to the email author page with the whoid, whatid, and template id defined in the URL, the email subject and body show up just fine but there is no attachment. Anyone else run into this? Any ideas on a fix?

Message Edited by trsmith on 11-17-2008 01:08 PM

Message Edited by trsmith on 11-17-2008 01:10 PM