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

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

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