• JaganC
  • NEWBIE
  • 0 Points
  • Member since 2013


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

As per then announcement at there https://help.salesforce.com/apex/HTViewSolution?id=000206493&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000206493&language=en_US) ,   the algorithm of certificate will be upgrade to SHA-256. 

I did test for my application with test the test endpoint https://sha2test.salesforce.com/services/Soap/u/32.0 and I got "(411)Length Required" error response. I'd like to confirm, is the SSL test passed?

Hi all,

Trying to allow users to create a case via sites on our intranet.  That isnt a problem, however I dont seem to be able to allow the user to create Attachments.

 

There's nothing in the user profile to allow access to Attachments that I can see but I'm getting Authorization errors when I try and insert an attachment.

 

Anyone know how I can do this?

 

Thanks

Steven

I've built a native application which needs Page Layout info.  You can't call describeLayout directly in Apex, so my workaround is to use a web service callout to call the SOAP API.  It works really well, BUT a few customers are unable to use the app because the call fails due to the describeLayout response being greater than the maximum response size that Apex can digest (3MB).

I have no idea why the response is so larger... the orgs in which I've investigated have a very reasonable number of fields, layouts, record types, etc.

So my questions for you experts:  What the heck is in this response that could be making it so large?  How can I work with the customer to somehow get the response size down?  Any recommendations?

I am having tons of issues starting starting eclipse.  It freezes when loading the com.salesforce.ide.core plugin.  I am running:

 

VMware workstation 8

SUSE 12.1 x64

Java 1.6.0_24 x64

 

My eclipse setting is:

 

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120522-1813
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-XX:PermSize=128m
-Xms40m
-XX:MaxPermSize=1024m
-Xmx1924m
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard

 

I am able to start up fine when I move my workspace/.metadata file and it locks up again when I move it back.

 

Can anyone assist?

 

Thank you

I have an apex component in which the constructor in the controller is exectuting twice. I have made all the pages and classes as simple as possible to reproduce and this is what we have:

 

The Page

<apex:page >	
    <c:myComponent />
</apex:page>

 

The Component

<apex:component controller="MyController" >
    <apex:form >
        <apex:actionFunction name="thisIsMyName" action="{!doSomething}"  />	
    </apex:form>
</apex:component>

 

The Controller

public class MyController {
	
    //Constructor
    public MyController(){
        system.debug('I am a constructor and I am executing multiple times to drive you crazy.');
    }
    
    public void doSomething(){
    	//Blah blah blah
    }

}

 

The Debug Log

23.0 APEX_CODE,DEBUG
18:56:46.028 (28871000)|EXECUTION_STARTED
18:56:46.028 (28903000)|CODE_UNIT_STARTED|[EXTERNAL]|066500000008tEE|VF: /apex/mypage
18:56:46.039 (39198000)|CODE_UNIT_STARTED|[EXTERNAL]|01p50000000DYoB|MyController <init>
18:56:46.039 (39850000)|METHOD_ENTRY|[1]|01p50000000DYoB|MyController.MyController()
18:56:46.039 (39939000)|METHOD_EXIT|[1]|MyController
18:56:46.041 (41245000)|USER_DEBUG|[5]|DEBUG|I am a constructor and I am executing multiple times to drive you crazy.
18:56:46.041 (41308000)|CODE_UNIT_FINISHED|MyController <init>
18:56:46.041 (41830000)|CODE_UNIT_STARTED|[EXTERNAL]|01p50000000DYoB|MyController <init>
18:56:46.041 (41872000)|USER_DEBUG|[5]|DEBUG|I am a constructor and I am executing multiple times to drive you crazy.
18:56:46.041 (41894000)|CODE_UNIT_FINISHED|MyController <init>
18:56:46.071 (71248000)|CODE_UNIT_FINISHED|VF: /apex/mypage
18:56:46.071 (71263000)|EXECUTION_FINISHED

Any ideas why this is happening. It is making me go a little crazy.

 

If I move everything that is in the component directly to the page it will only execute once, as expected, but I need use components.

 

Thanks,

Jason

  • April 29, 2012
  • Like
  • 1

I see this question come up often and after having to fight with it again today, I thought I would post a quick quick with tips and tricks:

 

 

What you think should work

 

<apex:commandButton action="{!someAtion}" value="Click Me">
     <apex:param assignTo="{!conVariable}" name="con" id="con" value="123"/>
</apex:commandButton>

 Well, let me tell you, this DOES NOT work.

 

  - Why - A little bug with the command button and param. Commandlink works, but the command button requires something more to get it to set the value of the controller variable.

 

