• TomSnyder
  • NEWBIE
  • 224 Points
  • Member since 2007

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 81
    Replies
I'm creating a visualforce email template but I am having a hard time accessing fields from a parent object. Currently I have the visualforce template related to the Opportunity object. I would like to access the Account name on the opportunity. How would I do this? Any example?

How can i reach the last record in the for loop as following:

for (Timesheet__c timeSheet: [select Total_Hours__c, Hours__c from Timesheet__c])

I want to do some operation in the last timesheet. Thanks in advance for any help.

confused newbie here. I've read some previsous posts and I thought I had things right... apparently not.

I have tired  value="{!origZip}" and get save error -

ErrorError: Unknown property 'origZip' 

 

If I try value="{!rater.origZip}" and value="{!Rater__c.origZip}"/ I get

 

Error: Invalid field origZip for SObject Rater__c

 

 
Yes, I'm guessing at this point.

 

Any help would be greatly appreciated.

 

 

public class Rater{

    public String origZip {get; set;}   
    public String destZip {get; set;}
    public final Rater__c rater;

}

 

VFP

 

<apex:page StandardController="Rater__c">
    <apex:variable value="{!Rater__c}" var="rater" />
    <apex:pageBlock title="Spot Quote">
        <apex:pageblockSection>
            <apex:form>     
                <APEX:OUTPUTTEXT value="Orig Zip: "></APEX:OUTPUTTEXT>      
                <apex:inputText style="width: 50px" value="{!origZip}"/>
                <apex:outputText value="  "></apex:outputText>
                <APEX:OUTPUTTEXT value="Dest Zip: "></APEX:OUTPUTTEXT>      
                <apex:inputText style="width: 50px" />
                <apex:commandButton value="Rate"/>
            </apex:form>
        </apex:pageblockSection>
    </apex:pageBlock>
</apex:page>

  • March 04, 2010
  • Like
  • 0

Hi All,

 

I need to generate a PDF which dynamically includes long paragraphs of text (the longest contains 719 words).

I am new to SF and this is how I propose to do it - but I dont like it:

 

 

The paragraphs included in the PDF will be determined by the user filling out a form.

 

Once the user clicks "submit", the controller class determines which paragraphs to be included and populates a Map containing the paragraphs.

 

The Map is then used in a VisualForce page, within a datalist tag.

 

Now, this works fine but I dont lke the fact that I have EXTEMELY long Strings as values in my map, and because apex doesnt allow line breaks I am envisioning it will be hard to maintain.

 

I would be very grateful to hear from any SF experts to propose a better way of doing this, I am keen to learn so any pointers will be just as good.

 

Thanks a bunch.

  • September 10, 2009
  • Like
  • 0

I have a class where I am starting to see alot of the same code repeated and this is never ideal. Is there any way to refere to a variable name in a class dynamically? Below is what I have now. On my page I have a button that passes a param and clears this correct list. In my clear method I have alot of if else code.

 

It would be cool if I could somehow dynamically reference the Lists without have to hardcode the names. Is this possible?

 

 

Page:
<apex:commandButton value="Clear List" action="{!clearList}">
<apex:param value="divisions" assignTo="{!listToClear}"/>
</apex:commandButton>


Controller:
public String listToClear {get; set;}

List<cObject> divisions;
List<cObject> team;
List<cObject> infastructure;

public void clearList(){
if(listToClear == 'divisions'){
divisions = new List<cObject>();
}else if(listToClear == 'team'){
team = new List<cObject>();
}else if(listToClear == 'infastructure'){
infastructure = new List<cObject>();
}
}

 

Some like this. This code does not currently work:

 


public void clearList(){
this.get(listToClear) = new List<cObject>();
}

Is this even possible?

 

 

 

Message Edited by TehNrd on 09-02-2009 11:18 AM
  • September 02, 2009
  • Like
  • 0

