• Harini
  • NEWBIE
  • 40 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 17
    Replies

I have written the below for a trigger that I'm working on and both seem to produce the desired result.  Based on what I've learned they are two best pracitce ways to use SOQL queries.  But can someone please help me understand why I wouldn't want to just use the version with the SOQL For Loop almost all the time? (since it can help can avoid governor limits)

 

Version 1: SOQL List

 

List<OpportunityLineItem> OppProducts = new List<OpportunityLineItem>([SELECT Id, OpportunityId, PricebookEntryId, Post_Sale_Project__c FROM OpportunityLineItem WHERE OpportunityId IN: OppIds]);
		system.debug('OppProducts list size : ' + String.valueof(OppProducts.size()));
		
		for(OpportunityLineItem oli: OppProducts){
			if(psp.Opportunity__c == oli.OpportunityId){
				ResetOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = null));
				UpdateOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = psp.Id));
				system.debug('Post Sale Project Opportunity__c : ' + psp.Opportunity__c);
				system.debug('OpportunityLineItem OpportunityId : ' + oli.OpportunityId);
				system.debug('OpportunityLineItem Id : ' + oli.Id);
				system.debug('OpportunityLineItem ProductId : ' + oli.PricebookEntryId);
				system.debug('OpportunityLineItem Post Sales Project : ' + oli.Post_Sale_Project__c);
			}
		}

 

Version 2: SOQL List in For Loop

 

for(List<OpportunityLineItem> OppProducts: [SELECT Id, OpportunityId, PricebookEntryId, Post_Sale_Project__c FROM OpportunityLineItem WHERE OpportunityId IN: OppIds]){
			for(OpportunityLineItem oli: OppProducts){
				if(psp.Opportunity__c == oli.OpportunityId){
					ResetOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = null));
					UpdateOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = psp.Id));
				}
			}
		}

 

Thanks in advance for your help!

 

Hi All,

 

I have developed a vf page in which once a user chooses a pricebook , he will be able to see the list of products tied to that pricebook in a pageblock table. In order to accomplish this I have used the wrapper class which has a checked field and some input field along with fields from PRoduct2 object.

 

I have two options to write a validation to check the quqntity is not 0 if the product checkbox is checked .

 

1) From javascript ---client side validation:

 

I want to write a validation in javascript , when the checkbox is checked i.e that product is selected, I need to validate the quantity column in th table and alert if the quantity is 0.

 

When I read the checkbox field from javascript though it is checked or unchecked I am getting  a value of null always :

 

alert(document.getElementById('{!$Component.theForm.ProductDetail.ProductDetails.table.selectLine1}'));----returns null
and  alert(document.getElementById('{!$Component.selectLine1}')); ------retruns null

 

 

2) From Apex controller ---server side validation

 

I ama ble to read the values from the apex class perfectly fine i.e, checked as false initially and once user selects the product it is true.

 

And if the product is checked and the quantity field is 0 I am displaying a error message like below:

 

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please Enter Quantity  for the Product Selected!!') );
                     return null; ---------> When I return this pagereference  all the information enters by the user disappears and the page is clear of all the user inputted data.

 

How can I retain the information entered by the user and display a validation message .

 

Any help on client side or server side validation is highly appreciated.

 

 

Thanks

 

 

  • April 30, 2013
  • Like
  • 0

Hi All,

 

I have developed a vf page in which once a user chooses a pricebook , he will be able to see the list of products tied to that pricebook in a pageblock table. In order to accomplish this I have used the wrapper class which has a checked field and some input field along with fields from PRoduct2 object.

 

I have two options to write a validation to check the quqntity is not 0 if the product checkbox is checked .

 

1) From javascript ---client side validation:

 

I want to write a validation in javascript , when the checkbox is checked i.e that product is selected, I need to validate the quantity column in th table and alert if the quantity is 0.

 

When I read the checkbox field from javascript though it is checked or unchecked I am getting  a value of null always :

 