How to fix it

 

 1. Create a hidden output panel on the page, and simply rerender it. This will cause the command button to set the controller vairable as expected.

 

<apex:outputPanel id="hidden" rendered="false"/>

<apex:commandButton action="{!someAtion}" value="Click Me" reRender="hidden">
     <apex:param assignTo="{!conVariable}" name="con" id="con" value="123"/>
</apex:commandButton>

 

Calling Javascript with the button and setting the variable, what you think would work

 

<apex:commandButton onclick="someFunction();" value="Click Me" rerender="hidden">
     <apex:param assignTo="{!conVariable}" name="con" id="con" value="123" />
</apex:commandButton>

 

     Well this does not work either - You need BOTH the action and rerender to be present. Well shucks, I do not want to call the controller, I want to call a jave method....

 

How to make it work

 

1. Add a method to your extenstion / controller

 

public void doNothing(){

   //Do absolutely nothing

}

 2. Modify the button as follows:

 

<apex:commandButton action="{!doNothing}" onclick="someFunction();" value="Click Me" rerender="hidden">
     <apex:param assignTo="{!conVariable}" name="con" id="con" value="123"/>
</apex:commandButton>

 

Bam. The controller variable is set as expected.

 

Why would you use this? Well here was my flow:

 

1. On click of a button I needed to set the value of a controller variable which will be used in a query

2. Before the actual method in the controller ran, I needed to run some java to manipulate the DOM

3. After the method ran, I needed to check the results

 

1: Button -> doNothing -> call Java Function

2. Java Function DOM Stuff -> ActionFunction

3. ActionFunction -> Run Controller method -> onComplete -> Java Function passin in result variable from controller

4. Java Function More DOM Manipulation or Action Function stuff based on result.

 

Hope this helps someone


Hi, 

I have a commandLink on click of which I want to ask the user for confirmation first i.e. whether he is sure to take the action. Once the user says Yes and the action is completed, I want a alert saying that the action was completed successfully. In order to achieve this, I used the onclick and oncomplete attributes of CommandLink. My issue is that if I use both the attributes, my commandLink action never gets fired. If I use only one of the them, everything works fine except I have only one of the popups. 


Is there an issue when both the onclick and oncomplete attribute are used together? Following is a sample code:

 

<apex:commandLink value="Test" action="{!myAction}" onclick="return window.confirm('Are you sure?');" oncomplete="alert('Event Completed');" />

 

 

I am not sure what I am doing wrong with my savepoint.  It seems no matter where I put it, the cloned opportunity still saves despite the user clicking cancel.  Is there something else that I am missing?  Should I have a custom cancel method in my VF page? 

<apex:page standardController="Opportunity" extensions="OppCloneController" 
    action="{!cloneWithItems}">  
    <apex:pageMessages />  

</apex:page>

 

 

 

Thanks!

Pat

 

 

public class OppCloneController {  


    private ApexPages.StandardController controller {get; set;}  

    public Opportunity opp {get;set;} 
    public List<OpportunityLineItem> items = new List<OpportunityLineItem>();
    Schema.DescribeSObjectResult R = Opportunity.SObjectType.getDescribe();
    List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();
    

    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS  

    public ID newRecordId {get;set;}  

     // initialize the controller  

    public OppCloneController(ApexPages.StandardController controller) {  

     //initialize the standard controller  

      this.controller = controller;  

    // load the current record  

         opp = (Opportunity)controller.getRecord(); 
          


     }  

    // setup the save point for rollback  
    
        Savepoint sp = Database.setSavepoint();
        
    // method called from the VF's action attribute to clone the opp 

