• Jon Wilson
  • NEWBIE
  • 0 Points
  • Member since 2013

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

In previous logs, I got an EXCEPTION_THROWN entry when Apex executed a "throw" statement. This was as expected.

Now, I'm getting logs where there is an EXCEPTION_THROWN entry logged for a "throw" and every level of the call stack which unwinds due to that exception. The "unwinding" entries are copies of the original, so you can't easily identify them as duplicates.

When a log can contain several exceptions which are thrown and caught, this extra "noise" is most unwelcome as you can't tell where an exception originates without back-tracking through the log...

I have the following code:
public with sharing class getCustomvalues {

        public final Account account;
        public List<String> myitems {get; set;}
        public List<Custom_items__c> myResult {get;set;}
    
        public getCustomvalues() {
            Id id = ApexPages.currentPage().getParameters().get('id');
            account =  [SELECT Account.Name, items__c FROM Account WHERE Id = :id];
            myitems = new List<String>();
            if (account.items__c== null) {
                 myResult =null;  
                //System.debug(LoggingLevel.ERROR, 'result will be empty');
            } else {
                myitems.addAll(account.items__c.split(';'));
System.debug('myResult Query=select Name,Sn__c,Rn__c from Custom_items__c where Name in '+myitems+' order by Ordering_number__c');
                   myResult =[select Name,Sn__c,Rn__c from Custom_items__c where Name in :myitems order by Ordering_number__c];
            }
        }

        public Account getAccount() {
        
            return account;
        }
}
I wrote a test class that works good, but for some reason the myResult object stays empty.
Looking at the test logs I see that  (account.items__c== null) { is not true during the test, so it goes to the } else { section and there myitems is filled and contains data. 

One thing I noticed was that the debug log showed the following for the query
select Name,Sn__c,Rn__c from Custom_items__c where Name in (thevalue) order by Ordering_number__c
This looks wrong because it should be
select Name,Sn__c,Rn__c from Custom_items__c where Name in ('thevalue') order by Ordering_number__c
So instead of (thevalue) it should be ('thevalue') to be correct. 
On the other hand, the code works correct in the normal situations. 


 

Hi there,

 

I'm relatively new to Apex coding and have been looking for ways to do dynamic class instantiation.

 

In java I can write something like

 

String classToInstantiate = dao.getClassName();

AnInterface obj = (AnInterface) Class.forName(classToInstantiate).newInstance();

 

Is anyone aware of how I can do this or something similar in Apex? 

 

thanks in advance for any help you might be able to provide

Mark

 


 

I came across this post trying to find a solution to the same issue,
In my case i found that the popup was selecting the correct ID along the x axis but moving the position on the popup outside of the panel i wanted. So when i highlighted the linked item if it was say 800px on a scroller. It would move the popup to 800px outside the scroller.

This was the first issue I found. There were also ID issues along the X and Y for different commandLinks & when I reordered my page the popups would again be scrambled.

I worked out that the broken / buggy SalesForce code was within LookupHoverDetail.prototype.position. In here we were returning getObjX and getObjY wrongly.

So within my visualforce page I placed some overwriting code to replace the wrong possitions.

function getObjX(a) {
var left = 0; 
while(a){
left += (a.offsetLeft - a.scrollLeft + a.clientLeft);
a = a.offsetParent;
}
return left;
}
function getObjY(a) {
var top = 0; 
while(a){
top += (a.offsetTop - a.scrollTop + a.clientTop);
a = a.offsetParent;
}
return top;
}

 

Next I had to deal with the ID's being non-unique, I call this function after every Ajax event so that if I order the page, the Id's are to the correct links still.
This function will execute at the same time as the others on load.

function fixSalesforce() {
$FFDC('.lineItem A').each(function(index){
var me = $FFDC(this);
var aId = me.attr('id');
if (aId != null){
var trId = me.closest('tr').attr('id');
if (aId.indexOf(trId) != 0){
var newId = trId + aId;
me.attr('id', newId);
me.attr('onmouseover', me.attr('onmouseover').replace( new RegExp(aId, 'g' ), newId));
me.attr('onmouseout', me.attr('onmouseout').replace( new RegExp(aId, 'g' ), newId));
me.attr('onfocus', me.attr('onfocus').replace( new RegExp(aId, 'g' ), newId));
me.attr('onblur', me.attr('onblur').replace( new RegExp(aId, 'g' ), newId));
}
}
});
}

 

The aim of the above function is to make the ID's unique by prefixing them with the row ID which I put on the TR.

{
<apex:variable value="{!0}" var="tRow" /> 
<apex:repeat var="tl"value="{!viewState.BankStatement.TransactionLineItems}"id="tRow1"> 
<tr id="tRow{!tRow}" class="lineItem{!IF(tl.isChecked,'selected','')}">
<apex:variable var="tRow"value="{!tRow+1}"/>
}

 

Within all CommandLinks I then placed onComplete="Refresh();"

This is a function that will call the fixSalesforce() function from earlier.