alert(document.getElementById('{!$Component.theForm.ProductDetail.ProductDetails.table.selectLine1}'));---- null
and  alert(document.getElementById('{!$Component.selectLine1}')); ------null

 

 

2) From Apex controller ---server side validation

 

I ama ble to read the values from the apex class perfectly fine i.e, checked as false initially and once user selects the product it is true.

 

And if the product is checked and the quantity field is 0 I am displaying a error message like below:

 

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please Enter Quantity  for the Product Selected!!') );
                     return null; ---------> When I return this pagereference  all the information enters by the user disappears and the page is clear of all the user inputted data.

 

How can I retain the information entered by the user and display a validation message .

 

Any help on client side or server side validation is highly appreciated.

 

 

Thanks

 

 

 

 

  • April 29, 2013
  • Like
  • 0

Hi

 

I have a pageblock table which displays a list of product records. The list of products shows product name,family,description ,quantity,discount,standard price and salesprice.

 

When the user enters discount value in the input text onchange triggers a call to javascript where salesprice is calculated : standardprice- (standardprice*discount)/100;

 

Iam able to read the values in the javascript and calculate salesprice. I am unable to set the salesprice to the outputText column in the table .

 

Here is  my vf page  partial markup:

<apex:actionFunction name="salesPriceUpdate" 
                     action="{!fieldUpdate}" rerender="prodSalesPrice,prodSalesPriceCol" /> 

 

<apex:column headervalue="Discount %"  >
               <apex:inputtext value="{!products1.discount}" id="discPcrnt" onchange="CalculateSP('{!$Component.discPcrnt}','{!$Component.stdPrice}'),'{!$Component.prodSalesPrice}';" />
            </apex:column>
           
            <apex:column headervalue="Sales Price" id="prodSalesPriceCol" >
             <apex:outputtext  id="prodSalesPrice" value="{!salesPriceCalc}"/>
                       </apex:column>

 

Here is the javascript function:

 

<script language="javascript">
           function CalculateSP(disc,stndPrice,salesPrice){
              var discPcrnt=document.getElementById(disc).value;
       
               var stdPrice= document.getElementById(stndPrice).innerHTML;
               var discPrice= stdPrice*discPcrnt/100 ;
       var sellingPrice= stdPrice - discPrice ;
              document.getElementById(salesPrice).innerHTML = sellingPrice;
        document.getElementById(prodSalesPrice).innerHTML = sellingPrice;
        salesPriceUpdate(sellingPrice);
       }

 

Any help is greatly appreciated.

  • April 25, 2013
  • Like
  • 0

I  have a vf page that displays the list of products, When the user enters the discount in the input text the salesprice should be calculated and auto populated in the next column of the same row. I am calling a javascript function upon the event of onchange on discount field  to calculate salesprice but I am  not sure how to update the salesprice column on the  pageblock table.

 

Also I am not able to read the values of the discount entered : alert(document.getElementById(discPcrnt).value);  --->also does not give the value of the discount entered it says unavailable.
       

 

Below is the js:

 

function CalculateSP(discount,stdPrice,prodSalesPrice){
         alert("In Calculate Sp");
      
       var standardPrice= document.getElementById('stdPrice').value;
         alert("IN TEST");
        alert(document.getElementById(stdPrice).value);
       
       var  discount=document.getElementById(discPcrnt).value;
        var discPrice = stdPrice*discount/100 ;
       
        document.getElementById(prodSalesPrice).value=stdPrice - discPrice ;
       
              }

 

My VF Page partly:

 