    public PageReference cloneWithItems() {  



        Opportunity newOP;  


         try {  


          //copy the opportunity - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE  

             opp = [select Id, Name, Account.Name, AccountID, StageName, CloseDate, OwnerID, Type_of_Job__c, 
             Invoice_Requirements__c, Customer_Account__c, Contact_Name__c, Customer_E_mail__c, RecordTypeID,
             Phone__c, fax__c, Pricebook2Id
             from Opportunity where id = :opp.id]; 
             
 
             newOP = opp.clone(false);  
           //check to see if the opportunity name contains DTV or DirecTV, if so apply the appropriate record type,
           //otherwise use standard record type
                          
                    
   
                      // VALUE MAPPING 

            newOp.Name = opp.Name;
            newOp.Account.Name = opp.Account.Name;     
            newOp.AccountId = opp.AccountId;
            newOp.CloseDate = opp.CloseDate;
            newOp.StageName = 'New Work Order';
            newOp.OwnerID = opp.OwnerID;
            newOp.Type_of_Job__c = opp.Type_of_Job__c;
            newOp.Invoice_Requirements__c = opp.Invoice_Requirements__c;
            newOp.Customer_Account__c = opp.Customer_Account__c;
             newOp.RecordTypeId = opp.RecordTypeId;      
            newOp.Contact_Name__c = opp.Contact_Name__c;
            newOp.Customer_E_mail__c = opp.Customer_E_mail__c;
            newOp.Phone__c = opp.Phone__c;
            newOp.fax__c = opp.fax__c;
            newOp.Pricebook2Id = opp.Pricebook2Id;
            
             If (newOp.Name.contains('DirecTV'))
            newOp.RecordTypeId = [Select Id From RecordType RT Where RT.Name='DTV New Standard' limit 1].Id;
  
            else if (newOp.Name.contains('DTV'))
            newOp.RecordTypeId = [Select Id From RecordType RT Where RT.Name='DTV New Standard' limit 1].Id;
             else 
                newOp.RecordTypeID = [Select ID From RecordType r Where r.Name='New Standard' limit 1].ID;
                
                   insert newOP;  

             // set the id of the new opp created for testing  

              newRecordId = newOP.id;  
 



  // copy over the line items - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE 
               
               for(OpportunityLineItem oli : [Select ID, OpportunityID,  
               UnitPrice, Quantity, PricebookEntryID
               
               from OpportunityLineItem oliList where OpportunityID = :opp.id]
               )
           

               {
               OpportunityLineItem newOli = new OpportunityLineItem();
                   newOli.PricebookEntryID = oli.PricebookEntryID;
                   newOli.Quantity = oli.Quantity;
                   newOli.UnitPrice = oli.UnitPrice;
                   newOlI.OpportunityID=newOP.id;
              
                   items.add(newOli);
                   } //end loop
                   
                   insert items;
           
         } catch (Exception e){  

              // roll everything back in case of error  

             Database.rollback(sp);  
             ApexPages.addMessages(e);
             opp = opp.clone(false);
  
             return null;  

         }  
         
    

         return new PageReference('/'+newOp.id+'/e?retURL=%2F'+newOp.id);  

     }  

    

 }

 

 

will a custom component controller 's constructor get called even if the "Rendered" expression evaluates to "false"? Below is a visual force page that has two components. Only one of them is rendered depending on the user's Profile name:

 

<apex:page showHeader="true" sidebar="false" controller="SiteHeaderController" action="{!init}">
<apex:form >
User Profile:{!userProfile}<br/>
<apex:outputText value="SL Component" rendered="{!userProfile='Leader'}"/><br/>
<apex:outputText value="ZoneDiv Component" rendered="{!OR(userProfile='Division Manager',userProfile='Zone Manager')}"/><br/>
<apex:commandLink value="{!$Label.Earning_Opportunity}" action="{!showEarningOpportunity}" rerender="earningOpportunity" rendered="{!userProfile='Leader'}"/>
<apex:outputPanel id="earningOpportunity">
   	<apex:outputPanel rendered="{!showEarningOppty}">
    	<c:SalesLeaderEarningOpportunity rendered="{!userProfile='Leader'}"/>
    	<c:ZoneDivEarningOpportunity rendered="{!OR(userProfile='Division Manager',userProfile='Avon Zone Manager')}"/>
   	</apex:outputPanel>
</apex:outputPanel>                
</apex:form>

</apex:page>

 

ShowEarningOpportunity method is below:

 

public PageReference showEarningOpportunity(){
	this.showEarningOppty=true;
	return null;
}

 

 

When I executed the page and click on the "command link", both constructors are getting called. Am I missing something?

 

Good day,

 

Can i know if Apex:Repeat tag's value able hold Map instead of List ?

 

 

VF page
------------
<apex:repeat value="{!partnerFieldList}" var="field">

<apex:variable var="currentLabel" value="{!$Label.first_name}" rendered="{field.containsKey('First_Name__c')}"/>


Controller
-----------
public Map<String,Boolean> partnerFieldList = new Map<String,Boolean>{
'First_Name__c' => TRUE

};

 

