• philbo
  • NEWBIE
  • 65 Points
  • Member since 2007

  • Chatter
    Feed
  • 2
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 93
    Replies
Hi,

Here's my situation. I'm working on an application in a developer organization. I've created an extra user for the end user of the application I've created so I can get feedback from the end user as I'm developing the application. I would like to write test cases with users that are created with DML as was recommend and demoed at dreamforce. The problem is that the developer organization has a limit of 2 user licenses. That's fine, so I thought I'll just delete the users in the test method and create new generic ones and at the end of the tests everything would roll back. Unfortunately I received the error that DML is not allowed on the user object. Is there anyway around this?

Thanks!
Scott

Hi all,

 

hoping someone can QUICKLY weigh in with a sol'n here as I have minimal time to get this resolved.

 

I have an Apex trigger that builds a fairly complex dynamic SOQL query based on the trigger's input records.  When the trigger executes the query, it throws a 'Non-selective query against large object type' error.

 

However - when I scrape that query out of the trigger and run it anonymously, it runs successfully.  When I put it in its own static class method and run the method, it runs successfully.

 

I have tried both class and trigger on API versions 15.0 and 20.0 with consistent results.

 

I am not that interested in this point in how my query could be restructured to avoid the exception, although I will say that the fields it returns AND the fields in its query clause are all lookup fields (plus the IsDeleted flag).  What is of crucial interest to me is - why does the query behave differently between trigger and non-trigger context?  Is this to be expected, and if so, can someone please point me to the documentation that says it is to be expected? 

 

Thanks.  Anxiously awaiting a response....

 

  • November 23, 2011
  • Like
  • 0

Hi all,

 

We have some infrastructure built out that adds/removes Manual Shares on particular SObject records based on certain conditions within our application.

 

As a matter of course, situations arise where we are about to add a Manual Share to a record, but the User in question already owns the record so there's an Owner Share already in the system.  In that case, according to the Force.com documentation, we should expect the Manual Share insertion to throw a 'FIELD_FILTER_VALIDATION_EXCEPTION' exception, with error message containing the string 'AccessLevel', and best practice is to simply ignore the exception.

 

HOWEVER, we don't see this exception when we "try" to overwrite an Owner Share with a Manual Share.  Instead, we see:  'INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY' with msg 'Insufficient access rights on cross-reference id: []'.  (Note the useless nothing inside those square brackets.)  This seems to be regardless of who the owner is.  Even if the record (and Owner Share) is owned by the logged-in User, and that same User is trying to insert a Manual Share hooked to himself, the same exception is thrown.  (This user is a System Administrator, btw)

 

So what are we supposed to do?  Ignore THIS error as a matter of course?  I don't want to just start blindly doing that, in case there are situations where this does mean something really erroneous.

 

Words of wisdom anybody?  (esp. within SFDC's walls)

 

thanks

  • November 01, 2011
  • Like
  • 0

Hey,

 

When I use System.Schedule() to schedule an Apex job, I am experiencing some strange behavior:

 

* The job does show up on the 'Scheduled Jobs' page on the org, but its 'Manage' link is missing (the only link beside the job entry is 'Del').

 

* According to the 'Scheduled Jobs' page, the job does run at the scheduled time, but there is no evidence anywhere else in the org that the job actually run.  No debug logs appear and none of the side-effects of the job appear on the org.  I even stubbed out the class' execute() method with a System.assert ( False ) statement, to make it throw out an error email, but that doesn't happen either.  It definitely seems like nothing at all is being executed.

 

When I schedule the job via the UI (Develop -> Apex Classes -> Schedule Apex), it runs fine as expected.

 

Why is this?

 

(and why oh why is the page behind the 'Manage' link read-only??)

 

Thanks

  • October 27, 2011
  • Like
  • 2

Hey,

 

Just canvassing the community here for some feedback on Apex script performance.

 

We have been doing some pretty detailed analysis on our Apex code base to diagnose some performance issues with our application.  We were expecting to see the app getting hung up waiting for some SOQL query to execute.  Somewhat to our surprise, that turned out not to be the case; instead, we seem to be suffering from a 'death-by-a-thousand-cuts' scenario where most of the elapsed time is taken up by the execution of the Apex code itself.

 

Based on our debug logs, it looks like Apex script execution chugs along at a rate of roughly 10 statements per millisecond (seems to vary widely, anywhere between 5 and 15 per ms).  This is excluding all interaction with the database - strictly script execution.

 

Can anybody corroborate/refute this observation?  As it stands, we have web service methods in our application's back end that can execute anywhere between 10,000 and 100,000 script statements, depending on what is being asked for (and what the underlying data set size is).  Meaning, our application's FRONT end sits there for seconds on end waiting for its WS call to return.  Not a happy user experience.

 

Our position is, 10,000-100,000 executed statements in a method is peanuts, and 10 seconds is a long time to wait.  (Maybe this is a debatable point?) 

 

Any input from the community is most welcome!

 

Thanks

 

  • September 15, 2011
  • Like
  • 0

Hey,

 

Feel a little foolish resorting to the dev boards on this - but - as of today all of a sudden, on this one particular Sandbox org, I can't get to Setup -> Monitoring -> Debug Logs - it throws up a login screen that I can't get past.  Type the correct credentials in and it just bounces back to the same screen.

 

This behavior has persisted through a complete cookie cleanout, deletion of history, the whole bit (Firefox AND IE).  It is only happening on one org, and only for myself - my colleagues can get to the page no problem.

 

Any idea why this would be?  Worrisome that it's just me (also indicative that it's probably a stupid problem) and also that it's both browsers.

 