<apex:column headervalue="Standard Price" id="stdPrice">
                <apex:outputtext value="{!products1.stdPrice}"/>
            </apex:column>  
           
         
                  <apex:column headervalue="quantity"  id="prodQuantity">
               <apex:inputtext value="{!products1.quantity}"/>
            </apex:column>
               
                 <apex:column headervalue="Discount %"  id="discPcrnt">
               <apex:inputtext value="{!products1.discount}" onchange="CalculateSP('{!$Component.discPcrnt}','{!$Component.stdPrice}'),'{!$Component.prodSalesPrice}';" />
            </apex:column>
           
            <apex:column headervalue="Sales Price" id="prodSalesPrice">
            <apex:outputtext value=??????>
            </apex:column>
           

 

Any help is greatly appreciated.

 

Thanks

  • April 24, 2013
  • Like
  • 0

Hi

I am trying to read the content of an attachment from an apex class. 

 Attachment att=   [Select Id,a.ParentId, a.Name,a.body,a.ContentType From Attachment a where ParentId=:contactId limit 1];
           System.debug('Attachment body : '+ att.body);
        System.debug('Attachment body : '+ att.ContentType);

 the attachment body  content is displayed as :Blob[176680].
the body of the attachment is base64. I want to see the content of the body in plain english .

Any help is appreciated.

Thanks

  • April 23, 2013
  • Like
  • 0

Hi

I am trying to read the content of an attachment from an apex class. 

 Attachment att=   [Select Id,a.ParentId, a.Name,a.body,a.ContentType From Attachment a where ParentId=:contactId limit 1];
           System.debug('Attachment body : '+ att.body);
        System.debug('Attachment body : '+ att.ContentType);

 the attachment body  content is displayed as :Blob[176680].
the body of the attachment is base64. I want to see the content of the body in plain english .

Any help is appreciated.

Thanks

  • April 23, 2013
  • Like
  • 0

Create a simple Visualforce page that when given a contact ID will display that contact, the account that it is associated to, as well as the billing address of account and other address of contact . Want to make this  Visualforce page accessible via a Web Tab.

 

How can I do this. Any help would be greatly appreciated
  • October 23, 2009
  • Like
  • 0
I read in some of the sfdc study guides with eamples to recruiting application,  if a position is closed the reviewer should not be able to add or delete a review and this could be done using roll up summary fields.Could anybody please explain how can that be accomplished.
 

In my case I want to restrict the user from adding or deleting the child records only when the master records status is closed. If the status of the master record is something else other than closed the user can add child records once the status changes he should be restricted.

 
  • October 15, 2009
  • Like
  • 0

I read in some of the sfdc study guides with eamples to recruiting application,  if a position is closed the reviewer should not be able to add or delete a review and this could be done using roll up summary fields.Could anybody please explain how can that be accomplished.

 

Thanks much.

  • October 15, 2009
  • Like
  • 0

how to  display the objects as pick list field,display the corresponding object fields as picklist field  in visualforce page

I have written the below for a trigger that I'm working on and both seem to produce the desired result.  Based on what I've learned they are two best pracitce ways to use SOQL queries.  But can someone please help me understand why I wouldn't want to just use the version with the SOQL For Loop almost all the time? (since it can help can avoid governor limits)

 

Version 1: SOQL List

 

List<OpportunityLineItem> OppProducts = new List<OpportunityLineItem>([SELECT Id, OpportunityId, PricebookEntryId, Post_Sale_Project__c FROM OpportunityLineItem WHERE OpportunityId IN: OppIds]);
		system.debug('OppProducts list size : ' + String.valueof(OppProducts.size()));
		
		for(OpportunityLineItem oli: OppProducts){
			if(psp.Opportunity__c == oli.OpportunityId){
				ResetOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = null));
				UpdateOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = psp.Id));
				system.debug('Post Sale Project Opportunity__c : ' + psp.Opportunity__c);
				system.debug('OpportunityLineItem OpportunityId : ' + oli.OpportunityId);
				system.debug('OpportunityLineItem Id : ' + oli.Id);
				system.debug('OpportunityLineItem ProductId : ' + oli.PricebookEntryId);
				system.debug('OpportunityLineItem Post Sales Project : ' + oli.Post_Sale_Project__c);
			}
		}

 

