• TaoDuh
  • NEWBIE
  • 20 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 14
    Replies

In my site code I have a bunch methods that look like this (with some extra error checking):

public SomeObj__c myobj {
  get {
    if (myobj == null) {
      myobj = [SELECT Id, ... FROM SomeObj__c WHERE Id = :Id LIMIT 1];
    }
  return myobj;
}
private set;
}


I understand the above to be a good practice.  However I'm running into a caching dilemma when it comes to sites and the key issue is the line... if (myobj == null)

The above is in an abstract base class which is extended by both the display and the admin controllers.  In the admin pages, everything works great.  My save methods all save properly and the expected values are displayed on the page.  Subsequent views of the corresponding page on the site also display the proper data.  Nice.

However, the issue occurs when the data editor edits a page and wants to see his changes. Imagine this scenario.
1) editor goes to admin page salesforce.com/apex/EditMyStuff?id=12345 <http://salesforce.com/apex/EditMyStuff?id=12345>  and makes changes
2) editor then goes to see changes at the site mysite.force.com/ViewMyStuff?id=12345 <http://mysite.force.com/ViewMyStuff?id=12345>  -- looks almost perfect
3) go back to admin page and make another change
4) refresh site...oops, no change.  Because the controller value is not null it does not re-retrieve

I can think of two solutions here.
#1 Completely separate the controllers for the public/private sides.  Leave out the if (myobj == null) lines on the public side and just have it retrieve every single time.
PROS: works as users expect
CONS: duplication of code, inefficient database utilization for most common use case

#2 Add a method to clear out all of the instance variables. Add a "Preview" button to the admin pages and train users to look there for changes rather than live site
PROS: keeps the efficiencies
CONS: training/support cost (our users are not very savvy)

Am I overlooking some 3rd way?  A better pattern perhaps?  Someone else out there must have a site with this problem.

Hi everyone,

 

We have a custom lookup to contact on our opportunity object.  The users would like the email on that contact to be the default value when the user clicks "Send An Email" on the opportunity.  Following is what I've tried/thought about.

 

1) Add a visualforce chunk to the task layout that copies the value to the "To" box.  I'm not sure that's possible, I haven't tried reaching outside the boundries of my visualforce page before.  But even if It were, when I add a visualforce chunk to the layout it a) does not appear on the screen for new tasks, just existing tasks and b) does not appear on the send an email page at all

 

2) Rewrite the whole "Send An Email" page in Visualforce and have the button go there.  Besides seeming like a pain and a wasted duplication of effort, I imagine I will at the least lose the spell check functionality.  I will no doubt get complaints about that.

 

Am I missing an easier way in my tiredness?

  • April 08, 2010
  • Like
  • 0

Nothing serious here, I just wondered if anyone knows what is going on.

 

I get this email every time I deploy from Eclipse. (Or validate a deployment.)

 

Nothing actually gets changed.

 

  • November 24, 2009
  • Like
  • 0

I have a VF page with the following line

    <apex:outputText value="{!idea.body}" escape="false" />

 

On my sandbox, the tags are not escaped and I get formatted text as I would expect.  However, the same code on production results in output like this:

    <strong>bold</strong><br />
    <em>ital</em><br />
    <u>underline</u><br />
    <strike>strike</strike><br />

 

I can see that in the database the idea body content is stored identically in the sandbox and production.  So the problem occurs during the display part of the process.

 

Oddly enough this problem is not plaguing me on some pages.  I haven't figured out the difference yet though.  I will keep looking.

 

If anyone has a good guess to spur my thoughts, please post it!

Thanks!

  • October 22, 2009
  • Like
  • 0
I have a Class and a Trigger:

public class TempSetEventName {
    public void subjectMutation(Event[] evts){
        for (Event e:evts){
            if (e.Subject == 'Todd') e.Subject = 'Should upd oppt ' + e.WhatId;
        }
    }
}

---

trigger opportunityStatusUpdate on Event (before insert) {
    TempSetEventName en = new TempSetEventName();
    en.subjectMutation(Trigger.new);
}