** edit ** : oh and the URL of the login page I get kicked out to is, https://test.salesforce.com/?ec=302&startURL=blahBlahBlah...  Note the 'ec=302' parameter.  Does my browser think the Debug Log location has changed?? ** edit **

 

 

 

Thanks if anyone can suggest anything....

 

-mr. frustrated

 

  • January 25, 2011
  • Like
  • 0

Hey,

 

Hopefully someone out there can help me on this (and is alertly reading this dev board).

 

I have a Perl script that uses WWW::Salesforce to read data in from a SFDC org, do a whole bunch of transformation, and write data back in via upsert().  The structure and flow all seems fine, and all aspects of SFDC connectivity are functional.  EXCEPT when trying to write non-ASCII chars back to SF.  The use case is as follows:

 

1. Use 'query()' to pull a record from a custom Salesforce object.  The record's Name is 'Québec'.  Note the accented char, whose hex value appears to be 'c3a9' by the time it is pulled into my Perl script.

 

2. Assign this value to the Name field of a brand new record of another custom SF object, and use 'upsert()' to write this record to Salesforce.

 

This fails, with the following information in $result->envelope->{Body}->{upsertResponse}->{result}->{errors}:

 

errors->{fields} : Name

errors->{message} : <objLabel>: value not of required type: core.filemanager.ByteBlobValue@<hexNum>

errors->{statusCode} : INVALID_TYPE_ON_FIELD_IN_RECORD

 

I have tried encoding and decoding the field six ways to Sunday, using everything available in the Encode module (ascii, ascii-ctrl, iso-8859-1, null, utf-8-strict, utf-8), to no avail.  I even tried HTML::Entities and 'encode_entities()', but that changes the accented 'e' character to '&eacute;' which then gets passed verbatim to SF, which clearly I don't want (and should have expected).

 

My WWW::Salesforce module version is 0.12.

 

How can I get fields with characters like this into Salesforce from my Perl script?

 

Thanks.

 

 

 

  • January 06, 2011
  • Like
  • 0

OK, here's the thing:

 

We have a VF page consisting mostly of an <apex:tabPanel> containing several <apex:tab> components.  The contents of these tabs are somewhat complex and take a bit of time to build, so we don't want to ever re-render the tabPanel if we can help it.

 

Each tab contains controls that allow navigation away from this page (e.g. one contains a related list with the standard Edit/New controls). When we do so, and now we're on whatever other page, and we hit Save or Cancel, we are returned to our VF page as expected, and it is re-rendered at that time.  

 

Back on our VF page, though, we are now sitting on the page's default tab, as opposed to the tab we were on when we navigated away.  This is the problem I'm trying to solve.  I have envisioned the following approaches:

 

1) Inject the currently active tab (name or Id) into the current URL via a page parameter, whenever a tab is selected. 

 

I have not gotten this to work because I cannot modify the current URL without causing the whole page to re-render, and that is unacceptable because of load time.  I tried modifying the current URL both in the controller (via an actionFunction linked to the 'ontabenter' event of the tab - NOT by setting the tabPanel's 'switchType' attribute to 'ajax' or 'server', which also causes a page re-render), and via javascript, modifying 'window.location.search' directly, but neither allows me to sneak the parameter into the page without re-rendering it.  Which I suppose is to be expected.

 

2) Remember the currently active tab in a cookie.  Then, when the page is initialized (or re-initialized when we return to it), grab the cookie and use its value to set the active tab.  

 

If I could get the cookie value back into the controller as part of its initialization, then this would work easily, as I could then use it to set a controller property, and bind it to the tabPanel's 'value' attribute before the tabPanel gets rendered.  But I don't know of any way to do that.

 

Alternatively, I could conceivably use the cookie directly in Javascript to poke whatever information into the underlying HTML to 'spoof' a tab selection.  I did actually look into this, inspecting the HTML of a sample page, and I see style classes like 'dr-tbpnl-tbcell-inact' vs. 'dr-tbpnl-tbcell-act' that I could maybe toggle on the appropriate page components.  Or maybe there's some JS method that already exists, buried in main.js or somewhere, that could be leveraged?  Seems a little risky to me, reverse-engineering SF functionality - dodgy at best and non-forward-compatible at worst.

 

Anybody got any suggestions about this?  Remember, the key point here is to keep track of tab changes without re-rendering the tabPanel, in a way that survives navigating away from + back to the page.

 

Thanks!

 

  • January 28, 2010
  • Like
  • 0

Hey,

 

Couple of questions about merging Accounts, where there's one Master Acct and one or two 'victims':

  1. Clearly this causes an update to the Master and deletions to the victims.  Presumably these DML operations fire whatever Apex triggers are there.  Is there some field on the Account object that I can consult in an Update trigger, to tell me that this update was the result of a merge?  And - is there anything that gets set on a 'victim' Acct just before it's deleted, that a Delete trigger can consult to see that this deletion was the result of a merge - and to which Master Acct?
  2. The documentation says that all related lists of a 'victim' Acct are re-parented to the Master Acct.What about this operation - does it cause the Update triggers to fire on those related lists?  (I have a suspicion the answer is 'no'.)

Anyone out there know about this stuff?

 

Thanks!

  • November 18, 2009
  • Like
  • 0

Hey,

 