I am finding it very irritating in a situation where I implement a Mass Update Button on a List View tab and I've Set the Button as Visualforce Page redirect then I CANNOT display a Message alert for User to First Select records, the way sControls work, I'm stuck here without any check for that button. And I cannot use scontrols for implementing the button.

 

Any suggestion or any info when will salesforce allow us to apply a Record Selection validation alert when we implement a List Button with Visualforce page redirect ?

I'm trying to finish up my testMethods on a Controller Extension I wrote for a Visualforce page.  The problem I'm running into is that the controller is involved in a lot of callouts.  There are a couple of Geocoding callouts to Google as well as 4 different callouts to our point of sale system.  Obviously testMethods don't allow callouts, but how can I get my coverage to 75% (currently at 48%) when so much of the code is tied up in callouts?  Suggestions?
  • February 19, 2009
  • Like
  • 0
I have a trigger on the QuotelineItem that has some complex discount logic, it has been through mutiple iterations of optimization.  It will run well within gov limits when dealing with a batch of 200 records.   The problem is when I need to do Apex DML to all quotelineItems on a large quote (500+ items) using Apex.    Ex: update [Select id from QuoteLineItem where id=:quoteid] ).  I get the Maximum CPU time exception.  

Since triggers run in there own transaction  I was under the assumtion that each execution of the triggers CPU time for the trigger would not be aggregated in the transaction where the Apex DML > 200 records is done,  but this does not seem to be the case.  

Can anyone shed some light on the accuracy of this aggregation and possible workarounds without using batch apex.
I have a trigger on the QuotelineItem that has some complex discount logic, it has been through mutiple iterations of optimization.  It will run well within gov limits when dealing with a batch of 200 records.   The problem is when we need to do Apex DML to all quotelineItems on a large quote (500+ items) using Apex.  (i.e. something like update [Select id from QuoteLineItem where id=:quoteid] ).  I get the Maximum CPU time exception.  
Since triggers run in there own transaction  I was under the assumtion that the trigger CPU time for the trigger would not be aggregated in the transaction where the Apex DML > 200 records is done,  but this does not seem to be the case.  

Can anyone shed some light on the accuracy of this aggregation and possible workarounds without using batch apex. 

Trying to write a test case for creating a group event however the child events for the invitee's do not get created.

 

When execution the code below in the debug console it works as expected and creates the child Event record for the invitee,  however when running in a test case the child event record does not get created.

 

 I Also tried checking for the events after a call to the Test.startTest() and it did not work either.

 

//Add Event
Event e = new Event(ActivityDateTime=DateTime.Now()+1, subject='Apex Event Demo', whatid='001............', DurationInMinutes=60);
insert e;	

//Add Invitee to event
EventRelation er1 = new EventRelation(EventId = e.id,  RelationId='005............');
insert er1;




 

 

 

The following component works as expected with the default attribute,  (also as tried with type=object[])

 

 

<apex:component >
<apex:attribute name="fieldset" type="string[]" description="VisualforceArrayList" default="{!$ObjectType.Metadata__c.FieldSets.RL_Default}" />
...

 however when leveraging the component and setting the fieldset I get:

 

 

Save error: Literal value is required for attribute fieldset in <c:metadataRelatedListFilter>

 

		<c:metadataRelatedListFilter metadataList="{!Metadata__c.ReferenceFrom__r}" tabname="childrel" title="Child Relationships" fieldset="{!Metadata__c.FieldSets.RL_SObject_ReferenceFrom}"/>

 Please advise,

 

-Tom

 

 

 

 

I have used this pattern in a few VF pages but since our upgrade to Winter 11 they no longer work. 

 

 

The correct param does gets does get passed in the POST, but never gets binded to property on the controller.

 

 

Ex:

 

 

    <apex:actionFunction action="{!refresh}" name="JSonSelect" rerender="selobj" >
        <apex:param name="firstParam" assignTo="{!selectedItem}" value="" />
    </apex:actionFunction>


 

 

Anyone else having problems with passing parameters in the actionFunction since the release of Winter 11?

 

 

-Tom

 

Action:

Mass update (~400 profiles) to grant read access to a custom object using the Profile Enhanced list view..  

 

Result:

This action granted read access to the custom object for all custom profile as expected,  however changed the tab settings to a select set of packaged tabs from 'default on' to hidden.

 

More details:

 

  • An profile audit trails were recorded for the read update to the custom object.
  • No profile audit trail were recorded for the packaged tab change from 'default on' to hidden was logged?
  • Only certain  tabs are effected (packaged ServiceMAX)
  • A subsequent manual tab setting change is recorded in the log.
  • This is not a onetime event and can be reproduced.
  • I did submit a ticket to both sfdc and serviceMax,  but usually have better luck here.

I cant see how  the following be possible using the force.com platform

 

  1. detect a change in the profile.
  2. make a modification to the profile without an audit trail. (even to make tab setting change would require a callout to the metadataAPI (unsupported, cluggy, but possible),  but that would at least show an audit trail )

 

I am looking to upgrade to eclipse 3.5,  and looking for some guidance in a couple of areas:

 

  • Which eclipse bundle to install if I am going to use it for only Force.com development (xml/html,.javascript, Force.com IDE, maybe Flash builder)
  • What are some recommended plug-ins other then the ones in the package. 
  • What differences can I expect from using eclipse 3.5.2 over my existing 3.3.2 build (force.com dev)

 

As for plug-ins here are my findings:

I found JSEclipse very useful when leveraging javascript in your VF pages, 

Also for documentation I have uses Green UML to make class diagrams however I could not get it to work directly with the class files so I had to copy into a java project to get it to work,  I would really like to find a way to create documentation easier.

 

Thanks in advance,

 

tom

 

 

 

 If I do a MySObject.GetSObjectType().getDescribe().fields.getMap() in anon block or in non-Sites VF page it will return all the field, 

 

BUT if i run the same VF page in Sites it wont return the standard fields... only the custom.   

 

Does anyone know why or what the workaround would be?

 

-Tom

 

reproduce:

 

public class reproduce_getMap { public string s {set;get;} public reproduce_getMap() { sobject q = new Account(); Map<String, SObjectField> flds = q.GetSObjectType().getDescribe().fields.getMap(); s=joint(flds.keyset(),','); system.debug(s); } //////////////////////////////////////////////////////////////////////////////////////////// private static string joint(SET<String> alist, String delim) { String out=''; for (String s :alist) out+=s+delim; return (out.length()>0) ? out.substring(0,out.length()-(delim.length())) : out; } }

 


<apex:page controller="reproduce_getMap"> {!s} </apex:page>

 


 

Is there anyway to reflect the properties of a custom class [like the output of system.debug(myClass);] into a string variable.

 

 

<apex:page> attribute language does not seem to maintain on postbacks.

 

<apex:page controller="mycontroller" language="en">

This renders the dates and currency in english as expected. However once I do a call to the custom controller via a commandbutton the page now renders the dates and currencies in the locale/language of the current user?