I get an "Invalid type: TempSetEventName" on the first code line of the trigger.  Changing the method to static and attempting static access has the same result.

My project has a Namespace prefix (VistageApexTest).  I tried prepending that to no avail.

Can anyone tell what I am missing?
  • January 11, 2008
  • Like
  • 0
I have created a custom field on the Lead object called LegacyId.

This query works fine (Java code):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website", "Lead", new String[] {id});

But this one, not so well (error is down at the bottom):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website, LegacyId__c", "Lead", new String[] {id});

Obviously, trying to figure out why.

Oddly, it used to work until I changed the label on my custom field.  I have since deleted it and created a new one but I'm still stuck with my error.  Note that if I do a describeSObject("Lead") I do see my field name.

When it was working, I was trying to figure out how to get the value out of my result set.  Obviously, there was no method called lead.getLegacyId__c().  I tried to get it via reflection but that didn't work either.  (No surprise there)  But I couldn't find another way.  While I'm asking questions I thought I'd throw that in there.


The error:
[ERROR] Exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
    at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.sforce.soap.enterprise.SoapBindingStub.retrieve(SoapBindingStub.java:3309)
    at com.vistage.salesforce.ToddTest.retrieveLead(ToddTest.java:92)
    at com.vistage.salesforce.ToddTest.findRecentUpdates(ToddTest.java:58)
    at com.vistage.salesforce.ToddTest.sfTests(ToddTest.java:38)
    at com.vistage.salesforce.ToddTest.<init>(ToddTest.java:27)
    at com.vistage.salesforce.ToddTest.main(ToddTest.java:212)
An unexpected error has occurred.; nested exception is:
    org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
  • November 12, 2007
  • Like
  • 0

I tried to log in tonight several times with several browsers.  Each time it asked me to create a new profile/name.  (I used to be taoduh.)

 

Not a huge loss but I would have used the links of my recent posts if I had new answers to post to my own problems.

Hi everyone,

 

We have a custom lookup to contact on our opportunity object.  The users would like the email on that contact to be the default value when the user clicks "Send An Email" on the opportunity.  Following is what I've tried/thought about.

 

1) Add a visualforce chunk to the task layout that copies the value to the "To" box.  I'm not sure that's possible, I haven't tried reaching outside the boundries of my visualforce page before.  But even if It were, when I add a visualforce chunk to the layout it a) does not appear on the screen for new tasks, just existing tasks and b) does not appear on the send an email page at all

 

2) Rewrite the whole "Send An Email" page in Visualforce and have the button go there.  Besides seeming like a pain and a wasted duplication of effort, I imagine I will at the least lose the spell check functionality.  I will no doubt get complaints about that.

 

Am I missing an easier way in my tiredness?

  • April 08, 2010
  • Like
  • 0

I have a VF page with the following line

    <apex:outputText value="{!idea.body}" escape="false" />

 

On my sandbox, the tags are not escaped and I get formatted text as I would expect.  However, the same code on production results in output like this:

    <strong>bold</strong><br />
    <em>ital</em><br />
    <u>underline</u><br />
    <strike>strike</strike><br />

 

I can see that in the database the idea body content is stored identically in the sandbox and production.  So the problem occurs during the display part of the process.

 

Oddly enough this problem is not plaguing me on some pages.  I haven't figured out the difference yet though.  I will keep looking.

 

If anyone has a good guess to spur my thoughts, please post it!

Thanks!

  • October 22, 2009
  • Like
  • 0

Howdy everyone,

 

Well, I'm a bit stumped. I'm trying to test a web-to-lead form where I preset the record type:

 

 

<input type="hidden" id="recordType" name="recordType" value="012Q00000008ULW">

 

I have the "keep the existing record type" option set under Lead Settings and it is still not working. 

 

Everything else is populating correctly on the lead record in SFDC. 

 

Thoughts?

 

Thanks, 

 

Hey guys,

 

needed a way to convert from a 15 digit ID to an 18 digit one.