We are seeing some strange behaviour with a VF controller we're trying to deploy from a Sandbox org to production.  In our org we have a parent-child relationship (lookup) between two objects.  A method in the controller class creates a record of the parent object, and then creates a child object record, linking it to the new parent record (newChildRec.Parent__c = parentRec.Id ).  This is all in one method, so presumably it's all taking place in a single transaction.

 

So this works fine in the sandbox, and the covering testMethod works fine too - both parent and child records are created no problem.

 

But when we try to deploy to the production org, the testMethod fails, saying (roughly) "Unable to obtain exclusive access to the record" (UNABLE_TO_LOCK_ROW) when trying to create the CHILD record.  Why would this be?  I do understand that when you create a child object record, the system locks the parent record.  But how come this would work on the sandbox but not when we try to deploy to production?  Wouldn't the fact that this is within the same transaction cause this failure to NOT happen?  Could it have to do with API versions, perhaps?  The controller in question is 15.0, and it is being deployed using Eclipse with force.com plugin version 15.0.    The sandbox is on Summer '09 whereas the prod org is of course still on Spring '09, in case that makes a difference.

 

Can someone advise, by any chance?  

 

Thanks!

Hey,

 

Where does the debug log go when you run tests via <sf:deploy> within an ANT script?

 

e.g. I have the following target

 

 

<target name="runTests"> <sf:deploy checkOnly="true" username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="codeDir" logType="Detail"> <runTest>MyTestClass</runTest> </sf:deploy> </target>

 

 ...and I would like to see the output of all the System.debug()'s in the testmethods within MyTestClass.

 

Is there a way to do this?

 

Thanks!

 

 

Hey,

 

I have an e-mail service set up, with no restrictions on the source domain (i.e. 'Accept Email From' is blank - it says on the GUI 'All email addresses (subject to security settings)').  I am able to send e-mails to the service's address from my WORK account, but not from my PERSONAL account - the latter bounces, saying '<personalEmailAddr> is not authorized to send emails to this service'.  I would like to understand what it is that is imposing this restriction - some org-level setting presumably. 

 

Our real issue is that we have a client with an automated system that is sending e-mails to this service - and we just discovered that the e-mails have not been processed since around 12 February, both in PROD and in SANDBOX.  Unquestionably the e-mails are being sent and their format is correct - not sure if they're bouncing (client is checking right now).  My current theory is that some security setting changed around that time and now the SFDC e-mail service is no longer accepting e-mails from our client's domain.  I'd like to know how I can confirm/refute this theory.  I haven't found anything helpful in the discussion boards or help pages.....

 

Anybody got any words of wisdom on this?

 

Thanks!

  • March 16, 2009
  • Like
  • 0

Hey,

 

This is related to an earlier post:

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=10588

 

I am trying to make a VF data grid without knowing at compile time how many columns the grid is going to have.  Using straight HTML combined with VF markup, I have managed to do so, via the <apex:repeat> component.  Now I'm trying to take it one step further - I want to hook an actionSupport to each cell in my (one-row) grid so I can write its contents back to the controller and re-render the page (or a part of it).  A mock-up VF page and controller are as follows:

 

Page:

 

<apex:page id="mainPage" controller="testCtrlr" > <apex:form id="mainForm"> <apex:outputPanel id="clickedCell"> <apex:outputText value="Clicked : {!clickedCell}"/> <apex:actionSupport event="onclick" rerender="clickedCell"> <apex:param assignTo="{!clickedCell}" value="TEXT CLICKED {!NOW()}"/> </apex:actionSupport> </apex:outputPanel> <table> <tr> <apex:repeat value="{!rowData}" var="cell"> <td> <apex:outputPanel > <apex:outputText id="rowCell" value="{!cell}"/> <apex:actionSupport event="onclick" rerender="mainPage:mainForm:clickedCell"> <apex:param assignTo="{!clickedCell}" value="{!cell} {!NOW()}"/> </apex:actionSupport> </apex:outputPanel> </td> </apex:repeat> </tr> </table> </apex:form> </apex:page>

 

...and Controller:

 

public class testCtrlr { public String[] rowData { get { return new String[] { 'CELL 0' , 'CELL 1' , 'CELL 2' , 'CELL 3' }; } set; } public String clickedCell { get; set {
System.debug ( 'SETTING clickedCell to [' + value + ']' );
clickedCell = value;
}
} }

 

A couple of things about this don't seem to work.

  1. The resulting one-row table has four cells, containing the contents of the 'rowData' array ('CELL 0', etc.).  I would expect to be able to click on any of these cells and have its contents written into the 'clickedCell' property - and then displayed on the page thanks to the 'rerender' attribute of the 'actionSupport' component.  But what actually happens is - it only works for the right-most cell, the one containing 'CELL 3', and then only if it is the very first cell I click.  The AJAX refresh always seems to take place, according to my System Log window, but the only time the 'clickedCell's setter method is invoked is if the right-most cell is clicked the FIRST TIME, and never after for any cell.  It's as if the <apex:param> component ceases to work after the first time (and never does at all if any other cell is clicked).  I took a look at the page source and, though I don't really know what I'm looking at, it seems like all the cells have the same or similar 'onclick' directive.
  2. Notice the actionSupport attached to the 'clickedCell' outputPanel, updating the 'clickedCell' property to 'TEXT CLICKED' when you click on it.  I put that in there to demonstrate that THIS component does not have the same problem - you can click on it repeatedly and the 'clickedCell' property always gets set like it's supposed to.

Is there something I'm missing, here?  I feel like I'm <THIS> close, but not quite there.

 