 and the dates on the inputfields are not excepted and return the following errors:

 

Errors:

• Invalid Date

• {0}: Conversion error occurred. 

 

Anyone else aware of this issue or/and a workaround?

 

 

 

 

I'm Trying force the pageblocks below to use 'en' as the translated language using the lang="en" attribute.  I tried using the attribute at all levels (pageblock, pageBlockSection, and below).  My person settings language is 'de' and its keeps render the labels in 'de', i would prefer not to hardcode the english labels unless neccessary.
Why does lang attribute not effect the labels?
 

<apex:pageBlock title="Section: Highlighted Call Reports" rendered="{!IF(sec5.selected==(2^16),'true','false')}" tabStyle="Call_Report__c" lang="en"> <apex:repeat value="{!callReportsHighlight}" var="crh" id="callReportsHighlight" > <apex:pageBlockSection columns="1" title="Section: {!crh.name} [{!crh.Channel__c}]" lang="en"> <apex:pageBlockSectionItem ><apex:outputLabel value="Name"/><apex:outputLink value="/{!crh.Id}" target="_blank">{!crh.Name}</apex:outputLink></apex:pageBlockSectionItem> <apex:outputField value="{!crh.Call_Date__c}" lang="en"/> <apex:pageBlockSectionItem ><apex:outputLabel value="Account Name"/><apex:outputLink value="/{!crh.Account__r.Id}" target="_blank">{!crh.Account__r.Name}</apex:outputLink></apex:pageBlockSectionItem> <apex:pageBlockSectionItem ><apex:outputLabel value="Related Initiative"/><apex:outputLink value="/{!crh.Related_Initiative__r.Id}" target="_blank">{!crh.Related_Initiative__r.Name}</apex:outputLink></apex:pageBlockSectionItem> <apex:outputField value="{!crh.Next_Steps__c}" lang="en"/> <apex:outputField value="{!crh.Summary__c}" lang="en"/> </apex:pageBlockSection> </apex:repeat> </apex:pageBlock> <apex:pageBlock title="Section: Summary Reports" rendered="{!IF(sec6.selected==(2^20),'true','false')}" tabStyle="Call_Report__c" lang="en"> <apex:repeat value="{!callReportsHighlight}" var="crh" id="callReportsSummary"> <apex:pageBlockSection columns="1" title="Section: {!crh.name} [{!crh.Status__c}]" lang="en"> <apex:pageBlockSectionItem ><apex:outputLabel value="Name"/><apex:outputLink value="/{!crh.Id}" target="_blank">{!crh.Name}</apex:outputLink></apex:pageBlockSectionItem> <apex:outputField value="{!crh.Type__c}" lang="en"/> <apex:outputField value="{!crh.Status__c}" lang="en"/> <apex:outputField value="{!crh.Call_Date__c}" lang="en"/> <apex:pageBlockSectionItem ><apex:outputLabel value="Account Name"/><apex:outputLink value="/{!crh.Account__r.Id}" target="_blank">{!crh.Account__r.Name}</apex:outputLink></apex:pageBlockSectionItem> <apex:outputField value="{!crh.Summary__c}" lang="en"/> <apex:outputField value="{!crh.Issues__c}" lang="en"/> <apex:outputField value="{!crh.Training_Update__c}" lang="en"/> <apex:outputField value="{!crh.Next_Steps__c}" lang="en"/> </apex:pageBlockSection> </apex:repeat> </apex:pageBlock>

 


Message Edited by tesii on 03-17-2009 06:14 AM

 

I am getting 'Too many script statements: 10201'

 Governor Limit error when submitting ~100 or more updates at a time via the list view. 

 

When using the list view,  does it update in batch?  If so, according to the docs in the case of 100 records I should have 10,000 + (100*200) = 30,000 script statements allowed not 10200.  

 

If it's not updating in batch then why doesn't it happen when doing 1-50 updates?

 

Additional Details:

 All the updates performed were not data changes,  just a hit to have the trigger executed

 This is not an issue when doing a single update via the edit.

 or  less then 50 via the list view.