Version 2: SOQL List in For Loop

 

for(List<OpportunityLineItem> OppProducts: [SELECT Id, OpportunityId, PricebookEntryId, Post_Sale_Project__c FROM OpportunityLineItem WHERE OpportunityId IN: OppIds]){
			for(OpportunityLineItem oli: OppProducts){
				if(psp.Opportunity__c == oli.OpportunityId){
					ResetOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = null));
					UpdateOppProducts.put(oli.Id, new OpportunityLineItem(Id=oli.Id, OpportunityId = psp.Opportunity__c, Post_Sale_Project__c = psp.Id));
				}
			}
		}

 

Thanks in advance for your help!

 

I'm trying to display picklists on my custom VF page. These picklists, Prefix__c and Suffix__c are both custom fields in the Contact object. I am using the following code, but I keep getting the following error:

 

Method does not exist or incorrect signature: [String].getDescribe();

 


This example has been used by many people and they seem to get it working. I'm not sure what's happening here. Here's my code:

 

    public List<SelectOption> getCountries()
    {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult =
            Contact.Prefix__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }

 

Thanks,
Sanjeev

Hi Friends,

 

I have few picklist fields rendered from my object on to the visualforce page, when i view them on page, the static value on the picklist is seen as '--None--', which i want to change to '--Select--'.

 

I know this is possible if i am building a new custom ListofOptions field in visualforce but not sure for the standard/custom fields. Please let me know.

 

Thanks,

Maverick

Hi All,

    How to populate users based on their profile?

For e.g. I have taken lookup field which consist of all the profile.

Once a role is selected, a picklist should get populate with all the users under that category of profile.

Hi,

 

I need to create radio button  inside a data table for each row dynamically.  The list size determines number of radio buttons to be created dynamically. I am able to create radio buttons statically. But i want to create radio buttons as many as the size of the list. Can any one provide sample code.

 

Thanks.

 

 

Hi All,

 

I have developed a vf page in which once a user chooses a pricebook , he will be able to see the list of products tied to that pricebook in a pageblock table. In order to accomplish this I have used the wrapper class which has a checked field and some input field along with fields from PRoduct2 object.

 

I have two options to write a validation to check the quqntity is not 0 if the product checkbox is checked .

 

1) From javascript ---client side validation:

 

I want to write a validation in javascript , when the checkbox is checked i.e that product is selected, I need to validate the quantity column in th table and alert if the quantity is 0.

 

When I read the checkbox field from javascript though it is checked or unchecked I am getting  a value of null always :

 

alert(document.getElementById('{!$Component.theForm.ProductDetail.ProductDetails.table.selectLine1}'));----returns null
and  alert(document.getElementById('{!$Component.selectLine1}')); ------retruns null

 

 

2) From Apex controller ---server side validation

 

I ama ble to read the values from the apex class perfectly fine i.e, checked as false initially and once user selects the product it is true.

 

And if the product is checked and the quantity field is 0 I am displaying a error message like below:

 

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please Enter Quantity  for the Product Selected!!') );
                     return null; ---------> When I return this pagereference  all the information enters by the user disappears and the page is clear of all the user inputted data.

 

How can I retain the information entered by the user and display a validation message .

 

Any help on client side or server side validation is highly appreciated.

 

 

Thanks

 

 

  • April 30, 2013
  • Like
  • 0

Hi All,

 

I have developed a vf page in which once a user chooses a pricebook , he will be able to see the list of products tied to that pricebook in a pageblock table. In order to accomplish this I have used the wrapper class which has a checked field and some input field along with fields from PRoduct2 object.

 

I have two options to write a validation to check the quqntity is not 0 if the product checkbox is checked .

 

1) From javascript ---client side validation:

 

I want to write a validation in javascript , when the checkbox is checked i.e that product is selected, I need to validate the quantity column in th table and alert if the quantity is 0.

 

When I read the checkbox field from javascript though it is checked or unchecked I am getting  a value of null always :

 