Thanks, anybody who can comment on this.

 

 

  • March 05, 2009
  • Like
  • 0
Hey,

 

We have been trying to create a Visualforce framework which can support the display of the results of any SOQL query - without anything pre-determined at compile time.  

 

The controller component uses a set of Apex classes, which are instantiated with the following information:


  • The SObject name we want to query
  • The field names we want to query (including relationship fields; e.g. 'Account.Name')
  • The widths of the grid columns on the resulting VF page table 
  • The query clause


All specified by strings.  And then using Database.query() and subsequent SObject.get (fldName) and SObject.getSObject (relpFldName) calls, we can create a matrix of data from the result set.  Note that the number of fields is determined at run-time, and so the number of columns in the resulting dataTable on the VF page is also determined at run-time.

We managed to build this and it works well.  Problems arise, however, trying to get this matrix displayed on the VF page. 

 

My first approach was to use the <apex:repeat> component, as follows:

 

 

<apex:dataTable value="{!myDynamicGrid}" var="myGridRow"> <apex:repeat value="{!myGridRow.columns}" var="myGridCell"> <apex:column width="{!myGridCell.width}"> <apex:outputText value="{!myGridCell.text}"/> </apex:column> </apex:repeat> </apex:dataTable>

 

But this doesn't even compile - apparently <apex:column> must be a direct child of <apex:dataTable>.

 

I have tried rolling my own a bit, using a hybrid of Visualforce markup and straight HTML, with no success.

 

Has anyone out there ever tried something like this?  Is there a way to accomplish this on a VF page, without resorting to ugly hard-coded column components on the VF page?

 

Thanks!

 

 

 

 

  • March 03, 2009
  • Like
  • 0
Hey,

I have a VF page, containing the following fragment:

<apex:column id="colId" ondblclick="myVSFn(id)" headerondblclick="myVSFn(id)">
  <apex:facet name="header">{!myColHdr}</apex:facet>
  <apex:outputText value="{!iObj.Field__c}"/>
</apex:column>

...This is embedded within a dataTable that populates this column in the usual way.    I'm trying to bind the column header to a controller property so that I can control it at run-time.  The controller method is:

public String myColHdr {
  get {
    return ( myColHdr == Null — 'COL HDR &nbsp; &darr;' : rsnHdr );
  }
  set;
}

Pretty straightforward - just for the purposes of testing - I'm trying to inject a couple of HTML symbols into that column header, in the hopes that it will show up on the page as 'COL HDR v'  ('v' representing a down-arrow here).  But instead, it is displayed verbatim, with the HTML symbols uninterpreted.  Looking at the resulting page source, it appears that the ampersands in the text are being converted to '&amp;'; i.e. the page src looks like 'COL HDR &amp;nbsp; &amp;darr;'

Is there a way around this?  How can I suppress this ampersand conversion?  I tried escaping them, quoting them, etc., to no avail.  I know there's an 'escape=False' attribute you can set on certain components, but not on this one.  Is there some way I can leverage this for a column header?