 or 200 via the API.

I Also updated all record (+250k) via the API wo/ any gov limit errors, This proves its not caused by a differences in the records data causing difference logic to be applied.

 


Tom

 

 


 

 

 

 

 

 


 

>>All,
>>
>>Does anyone know if it is at all possible to get access to to the POST data from a visualforce page when posting from another domain. The >>example below works fine for GET but I actually prefer to use POST if at all possible.
>>
>>-Tom
 
Nevermind,
 
I was able to get the POST values using the same technique for GET fields by using.
ApexPages.CurrentPage().getParameters()
 
only caveat is you must post to the true url in my case:
 c.cs2.visual.force.com/apex/mypage
 
luckily the $Page.mypage returns the true url.
 
Sorry about the previous Message,  my sample code seemed to hose the page so I could not reply or remove
(don't use chrome to post messages and paste code).
 
-Tom
 
 
well here is the working code:
 
Code:
<apex:page>
<h1>Wrapper to Punchout Site</h1>
 <br></br><b>Browser Post URL:</b>  {!$Page.testProxy}
 <br></br>
 <apex:iframe src="http://127.0.0.1/fakePunchout/submitPOOM.html" id="Iframe_Punchout"/>
</apex:page>

----------------------------------------------------------------
submitPOOM.html
----------------------------------------------------------------
<html>
<body>
    <h1>DEMO Punchout FORM POST</h1>
    <form action="https://c.cs2.visual.force.com/apex/testProxy" method="POST" target="_top">
  <br/><input type="text" name="cxml-urlencoded" id="payload2" value="POST Entire URL-Encoded PunchOutOrderMessage"/>
        <input type="submit" value="confirm"/>
    </form>
    <br/><br/>

 <h1>DEMO Punchout FORM GET</h1>
    <form action="https://cs2.salesforce.com/apex/testProxy" method="GET" target="_top">
     <br/><input type="text" name="cxml-urlencoded" id="payload3" value="GET Entire URL-Encoded PunchOutOrderMessage"/>
        <input type="submit" value="confirm"/>
    </form>
</body>
</html>
----------------------------------------------------------------
testProxy
----------------------------------------------------------------

<apex:page controller="testProxy" action="{!init}">
  <form>
  <h1>SFDC - DEMO PROCESS POOM</h1> 
  <br></br>
  <textarea name="payload" style="width:500px;height=400px;">{!cxml}</textarea>
  <br></br>
  {!headers}
   <br></br>
  </form>
</apex:page>
----------------------------------------------------------------
public class testProxy {
    public string cxml{get; set;}
    public string headers {get; set;}

    public PageReference init() {
     if ( ApexPages.currentPage().getParameters().get('cxml-urlencoded') != null )
         cxml = ApexPages.currentPage().getParameters().get('cxml-urlencoded');
         
        headers='';
        MAP<string, string> hdrs = ApexPages.currentPage().getheaders();
        for (string key : hdrs.keySet() )
            headers += key + ' : ' + hdrs.get(key) + '\n';
    
        return null;
    }
}

 
 
 


Message Edited by tesii on 01-06-2009 12:35 PM

Message Edited by tesii on 01-06-2009 12:36 PM
All development and test Salesforce instances are experiencing some form of the following, we have confirmed that functionality was impacted / problem not observed until 7/6:

Visualforce Remoting Exception: Error parsing json response:
'Unexpected token <'.  Logged in?
 
xhr.responseText=
"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body onload="document.forms['workerForm'].submit()">
<form  action="https://pmic--Dev12.cs41.my.salesforce.com/visualforce/session" id="workerForm" method="post" name="workerForm" ><input type="hidden" name="url" id="url" value="https://pmic--dev12--c.cs41.visual.force.com/apexremote" />
</form>
</body>
</html>"

This is happening when using the Continuation for both JavaScript remoting and action functions.

Issues are intermittent... appear to be permission related... perhaps... because if a user with admin or admin like access logs in "as" the test account that encounters the problem, the problem is not observed. However, when logging in directly using that test account the problem is encountered. In one instance there have not been any code changes implemented by our internal team since 6/30, the organization worked correctly on 6/30, 7/1 and then on 7/5 it has been confirmed that until at least 3:30pm (central) fuctionality was correct. However, on 7/6 the above error began to be received.

Any suggestions or insights would be greatly appreciated...
 
Hello, I'm receiving an error message for something that I believe was custom built by our integration partners who are no longer working with us. Below is the message. I can get to the Apex Trigger Page, I just don't know what I should be changing. Can someone advise? Thank you!

Error:Apex trigger kell01_OpportunityTrigger caused an unexpected exception, contact your administrator: kell01_OpportunityTrigger: execution of AfterUpdate caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Opportunity.AccountId: Trigger.kell01_OpportunityTrigger: line 108, column 1
I have a small controller that I'm using and I'm trying to figure out if there is a way I can pass a cookie to a visualforce page within a PageRefernece.   I'd like the cookie to be available on my visualforce page so I can just do {!someCookieValue}.

Do I need to create another controller for the visualforce page I'm returning?

Here is the code:
 
public with sharing class pageController {

  public PageReference getTemplate() {

   Cookie someCookieValue = ApexPages.currentPage().getCookies().get('thecookie');
   return Page.HomePageTemplate;
   }

}

 
Hi guys/gals,

Do you have any idea on how to obtain the Cloak of Adventure sweatshirt after completing 5 badges on trailheads?

Source: http://go.pardot.com/l/27572/2016-01-06/4wy4tn?utm_campaign=newyear-trailhead-sweatshirt

I haven't received any email address or notification about the completion after I had received 5 new badges on my profile. 

The sweetshirt looks really cool and I want to get it :D  Ty
 
I have a trigger on the QuotelineItem that has some complex discount logic, it has been through mutiple iterations of optimization.  It will run well within gov limits when dealing with a batch of 200 records.   The problem is when I need to do Apex DML to all quotelineItems on a large quote (500+ items) using Apex.    Ex: update [Select id from QuoteLineItem where id=:quoteid] ).  I get the Maximum CPU time exception.  

Since triggers run in there own transaction  I was under the assumtion that each execution of the triggers CPU time for the trigger would not be aggregated in the transaction where the Apex DML > 200 records is done,  but this does not seem to be the case.  

Can anyone shed some light on the accuracy of this aggregation and possible workarounds without using batch apex.
I have a trigger on the QuotelineItem that has some complex discount logic, it has been through mutiple iterations of optimization.  It will run well within gov limits when dealing with a batch of 200 records.   The problem is when we need to do Apex DML to all quotelineItems on a large quote (500+ items) using Apex.  (i.e. something like update [Select id from QuoteLineItem where id=:quoteid] ).  I get the Maximum CPU time exception.  
Since triggers run in there own transaction  I was under the assumtion that the trigger CPU time for the trigger would not be aggregated in the transaction where the Apex DML > 200 records is done,  but this does not seem to be the case.  

Can anyone shed some light on the accuracy of this aggregation and possible workarounds without using batch apex. 
Hello All,

I was trying to update an exsting profile with few permissions to the custom object but I was getting some errors while doing these...
I also tried creating a new profile throgh APIs but it doesn't worked.

Below is the snippet of my code.. Please let mw know if I'm missing something in this code...
 
ProfileObjectPermissions pObj = new ProfileObjectPermissions();
		
