• thoban2
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Does anyone know how to get the hostname in an Apex Batch class?

 

Note that the following does not work (null pointer exception) because the process is not associated with a Visual Force page:

 

     ApexPages.currentPage().getHeaders().get('Host');

 

My use case:

 

      My batch program sends emails that display images that I've stored as static resources.  The email module utilizes VF Email Template.

Below is an example provided in the Apex manual that shows a custom iterator.  There is a line that I find confusing found in the method called "next()":

 

         if(i == 8){ i++; return null;}

 

Does anyone know what this is for?  I am inclined to dismiss it.  However, maybe there is something that I don't understand about the "iterable" and "iterator" interfaces.

 

If anyone has insights, please let me know.

 

Thanks

 

 

 

 

 

 

global class CustomIterable implements Iterator<Account>{
List<Account> accs {get; set;}
Integer i {get; set;}
public CustomIterable(){
accs = [SELECT id, name, numberofEmployees FROM Account WHERE name = 'false'];
i = 0;
}
global boolean hasNext(){
if(i >= accs.size())
return false;
else
return true;
}
global Account next(){
if(i == 8){ i++; return null;}
i=i+1;
return accs[i-1];
}
}

I have a formula field that that works fine in test, but when I generate the managed package, the references to namespace are not properly embedded into the formula.  Further, when I view the formula field is see the word "disable" at the end of the formula definition:

 

IF( ISNULL(ExpectedPaymentDate__c) ,
IF($Setup.forseva2__ForsevaPreferences__c.forseva2__Forcasted_Payment_Date_Method__c="AverageDaysDelinquent",
Invoice_Due_Date__c + ceiling(Account__r.Average_Days_Delinquent__c),
Invoice_Date__c + ceiling(Account__r.Average_Days_To_Pay__c)
) ,
ExpectedPaymentDate__c
)[disable]

 

Note that the formula references a custom setting (called ForsevaPreferences__c) .  The custom setting is properly prefixed with the namepace( "forseva2").  However,  the custom fields used within the formula do not have the prefix.

 

Note that other formula fields that we have defined properly prefix everything with the namespace.  They are different in that they do not reference a custom setting.  Can anyone tell me why this is happening?

 

Thanks,

Tom

Does anyone know if the DOM Classes (Dom.Document and Dom.XmlNode) support the ![CDATA[]] construct.

 

It appears that if I include a node in an xml document with CDATA text, navigate to the node and then call getText() on it, it returns the raw entry with the full "!CDATA[.....]]".  Even worse, if the CDATA block includes "<" or ">" Dom.XmlNode.load() throws a parse exception.  Is there a way to make this work?

 

Thanks,

Tom 

I have a java/Axix 1.4 program that calls a Apex class with a webservice method. 

 

I was getting this error:

 

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key:

 

My program closely follows the Java/Axis 1.4 example provided by SalesForce.  the Basic steps I followed were:

1) Using IDE, created class with a WebService method.

2) Exported WSDL on Salesforce.

3) Wrote java program, generated stubs and built program following example.

 

My problem was caused by the mistake I made in step 1.  By default, the class is created with apiVersion set to 16.0.  It seems, it needs to be 17.0 for everything to work.

 

Fix:

1) changed apiVersion to 17.0 for the class.

2) export wsdl

3) regen stubs and rebuild client application.

Works!

 

Note, that as I write this, we are currently on the Winter 10 release.  I believe SF is providing a new IDE with the Spring 10 release.  Hopefully, it picks the correct apiVersion by default.

 

Hope this helps anyone else who encounters this same problem. 

 

Does anyone know if the DOM Classes (Dom.Document and Dom.XmlNode) support the ![CDATA[]] construct.

 

It appears that if I include a node in an xml document with CDATA text, navigate to the node and then call getText() on it, it returns the raw entry with the full "!CDATA[.....]]".  Even worse, if the CDATA block includes "<" or ">" Dom.XmlNode.load() throws a parse exception.  Is there a way to make this work?

 

Thanks,

Tom 

Hi,

 

I have created some batch apex code alongwith other triggers and class/controller codes. 

 

When I run individual test methods on them, I am able to get test success result alongwith nice code coverage %. However when I run all tests together, I get following test failure errors:-

 

1)System.AsyncException: Database.executeBatch cannot be called from a batch or future method.

2)System.AsyncException: Future method cannot be called from a future method: changeOwners(String, String)

3)System.AsyncException: Future method cannot be called from a future method: getLead_Rollup_Amount(Id)

4)System.AsyncException: Future method cannot be called from a future method: changeOwners(String, String)

 

Please note again that the exceptions dont come when tested individually.

 

Please advise on same.

 

 

Thanks,

 

Vimal 

Hi,

 

If I create a custom component, is there any way to update a value on the parent controller? Let's say as a parameter passed into the custom component, I gave a value like {!value}. Can the controller behind the custom component modify that variable that's on the main page's custom controller? In java you might do this with a shared bean or session variable. What about in apex?

 

I have several VF tabs on my page. Each tab is a different business function. I end up re-using code on multiple VF pages so it would be great to make each tab a component so I can re-use thm elsewhere.  Right now it's monolithic. But a link on one tab may cause the VF page to jump you to another tab and use a commandlink parameter.

 

So if we were to break this up into custom components, we would need to somehow pass data between them. Is that possible somehow? It looks like variables only flow one way or maybe we just don't know how to do it?

 

Any thoughts?

 

Thank you,

DSL

  • April 12, 2009
  • Like
  • 0

Hi all,

 

I think the answer is no, but I'll ask anyway.

 

Is it possible to attach a visualforce page rendered as pdf that uses a custom controller, in a visualforce email template?

 

I saw a post that describes using a component, but I already have the page and the controller built...it seems that it shouldn't take much to make that available as an attachment in an email template. It's kind of silly to have to duplicate things.

 

Are there any workarounds?

 

Thanks,

 

--Alex