alert(document.getElementById('{!$Component.theForm.ProductDetail.ProductDetails.table.selectLine1}'));---- null
and  alert(document.getElementById('{!$Component.selectLine1}')); ------null

 

 

2) From Apex controller ---server side validation

 

I ama ble to read the values from the apex class perfectly fine i.e, checked as false initially and once user selects the product it is true.

 

And if the product is checked and the quantity field is 0 I am displaying a error message like below:

 

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, 'Please Enter Quantity  for the Product Selected!!') );
                     return null; ---------> When I return this pagereference  all the information enters by the user disappears and the page is clear of all the user inputted data.

 

How can I retain the information entered by the user and display a validation message .

 

Any help on client side or server side validation is highly appreciated.

 

 

Thanks

 

 

 

 

  • April 29, 2013
  • Like
  • 0

Hi

 

I have a pageblock table which displays a list of product records. The list of products shows product name,family,description ,quantity,discount,standard price and salesprice.

 

When the user enters discount value in the input text onchange triggers a call to javascript where salesprice is calculated : standardprice- (standardprice*discount)/100;

 

Iam able to read the values in the javascript and calculate salesprice. I am unable to set the salesprice to the outputText column in the table .

 

Here is  my vf page  partial markup:

<apex:actionFunction name="salesPriceUpdate" 
                     action="{!fieldUpdate}" rerender="prodSalesPrice,prodSalesPriceCol" /> 

 

<apex:column headervalue="Discount %"  >
               <apex:inputtext value="{!products1.discount}" id="discPcrnt" onchange="CalculateSP('{!$Component.discPcrnt}','{!$Component.stdPrice}'),'{!$Component.prodSalesPrice}';" />
            </apex:column>
           
            <apex:column headervalue="Sales Price" id="prodSalesPriceCol" >
             <apex:outputtext  id="prodSalesPrice" value="{!salesPriceCalc}"/>
                       </apex:column>

 

Here is the javascript function:

 

<script language="javascript">
           function CalculateSP(disc,stndPrice,salesPrice){
              var discPcrnt=document.getElementById(disc).value;
       
               var stdPrice= document.getElementById(stndPrice).innerHTML;
               var discPrice= stdPrice*discPcrnt/100 ;
       var sellingPrice= stdPrice - discPrice ;
              document.getElementById(salesPrice).innerHTML = sellingPrice;
        document.getElementById(prodSalesPrice).innerHTML = sellingPrice;
        salesPriceUpdate(sellingPrice);
       }

 

Any help is greatly appreciated.

  • April 25, 2013
  • Like
  • 0

i have one application in that appliction i have emp's and projects objects are there single emp working on multiple projects,

under single  project working on multiple employes, how to take the model view  

 

 

 

 

 

Advanced thanks

venkat

Hi

I am trying to read the content of an attachment from an apex class. 

 Attachment att=   [Select Id,a.ParentId, a.Name,a.body,a.ContentType From Attachment a where ParentId=:contactId limit 1];
           System.debug('Attachment body : '+ att.body);
        System.debug('Attachment body : '+ att.ContentType);

 the attachment body  content is displayed as :Blob[176680].
the body of the attachment is base64. I want to see the content of the body in plain english .

Any help is appreciated.

Thanks

  • April 23, 2013
  • Like
  • 0

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;
    }

 

Create a simple Visualforce page that when given a contact ID will display that contact, the account that it is associated to, as well as the billing address of account and other address of contact . Want to make this  Visualforce page accessible via a Web Tab.

 

How can I do this. Any help would be greatly appreciated
  • October 23, 2009
  • Like
  • 0

I read in some of the sfdc study guides with eamples to recruiting application,  if a position is closed the reviewer should not be able to add or delete a review and this could be done using roll up summary fields.Could anybody please explain how can that be accomplished.

 

Thanks much.

  • October 15, 2009
  • Like
  • 0