		pObj.setAllowCreate(true);
		pObj.setAllowEdit(true);
		pObj.setAllowDelete(true);
		pObj.setObject("Accounts");
		pObj.setModifyAllRecords(true);
		
Profile p = new Profile();
		
		p.setObjectPermissions(new ProfileObjectPermissions[] {pObj});
		p.setCustom(true);
		p.setUserLicense("Salesforce Platform");
		p.setFullName("TestClient1");

//For Update I used....
SaveResult[] results = metadataConnection.updateMetadata(new Metadata[]{p});

//For Create I used...
SaveResult[] results = metadataConnection.CreateMetadata(new Metadata[]{p});

However, If i try to creat a custom field with same logic, it gets created...
But creating or updating a profile fails everytime...

Please advise with a solution

Thanks in advance!
Saurabh 
 
Hello,
If I have a picklist field with 4 options
a,
b,
c,
d
Yet I want option d to be locked so users can see it  but will not be able to select it. They they can  only  select options a,b or c. How do i implement that?

Thanks,

Ben
 
Im trying to make both partner and Metadata API callouts from within apex jobs. but since the UserInfo.getSession() does not work within an apex job I need to authenticate.  Is there any way to use an OAuth named credential to do this,  I been try to find a way to get the access_token and/or refresh_token from a named credential but have not found a way.
  • March 10, 2015
  • Like
  • 0

I am having trouble finding any documentation on:

 

1.  What is the difference between Abstract and Virtual classes (they seem to be the exact same to me)

 

2. What are some scenarios for using Abstract or Virtual classes (wrapper classes comes to mind but are these the right thing to use?)

 

3.  When would you use an Interface instead of an Abstract or Virtual?  I read they are only suppose to be signatures but I saw an example that had a method with code in it too..