(The '&darr;' symbol was not chosen at random - I'm trying to work out a way to indicate on the screen whether the dataTable is sorted on that column, and whether it is Ascending or Descending).

Thanks!


Message Edited by philbo on 12-17-2008 02:08 PM
  • December 17, 2008
  • Like
  • 0
Hey,

Should I be expecting the 'headeronclick' and 'footeronclick' attributes to work per the VF documentation?

I have a block in my VF page looking like:

<apex:pageBlock id="myPB"> 
  <apex:pageBlockSection columns="1" title="My PB Section" id="pbSection">
    <apex:pageBlockSectionItem id="pbSectionItem">   
      <apex:outputPanel id="myPanel" layout="block">
        <apex:dataTable  value="{!myCtrlrMethod}" var="iObj">
          <apex:column id="colId" 
headerValue="colHdr"
footerValue="colFtr"
onclick="yyy(event,id)"
footeronclick="xxx(event,id)"
headeronclick="xxx(event,id)"> <apex:outputText value="{!iObj.Field__c}"/> </apex:column> . . . </apex:dataTable> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageBlockSection> . . . </apex:pageBlock>

 where 'xxx(event,id)' and 'yyy(event.id)' are just little Javascript placeholder methods that pop up an alert identifying themselves.

When I render the page, filling the dataTable with Field__c values from the results of myCtrlrMethod, and then click in any of the data cells of that one column, the 'yyy' method runs, as evidenced by an alert popping up.  But when I click on the header or footer cell of the column - nothing.

What is wrong with this scenario?  It also doesn't work if I setup the column's header text with an
  <apex:facet name="header">colHdr</apex:facet>
directive.

Any sage advice out there?




Message Edited by philbo on 12-10-2008 10:14 PM
  • December 11, 2008
  • Like
  • 0
Hey,

I will be finding this out for myself in the next little while, but meanwhile:  Does anybody know whether the following is possible?

Say we have a managed package, with NS prefix 'XXX' and the following class:

global virtual class baseClass {

    WebService String baseString;

    public baseClass () {
        baseString = 'bsaeClass instantiated';
    }
}

 We have this package deployed on an org, and now we want to do the following:

global class myClass extends XXX.baseClass {

    WebService String myString;

    public myClass () {
        super ();  // --- not sure if this is necessary ---
        myString = 'myClass instantiated';
    }
}

Is this legal?  Can you extend a virtual base class, if that class is sitting inside a managed package?  Can you even include virtual classes within a managed package, for that matter?
  • December 08, 2008
  • Like
  • 0
Hey,

We have an org whose Lead object has Apex trigger code attached to it, that converts a new/updated Lead to an Account and Contact under certain circumstances (which boil down to:  are all the necessary fields properly filled in?).  This is fully built out and works well.   Also in this org we have Web-to-Lead set up, with the intention that a properly filled-in Web Lead form will cause a Lead to be created and immediately converted upon initial save, creating an Account and a Contact on the system.  Again this works well - but with one small wrinkle. 

In cases where a Web-created Lead is inserted and auto-converts, the default Lead owner gets an e-mail titled "Salesforce Lead Alert", containing the following:

Alert: Salesforce experienced the following problem creating the lead below:

Reason: Your Lead could not be processed.

...and then a whole bunch of field Ids and their values.


I can only surmise that the auto-conversion of the Lead is confusing the Web-to-Lead process and causing this e-mail to be sent out.  Can anyone corroborate this?  Is there any workaround?  Is there a way to suppress these e-mails?  Not so much because they're annoying and misleading, but more because now there's client data sitting in those e-mails, that is flying around the Internet in cleartext.

Thanks
  • November 25, 2008
  • Like
  • 0
Hey,

Here's a new one:

I have a custom object Obj__c, one of whose fields UniqFld__c is flagged as unique.  This field gets populated in a Before Insert/Update trigger on the object - its value is derived from a couple of other (reference) fields Ref1__c and Ref2__c on the object.  The idea is to ensure that no two Obj__c records can exist linked to the same combination of Ref1__c and Ref2__c records.

This works correctly in a whole bunch of different scenarios - creating/updating from the GUI, inserting/updating via anonymous Apex - it throws an error any time a duplicate UniqFld__c value is detected.

But here's a problem I found, starting with the following Obj__c records:

  Obj__c obj1 = new Obj__c ( Ref1__c = ref1_1.Id , Ref2__c = ref2_1.Id );
  Obj__c obj2 = new Obj__c ( Ref1__c = ref1_2.Id , Ref2__c = ref2_2.Id );


...I already have an Obj__c record matching the first of these (obj1), but not the second.

If I go

  insert new Obj__c[] { obj1 , obj2 };

then the resulting duplicate UniqFld__c is created by the trigger, caught by SF and the whole thing craps out like it's supposed to.

And if I go

  Database.saveResult[] resList = Database.insert ( new Obj__c[] { obj1 , obj2 } , True );

the second 'True' arg indicating All or None, then the same behavour happens - the whole thing fails, as expected.

But if I change that arg to indicate NOT All or None:

  Database.saveResult[] resList = Database.insert ( new Obj__c[] { obj1 , obj2 } , False );

expecting obj1 to fail and obj2 to succeed - something unexpected happens instead:
  • Both records are successfully inserted into the database.
  • Although the Before trigger does run, supposedly populating the UniqFld__c field on both obj1 and obj2 (as confirmed by substantial System.debug()s), the field is NOT SET in the resulting Obj__c records in the database.
So it's breaking in two different (but presumably somehow related) ways. 

If I pass a single 'duplicate' Obj__c record into Database.insert(), it works as expected, as it also does with multiple 'good' or multiple 'duplicate' records.  It's only when the list is a mixture of 'good' and 'duplicate' records that this unexpected behaviour happens.

Oh - and if I call Database.update() with a 'good' record and a more blatantly 'bad' record (e.g. a bogus value in the Ref1__c field), then it works like it's supposed to - one rejected record and one inserted record whose UniqFld__c field is correctly filled out.

Has anyone experienced anything similar along these lines?  I can't help but think it's a SF bug but who knows, maybe it's something subtle I'm doing wrong.

Any input/commentary/whatever - would be MOST appreciated.


Message Edited by philbo on 11-19-2008 03:59 PM

Message Edited by philbo on 11-19-2008 04:08 PM
  • November 19, 2008
  • Like
  • 0
Hey,

Anybody come across this problem before?  Here's some code to send out a single e-mail:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage ();
mail.setToAddresses ( new String[] { 'xxx.yyy.zzz' } );
mail.setSubject ( 'TEST' );
mail.setPlainTextBody ( 'TEST' );

Messaging.sendEmailResult[] results = Messaging.sendEmail ( 
                                           new Messaging.SingleEmailMessage[] { mail } , False
                                      );
for ( Messaging.sendEmailResult result : results ) {
    if ( !result.isSuccess () ) {
        System.debug ( result );
} }

Note the deliberately bogus e-mail address.  When you run this, the following text is debug'ed out:

Messaging.SendEmailResult[
  getErrors=(
    Messaging.SendEmailError[
      getFields=null;
      getMessage=Invalid to address xx.yyy.zzz;
      getStatusCode=System.StatusCode.INVALID_EMAIL_ADDRESS;
      getTargetObjectId=null;
    ]
  );
  isSuccess=false;
]

 
Note that the getErrors() "member" is a Messaging.SendEmailError[] array, as specified in the Apex Ref Guide.

Now change the loop to

for ( Messaging.sendEmailResult result : results ) {
if ( !result.isSuccess () ) {
Messaging.sendEmailError[] errs = result.getErrors ();
}
}

Seems reasonable, based on the first code fragment - but in fact it doesn't even compile:
Illegal assignment from LIST:Database.Error to LIST:Messaging.SendEmailError

So - change the loop as follows:

Code:
for ( Messaging.sendEmailResult result : results ) {
if ( !result.isSuccess () ) {
Database.error[] errs = result.getErrors ();
}
}

and it compiles, but now throws a run-time error, to the effect that you can't cast a Messaging.SendEmailError object to a
Database.error. Seems like some sort of internal inconsistency.

OK - now here's the real WTF about this: Everything I've written here was demonstrably true until 30 min ago - but as of now -
 the last loop does not throw that run-time error any more! I would just discard this msg, but it took me a certain amount of effort
and now I'd like to share my worry about the behaviour of production orgs (yes, I was testing both in Sandbox and in Prod
throughout) changing in the middle of a working day.