Found the javascript version for just such an action here: http://community.salesforce.com/sforce/board/message?board.id=general_development&message.id=13148

 

tried to make my own apex version but the last digit keeps coming out wrong.  Any Ideas?

 

Thank's

 

 

 

String id = '001Q0000002NXad'; //a sample id

 

String suffix = '';

for(integer i=0;i<3;i++){

Integer flags = 0;

for(integer j=0;j<5;j++){
String c = id.substring(i*5+j,i*5+j+1);

if(c >= 'A' && c <='Z'){

flags += 1 << j;
}
}

if (flags <= 25) {

suffix += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.substring(flags,flags+1);

}else suffix += '012345'.substring(flags-26,flags-26+1);
}

System.debug('15-DIGIT:'+Id);
System.debug('18-DIGIT:'+Id + suffix);

 

 

 

Message Edited by astro on 05-01-2009 10:04 PM
Message Edited by astro on 05-01-2009 10:10 PM
  • May 01, 2009
  • Like
  • 0

Hi All,

 

 Can anyone please help me out about this error.

 I am enabling the NewUser feature in my site. And while registering I am getting this error.I am also recieving

       One Email by saying that  "accountId parameter value is not valid "


 

 

 

 

Message Edited by Brijesh_85 on 02-26-2009 03:58 AM
Hi. I tried to 'disable' the default Attachment function of SFDC with the following trigger:
 
Code:
trigger AttachmentDisabler on Attachment (before insert) {
 List<Attachment> atts = Trigger.new;
 for(Attachment a:atts) {
  a.addError('Please use the "Attach(FTP)" button on top of the detail page to attach a file.'); 
 }
}

 
But this does not seem to work. Did I do something wrong or is it impossible this way? Even the debug did not show anything, the trigger does not seem to do anything. Any other ways to disable the normal Attach function of SFDC without removing the entire related list? (want to keep notes function)
I am trying to understand if the "Without sharing" keyword will allow me do accomplish something I am trying to do with a VF page with a custom controller.
What my goal is, is to send a link to a base user that includes a link to my custom VF page, and include an id to an object that they would not normally have visibility to, for example, opportunities.
 
According to Premier support, "without sharing" executes under the System User, ignoring all CRUD, field level and row-level security. 
 
This would seem to do what I am trying to do.  However, I get an insufficient privileges error when a base user tries to access the page with an object id that they don't normally have access to.
 
Is this NOT with the "with sharing" or "without sharing" mean?  If it isn't, what is the purpose of these keywords and how are they used?
 
Regards,
Jim
  • October 20, 2008
  • Like
  • 0
I have created a custom field on the Lead object called LegacyId.

This query works fine (Java code):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website", "Lead", new String[] {id});

But this one, not so well (error is down at the bottom):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website, LegacyId__c", "Lead", new String[] {id});

Obviously, trying to figure out why.

Oddly, it used to work until I changed the label on my custom field.  I have since deleted it and created a new one but I'm still stuck with my error.  Note that if I do a describeSObject("Lead") I do see my field name.

When it was working, I was trying to figure out how to get the value out of my result set.  Obviously, there was no method called lead.getLegacyId__c().  I tried to get it via reflection but that didn't work either.  (No surprise there)  But I couldn't find another way.  While I'm asking questions I thought I'd throw that in there.


The error:
[ERROR] Exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
    at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.sforce.soap.enterprise.SoapBindingStub.retrieve(SoapBindingStub.java:3309)
    at com.vistage.salesforce.ToddTest.retrieveLead(ToddTest.java:92)
    at com.vistage.salesforce.ToddTest.findRecentUpdates(ToddTest.java:58)
    at com.vistage.salesforce.ToddTest.sfTests(ToddTest.java:38)
    at com.vistage.salesforce.ToddTest.<init>(ToddTest.java:27)
    at com.vistage.salesforce.ToddTest.main(ToddTest.java:212)
An unexpected error has occurred.; nested exception is:
    org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
  • November 12, 2007
  • Like
  • 0