  • July 25, 2013
  • Like
  • 0

Trying to write a test case for creating a group event however the child events for the invitee's do not get created.

 

When execution the code below in the debug console it works as expected and creates the child Event record for the invitee,  however when running in a test case the child event record does not get created.

 

 I Also tried checking for the events after a call to the Test.startTest() and it did not work either.

 

//Add Event
Event e = new Event(ActivityDateTime=DateTime.Now()+1, subject='Apex Event Demo', whatid='001............', DurationInMinutes=60);
insert e;	

//Add Invitee to event
EventRelation er1 = new EventRelation(EventId = e.id,  RelationId='005............');
insert er1;




 

Hi,

 

I have a trigger on quote line items.I have a custom number field on quote line item .Based on that value line items will be duplicated.

If user gives 3 in the custom field value then quote line items will be added in 3 number.

I am using a trigger for this.

Here is my code:

 

trigger AddingQuoteProducts on QuoteLineItem (before insert,before update) {

  List<QuoteLineItem> listItem = new List<QuoteLineItem>();
  for(QuoteLineItem qLI:trigger.new){  
      System.debug('*******'+qLI.customfield__c);  //////This value comes as null during insert and shows value during update.
     if(qLI.Customfield__c > 1){
      for(Integer i=1;i<qLI.CustomField__c;i++){
         QuoteLineItem qLiIt = new QuoteLineItem();
               qLiIt.QuoteId = qLI.QuoteId;
               qLiIt.UnitPrice = qLI.UnitPrice;
               system.debug('opp.PricebookEntry.Id '+qLI.PricebookEntryId);
               system.debug('opp.PricebookEntry.Product2.Id '+qLI.PricebookEntry.Product2.Id);
               qLiIt.PricebookEntryId = qLI.PricebookEntryId;               
               
               qLiIt.Quantity = qLI.Quantity;
               listItem.add(qLiIt);
      }
     }
     insert listItem;
  }  
}

It works fine in my dev org but not in my org.Also it works on update but not on insert.I dont understand what i am missing.

 

Please help!!!!!!!I need this ASAP

 

Hey guys-

 

I'm getting an error in testing "too many dml rows".  This is just an after update trigger that calls a class that will insert a custom object record when an opp gets updated to meet some criteria.

 

I think the error is due to me having a for loop in the trigger, then calling a class that has a for loop in it, but I'm not sure how to resolve this.

 

trigger:

 if (Trigger.isAfter) {

 
            for(Opportunity opp5:  Trigger.new) 
                if(Trigger.isUpdate && opp5.Threshold__c=='1' && Trigger.oldMap.get(opp5.Id).Threshold__c!='1')

                {
                   ServicesEngagementManager seFromOpp = new  ServicesEngagementManager();
                   seFromOpp.createEngagement2(Trigger.new);
                 }        

 Anyone see how to fix this issue?  The trigger works in sandbox but i can't move to prod bc of this too many dml row issue on bulk testing

 

 

class:

    public void createEngagement2 (List<Opportunity> oppsFromTrigger)
    {
        List< SFL5_Projects__c> engagementList = new List<SFL5_Projects__c>();
        for(Opportunity currentOpp: [SELECT Id,Services_to_be_Delivered_by__c,Owner.Id,Probability,Threshold__c,Account.Id,Account.Name,Region__c,
                                                       CreatedById,Account.Region__r.OwnerId,Account.Region__r.RSA_Manager__r.Id,Professional_Services__c, 
                                                       Name From Opportunity WHERE id IN: oppsFromTrigger])
        {  
            SFL5_Projects__c se = new SFL5_Projects__c();
                if(currentopp.Account.Region__r.RSA_Manager__r.Id!=null &&  currentopp.Account.Region__c !=null)
                {
                se.OwnerId = currentopp.Account.Region__r.RSA_Manager__r.Id;
	        } else
                {
		se.OwnerId = currentOpp.Owner.Id;
		}
                se.Name = 'Services Engagement for: '+ currentOpp.Account.Name;
                se.Opportunity__c = currentOpp.Id;
                se.Client__c = currentOpp.AccountId;
                se.Region__c = currentOpp.Region__c;
                se.Region__c = currentOpp.Region__c;
                se.Project_Status__c = 'Active';
                se.Services_Amount__c = currentOpp.Professional_Services__c;
                se.Services_to_be_Delivered_by__c = currentOpp.Services_to_be_Delivered_by__c;
                engagementList.add(se);
                 
         }
    Database.insert(engagementList);
    }

 

  • June 30, 2013
  • Like
  • 0

I have used this pattern in a few VF pages but since our upgrade to Winter 11 they no longer work. 

 

 

The correct param does gets does get passed in the POST, but never gets binded to property on the controller.

 

 

Ex:

 

 

    <apex:actionFunction action="{!refresh}" name="JSonSelect" rerender="selobj" >
        <apex:param name="firstParam" assignTo="{!selectedItem}" value="" />
    </apex:actionFunction>


 

 

Anyone else having problems with passing parameters in the actionFunction since the release of Winter 11?

 

 

-Tom

Hello,

 

We are seeing odd behavior with business hours in Apex. We are setting Milestone dates for a Project by starting with the Live Date (the final Milestone), and working backwards through the list of Milestones – each of which has a “days since previous Milestone”.  

 

This is the relevant portion of the block of code:

milliseconds = milestoneMap.get(j).Days_Since_Previous_Milestone__c.longValue() * 86400000L * -1;

 

System.debug('XXXXXX About to subtract ' + milliseconds + ' from ' + milestoneDateTime + ' for ' + projectMilestone.Milestone__c);

 

newMidDay = BusinessHours.add(bh.Id, milestoneDateTime, milliseconds);

 

System.debug('XXXXXX The number of milliseconds subtracted was ' + BusinessHours.diff(bh.id, newMidDay, milestoneDateTime)); 

 

When we run the Debug Log, it reads “XXXXXX About to subtract -172800000 from 2010-06-22 00:00:00 for a09R0000005dlMSIAY”, which is correct, because the next Milestone is two business days earlier, and there are 172800000 milliseconds in two days (it does read that it’s going to “subtract” a negative number, but you can see how the code is actually adding the negative number).  Now, the next debug entry, which is after only one line of code (the BusinessHours.add) states “XXXXXX The number of milliseconds subtracted was 86400000”.  How could this be?  So, it’s saying “I’m about to subtract 172800000 milliseconds, but I actually subtracted 86400000.”

 

Our only Business Hours record has 24 hours Mon - Fri and zero hours on Sat and Sun (I've confirmed through Apex Explorer).  No holidays.  The above example is subtracting two days from Monday and arriving at Friday (when it should arrive at Thursday, and should also not contradict itself with stating it's going to subtract one number but actually subtracting another).  This is also odd, because if it was "ignoring" business hours completely, it would have subtracted two days from Monday and arrived at Sunday.  Yet, if it subtracts two days from a Thursday, it accurately arrives at Tuesday (the debug log states “I’m about to subtract 172800000 milliseconds, and I did subtract 172800000.”

 

Thoughts?

 

Thanks,

Marc

Can anyone tell me if  it is possible to get binary data back from a web service callout?

 

I am using the apex Http, HttpRequest and HttpResponse classes to call an external  service that returns a binary file. I then attach that file to an email programatically. Everything works fine, except that my binary data in the attachment is mangled, because of the string conversion on response.getBody(). Is there a way to retrieve the binary stream from the HttpResponse class without corrupting it? 

 

Or is there another set of classes I should use to perform this function to get the results I'm looking for? 

 

Thanks for any help!

Gretchen

 

 

  • November 04, 2009
  • Like
  • 0