Thoughts/insight anyone?
 
  • November 17, 2008
  • Like
  • 0
Hey,

Running into some strange behaviour in an application of mine.  One of its components is a custom object whose creation is bracketed by a 'before insert' and an 'after insert' trigger.

These triggers take advantage of the following feature: In your 'before insert' trigger, if you set an object field to some value, then the object has that field value in the 'after insert' trigger.  Furthermore, in the 'after insert' trigger, if you select that object's field out of the database via SOQL, you'll get back the value you set in the 'before insert' trigger.

This has worked flawlessly until today.  Today, my app failed, and when I looked for the cause, I discovered that under sufficiently bulk-y conditions, the above feature ceases to work.  The app was creating 97 records of this custom object, each with a certain field that was being set by the object's 'before' trigger, and these field values were NOT SHOWING UP in the after trigger, either in trigger.new or in the database.

Just for "fun", I did a few tests and discovered an upper threshold of 55 object records.  55 records and below, and the above feature holds.  56 and above, and it ceases to hold.  I suspect there's nothing special about the number '55', it's probably specific to my environment, which is quite complex, but there is undeniably an upper limit and it's breaking my application.

Can any of you corroborate this behaviour in bulk conditions?  Why is this happening?  Smells like an Apex bug to me.  Any experts want to weigh in on this?

(Don't ask if my triggers are bulk-safe.  They're bulk-safe.  :^} )

Thanks
  • October 31, 2008
  • Like
  • 0

Hey,

 

When I use System.Schedule() to schedule an Apex job, I am experiencing some strange behavior:

 

* The job does show up on the 'Scheduled Jobs' page on the org, but its 'Manage' link is missing (the only link beside the job entry is 'Del').

 

* According to the 'Scheduled Jobs' page, the job does run at the scheduled time, but there is no evidence anywhere else in the org that the job actually run.  No debug logs appear and none of the side-effects of the job appear on the org.  I even stubbed out the class' execute() method with a System.assert ( False ) statement, to make it throw out an error email, but that doesn't happen either.  It definitely seems like nothing at all is being executed.

 

When I schedule the job via the UI (Develop -> Apex Classes -> Schedule Apex), it runs fine as expected.

 

Why is this?

 

(and why oh why is the page behind the 'Manage' link read-only??)

 

Thanks

  • October 27, 2011
  • Like
  • 2

Hi all,

 

hoping someone can QUICKLY weigh in with a sol'n here as I have minimal time to get this resolved.

 

I have an Apex trigger that builds a fairly complex dynamic SOQL query based on the trigger's input records.  When the trigger executes the query, it throws a 'Non-selective query against large object type' error.

 

However - when I scrape that query out of the trigger and run it anonymously, it runs successfully.  When I put it in its own static class method and run the method, it runs successfully.

 

I have tried both class and trigger on API versions 15.0 and 20.0 with consistent results.

 

I am not that interested in this point in how my query could be restructured to avoid the exception, although I will say that the fields it returns AND the fields in its query clause are all lookup fields (plus the IsDeleted flag).  What is of crucial interest to me is - why does the query behave differently between trigger and non-trigger context?  Is this to be expected, and if so, can someone please point me to the documentation that says it is to be expected? 

 

Thanks.  Anxiously awaiting a response....

 

  • November 23, 2011
  • Like
  • 0

Hey,

 

When I use System.Schedule() to schedule an Apex job, I am experiencing some strange behavior:

 

* The job does show up on the 'Scheduled Jobs' page on the org, but its 'Manage' link is missing (the only link beside the job entry is 'Del').

 

* According to the 'Scheduled Jobs' page, the job does run at the scheduled time, but there is no evidence anywhere else in the org that the job actually run.  No debug logs appear and none of the side-effects of the job appear on the org.  I even stubbed out the class' execute() method with a System.assert ( False ) statement, to make it throw out an error email, but that doesn't happen either.  It definitely seems like nothing at all is being executed.

 

When I schedule the job via the UI (Develop -> Apex Classes -> Schedule Apex), it runs fine as expected.

 

Why is this?

 

(and why oh why is the page behind the 'Manage' link read-only??)

 

Thanks

  • October 27, 2011
  • Like
  • 2

Hello,

 

Over the weekend, our sandbox was upgraded to Winter '12, and many of my Apex tests have failures now.

 

For instance, I have a test that tries to save a Lead without a Last Name (which should lead to an error for a required field missing).

 

My test:

 

static testMethod void testExceptionsConvertCloseNoLead() { 
  myGenHelpers gh = new myGenHelpers();
		
  Lead testLead = gh.getUptimeTestLead();
  insert testLead;
	            	
  testLead.LastName = null;
	            	
   myLeadConvertCloseExtension lcc = new myLeadConvertCloseExtension(new ApexPages.StandardController(testLead));
   lcc.save();
}

 

Last week, and still in production, this test passes successfully.  However, today, it fails.

 