public Map<String,Boolean> getPartnerFieldList(){
return partnerFieldList;

 

 

 I would like to rendered the 'firstname' variable if the field are calling, but i get "Unsupported type common.apex.runtime.impl.MapValue encountered."error when i run the apex page

 

Thank you !

 

  • November 10, 2009
  • Like
  • 1

I have a non-sobject field called "InvoiceDates" in my controller extension. On the VF page there is both an InputTextarea and an outputtext for the same field. The idea is the inputtextarea is pre-populated, but editable by the user. When the user updates that field and clicks a refresh button, they can see a "preview" of the document that will be created.

 

So far things work great for the inputtext area. I placed \n in the string which provides my line breaks. However when I go to output the value it shows up on a single line.

 

Part of method defining string

string vDate = string.valueof(StartDate.Month() +'/'+ StartDate.Day()+'/'+ StartDate.Year()); String Term = 'Term ' + string.valueof(i+2) + ': '; InvoiceDates = InvoiceDates + Term + Vdate + '\n';

VF Page area

 

(this works)

<apex:inputtextarea value="{!InvoiceDates}" id="InvoiceDates" style="width:300px;height:150px"/>

(Output not displaying with line breaks) <apex:outputtext value="{!InvoiceDates}" /> (Also tried) {!InvoiceDates}

 

the component references says outputtext "escape the rendered text if it contains sensitive HTML and XML characters" I'm assuming that using outputtext would "strip" my \n, so I tried just placing the string without an outputtext - but get the same data string line.

 

The only way I have been able to work around this is to create a list<string> instead of a concatenated String. This works on the display, but doesn't work for the user Inputtextarea well. Any suggestions on how I can get my output to include the \n ?

I am running into an issue in Apex outbound email. If I have an email message that is using a template, and that I am sending to a User (via setTargetObjectId), Apex won't let me set WhatId -- if I do, it gives me this error message

"System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds."

Is there any easy way around this limitation? Obviously via workflow rules I am able to send emails to users that have a "What" context sent (for instance, send an email to Opportunity owner when stage change X occurs). Seems like a big limitation of the Apex email service to not allow this.

For now, I am intending to set up temporary Contact objects for Users who do not have them, just so I can send them email.

Here is the code that is hitting this error. "UserId" is the ID of a User object and "WhatId" is the ID of an Opportunity.

Code:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
EmailTemplate template = [select Id from EmailTemplate where DeveloperName = :emailTemplateUniqueName];
mail.setTemplateId(template.Id);
mail.setReplyTo('no-reply@mycompany.com');
mail.setSenderDisplayName('Salesforce');
mail.setTargetObjectId(userId);
mail.setWhatId(whatId);
mail.setSaveAsActivity(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 
Any pointers much appreciated. If (as I suspect) this is just a straight Apex issue and cannot be done, I'll open an Idea to fix it.

Jeremy Kraybill
Austin, TX
Let's say I have an unpackaged page that wants to point at a packaged page via a standard <a> tag:

Code:
<a href="/apex/i__packagedPage">Go from unpackaged to packaged</a>

 
That works fine, as "https://na1.salesforce.com/apex/i__packagedPage" redirects to "https://i.na1.visual.force.com/apex/packagedPage".


However, I cannot do the reverse.  If I'm on a packaged page, this:

Code:
<a href="/apex/unpackagedPage">Go from packaged to unpackaged</a>

 
Does not work, because "https://i.na1.visual.force.com/apex/unpackagedPage" does not redirect back to the unpackaged domain; instead the sub-domain host just throws an error.


An understandable workaround would be if you had to use a controller method get the right URL by using a PageReference:

Code:
// packaged page:
<a href="{!unpackagedUrl}">Go from packaged to unpackaged</a>

// packaged controller:
public string getUnpackagedUrl() {
  PageReference p = new PageReference('/apex/unpackagedPage');
  return p.getUrl();
  }


But that doesn't work either - the code above generates the same relative URL, just like our HREF example above (ie, PageReference doesn't have any additional domain smarts).


So whatever is generating these URLs from the https://i.na1.visual.force.com" domain has to know that "https://na1.salesforce.com" is the appropriate unpackaged domain for the current user.

On the client side, this could be done via javascript.


But - I need to do this on the *server* side, because the actual use case is redirecting from a packaged page to an unpackaged version of that page (in order to support client customizations of our packaged UI):

Code:
// page:
<apex:page controller="PackagedController" action="{!checkForUnpackagedOverride}">


// controller:
public PageReference checkForUnpackagedOverride() {
  ApexPage[] override = [select Name from ApexPage where ...];
  if (p.size() == 0) return null;
PageReference p = new PageReference('/apex/' + override[0].Name); p.setRedirect(true); return p; }

 
But this doesn't work.  What can I do on the server side to figure out my salesforce instance URL?

I'll post what I find, if anything.
  • December 15, 2008
  • Like
  • 1