The problem is in this code segment:

 

                try {
	                update this.myLead;
                } catch (DmlException e) {
                    for (Integer i = 0; i < e.getNumDml(); i++) {
				    	System.debug('myClass.save: error: ' + e.getDmlMessage(i));
                        this.myLead.addError(e.getDmlMessage(i)); 
                    }
                    return null;
                }

 

Instead the error being handled gracefully, the test just fails at the upsert.

 

Any thoughts?

Hey,

 

Just canvassing the community here for some feedback on Apex script performance.

 

We have been doing some pretty detailed analysis on our Apex code base to diagnose some performance issues with our application.  We were expecting to see the app getting hung up waiting for some SOQL query to execute.  Somewhat to our surprise, that turned out not to be the case; instead, we seem to be suffering from a 'death-by-a-thousand-cuts' scenario where most of the elapsed time is taken up by the execution of the Apex code itself.

 

Based on our debug logs, it looks like Apex script execution chugs along at a rate of roughly 10 statements per millisecond (seems to vary widely, anywhere between 5 and 15 per ms).  This is excluding all interaction with the database - strictly script execution.

 

Can anybody corroborate/refute this observation?  As it stands, we have web service methods in our application's back end that can execute anywhere between 10,000 and 100,000 script statements, depending on what is being asked for (and what the underlying data set size is).  Meaning, our application's FRONT end sits there for seconds on end waiting for its WS call to return.  Not a happy user experience.

 

Our position is, 10,000-100,000 executed statements in a method is peanuts, and 10 seconds is a long time to wait.  (Maybe this is a debatable point?) 

 

Any input from the community is most welcome!

 

Thanks

 

  • September 15, 2011
  • Like
  • 0

I'm puzzled

 

Running Eclipse Helios and Force.com IDE plug 20.0.1

 

  • On 2011-05-20, our Sandbox was on Spring 11.  If I used the IDE and did Run Tests on class Foo, I got a full debug log of the entire class execution in the Apex Test Runner view
  • On 2011-05-23, after our Sandbox was upgraded to Summer 11, running the exact same test in the IDE on class Foo yields a vastly truncated debug log in the Apex Test Runner view. The log is only about 130KB.

 

I know the code executes to completion because the same Run tests in the Force.com browser Apex Classes | Run Tests yields a debug log of 3300KB using the same log filters.

 

As far as I can tell, it is something about Summer 11 and how the Eclipse IDE version 20.0.1 obtains the debug log.

 

Any ideas greatly appreciated (I'm already filtering the log to LoggingLevel.INFO and thus avoiding the noise; but I need more than 130KB of debug log to analyze my execution).

 

 

Hey,

 

Hopefully someone out there can help me on this (and is alertly reading this dev board).

 

I have a Perl script that uses WWW::Salesforce to read data in from a SFDC org, do a whole bunch of transformation, and write data back in via upsert().  The structure and flow all seems fine, and all aspects of SFDC connectivity are functional.  EXCEPT when trying to write non-ASCII chars back to SF.  The use case is as follows:

 

1. Use 'query()' to pull a record from a custom Salesforce object.  The record's Name is 'Québec'.  Note the accented char, whose hex value appears to be 'c3a9' by the time it is pulled into my Perl script.

 

2. Assign this value to the Name field of a brand new record of another custom SF object, and use 'upsert()' to write this record to Salesforce.

 

This fails, with the following information in $result->envelope->{Body}->{upsertResponse}->{result}->{errors}:

 

errors->{fields} : Name

errors->{message} : <objLabel>: value not of required type: core.filemanager.ByteBlobValue@<hexNum>

errors->{statusCode} : INVALID_TYPE_ON_FIELD_IN_RECORD

 

I have tried encoding and decoding the field six ways to Sunday, using everything available in the Encode module (ascii, ascii-ctrl, iso-8859-1, null, utf-8-strict, utf-8), to no avail.  I even tried HTML::Entities and 'encode_entities()', but that changes the accented 'e' character to '&eacute;' which then gets passed verbatim to SF, which clearly I don't want (and should have expected).

 

My WWW::Salesforce module version is 0.12.

 

How can I get fields with characters like this into Salesforce from my Perl script?

 

Thanks.

 

 

 

  • January 06, 2011
  • Like
  • 0

Hi How do I get around this error message...

Collection size 1,609 exceeds maximum size of 1,000.

 

 

public String cname{get; set;} public List<SelectOption> getnames() { List<SelectOption> options = new List<SelectOption>(); List<Contact> namelist = new List<Contact>(); namelist = [Select Id, Name FROM Contact where Recordtype.name='Company' Order by LastName,FirstName]; options.add(new SelectOption('--None--','--None--')); for (Integer j=0;j<namelist.size();j++) { options.add(new SelectOption(namelist[j].Name,namelist[j].Name)); } return options; }

 

 

<td> <apex:outputlabel value="Company Names" for="cnamed" /> <apex:selectList value="{!cname}" size="1" id="cnamed"> <apex:actionSupport event="onchange" reRender="newvalue" /> <apex:selectOptions value="{!names}"/> </apex:selectList> </td>

 Thank you

 

 

OK, here's the thing:

 

We have a VF page consisting mostly of an <apex:tabPanel> containing several <apex:tab> components.  The contents of these tabs are somewhat complex and take a bit of time to build, so we don't want to ever re-render the tabPanel if we can help it.

 

Each tab contains controls that allow navigation away from this page (e.g. one contains a related list with the standard Edit/New controls). When we do so, and now we're on whatever other page, and we hit Save or Cancel, we are returned to our VF page as expected, and it is re-rendered at that time.  

 

Back on our VF page, though, we are now sitting on the page's default tab, as opposed to the tab we were on when we navigated away.  This is the problem I'm trying to solve.  I have envisioned the following approaches:

 

1) Inject the currently active tab (name or Id) into the current URL via a page parameter, whenever a tab is selected. 

 

I have not gotten this to work because I cannot modify the current URL without causing the whole page to re-render, and that is unacceptable because of load time.  I tried modifying the current URL both in the controller (via an actionFunction linked to the 'ontabenter' event of the tab - NOT by setting the tabPanel's 'switchType' attribute to 'ajax' or 'server', which also causes a page re-render), and via javascript, modifying 'window.location.search' directly, but neither allows me to sneak the parameter into the page without re-rendering it.  Which I suppose is to be expected.

 

2) Remember the currently active tab in a cookie.  Then, when the page is initialized (or re-initialized when we return to it), grab the cookie and use its value to set the active tab.  

 

If I could get the cookie value back into the controller as part of its initialization, then this would work easily, as I could then use it to set a controller property, and bind it to the tabPanel's 'value' attribute before the tabPanel gets rendered.  But I don't know of any way to do that.

 

Alternatively, I could conceivably use the cookie directly in Javascript to poke whatever information into the underlying HTML to 'spoof' a tab selection.  I did actually look into this, inspecting the HTML of a sample page, and I see style classes like 'dr-tbpnl-tbcell-inact' vs. 'dr-tbpnl-tbcell-act' that I could maybe toggle on the appropriate page components.  Or maybe there's some JS method that already exists, buried in main.js or somewhere, that could be leveraged?  Seems a little risky to me, reverse-engineering SF functionality - dodgy at best and non-forward-compatible at worst.

 

Anybody got any suggestions about this?  Remember, the key point here is to keep track of tab changes without re-rendering the tabPanel, in a way that survives navigating away from + back to the page.

 

Thanks!

 

  • January 28, 2010
  • Like
  • 0

Hey,

 

Couple of questions about merging Accounts, where there's one Master Acct and one or two 'victims':

  1. Clearly this causes an update to the Master and deletions to the victims.  Presumably these DML operations fire whatever Apex triggers are there.  Is there some field on the Account object that I can consult in an Update trigger, to tell me that this update was the result of a merge?  And - is there anything that gets set on a 'victim' Acct just before it's deleted, that a Delete trigger can consult to see that this deletion was the result of a merge - and to which Master Acct?
  2. The documentation says that all related lists of a 'victim' Acct are re-parented to the Master Acct.What about this operation - does it cause the Update triggers to fire on those related lists?  (I have a suspicion the answer is 'no'.)

Anyone out there know about this stuff?

 

Thanks!

  • November 18, 2009
  • Like
  • 0

Hello,

 

Just started using Apex today and I'm having trouble using List<sObject>. Here is my class:

 

 

public class Settings {

private List<sObject> info;

 

public Settings() {

info = [Select Id, API_Key__c, Password__c, Phone_No__c, Recording_Phone_Number__c, Time_Zone__c from Settings__c];

}

 

public String getKey() {

//String key = [SELECT API_Key__c FROM Settings__C].api_key__c;

String key = info.api_key__c;

return key;

}

}

 

The line commented out in the getKey method works fine. However, trying to use info.api_key__c gives me the following error:

 

   Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST:SObject at line 10 column 22

 

How can I access individual values in the info List object?

 

Thanks,

Dan 

 

 

Message Edited by DDay on 06-04-2009 01:12 PM
  • June 04, 2009
  • Like
  • 0

Hey, can you please help me with this one:

We have a visual force email template with OpportunityLineItems. If that email is sent from Opportunity tab (standard SF email function with 'select template') everything is working fine. What we now would like to have is a similar email template with a couple of Opportunity fields and Opportunity Product Line Items together with some Contract fields in it. This email will be sent from the Contract tab.

 

This new email template (Contract tab version) is working okay with reference to related Opportunity or Account information like this:

       <td><font face="Arial">
              Description: {!relatedTo.Opportunity__r.Description}<br/> 
              Currency: {!relatedTo.Opportunity__r.CurrencyIsoCode}<br/>                
            </font>
       </td>

 

What would be the right way to have OpportunityLineItems to that email template too? I thought that I would be able to add them via Opportunity__r relationship, but I didn't.

 

Any comments, advice... help?

Hey everyone,

I'm trying to build a tree component and am able to go down two levels but I'm not sure how (or if) it would be possible to continue adding levels.


I'm already building the above tree with the following code:
Controller:
public ProjectTask__c [] getTasks()
 {
  return [Select Id, Name, (Select Id, Name from Tasks__r)  from ProjectTask__c where Project__c = :projectId];
 }

 
VF Page:
<ul id ="tree" class="treeview">
 <apex:repeat value="{!tasks}" var="t">
  <li><span class = "file"><a href = "/{!t.id}">{!t.name}</a></span>
   <ul>
    <apex:repeat value="{!t.Tasks__r}" var="st">
     <li><span class = "file"><a href = "/{!st.Id}" />{!st.name}</a></span></li>
    </apex:repeat>
   </ul>
  </li>
 </apex:repeat>
</ul>

 If I have any items below 1.1 or 2.1, such as 1.1.1, 1.1.1.1, etc. what would be the best way to build a list of this nature?

Thanks,
Colin