• AkiT
  • NEWBIE
  • 215 Points
  • Member since 2007
  • Head of Technology
  • Fluido

  • Chatter
    Feed
  • 7
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 86
    Replies

Im trying to create a simple trigger that writes out the UserId and Date (of the user triggering the trigger) to 2 custom fields.

 

Firstly is it possible to write out the user of the person triggering the trigger?

 

Secondly would something like this work? Trying to get it to trigger when the SS gets changed to 2 - Contact Made. I apologize for my shoddy coding, still learning! :)

 

trigger userForSS2 on Account (after update) { 

 

if(Trigger.isUpdate & myAccount.Sales_Stage__c == '2 - Contact Made'){ myAccount.SQL_User__c = UserInfo.getUserId(); myAccount.SQL_Date__c = date.Today();

}

}

 

 

 

Any help would be great!

Michael 

 

Hi,
in the Winter'09 release notes it says "Custom labels are custom text values, up to 1,000 characters in length, that can be accessed from Apex classes or Visualforce pages".
I could easily find how to access these labels from a visualforce page, but nowhere I can find how to access them from an apex class.
I need this because I have a class that dynamically generates labels for a certain table in a vf page. But I want to use Custom Labels (and the translation workbench) to get these translated in various languages.
Is there an object, something like Label with a static function like 'getLabel(String)'? Or is this not released in Winter '09?
  • September 30, 2008
  • Like
  • 0
Hi mates,
I got problems when sending emails, the code like following:
 
  Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
  mail.setTemplateId(emailTemplateId);
  mail.setTargetObjectId(myContactId);
  mail.setWhatId(customObjectId);
  Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
The problem is on customObjectId, i know the whatId can be set to some standard object and the custom objects. But there are some custom objects cannot set to whatId. For example, i got a RFQ object, its fields are almost the same with another Schedule object. When setting the RFQ id, it works fine. When setting the Schedule id, i got a exception like following:
 
System.EmailException: SendEmail failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Opportunity/Account ID: id value of incorrect type: a0070000009w4JMAAY: [WhatId]
 
So, is there a restriction of which custom object can be bound to the whatId field.
 
Thanks very much
Kevin
S-Control:
var result  = sforce.apex.execute('myApiWs', 'Xlogin', {customer:'SF', login:'Bob', pw:'Smith'});
 
Code:
global class myApiWs
{
    WebService static String Xlogin(String customer, String login, String pw)
    {
        return 'Customer=' + customer + '  Login=' + login;
    }
}
 
I have an S-Control that yields the error "No service available for class 'myApiWS", " when an attempt is made to call this Web Service.  Any idea why?
 
Chris
  • November 06, 2007
  • Like
  • 0
Hi. This is probably very simple. I have created a trigger which updates some records upon a user clicking on the SAVE button, after the updates I then want to redirect them to a custom object (which depends on what they have selected before clicking on save). In other words, I don't want them to view the saved record but immediately be directed to a new create screen for another object.

I have everything working fine but I cannot work out how to direct them to the create page for a custom object? I would assume it is possible to do from within the trigger but I can't find out how. Any assistance appreciated.

Hello,

Starting from 25.1.2012 our Sites analytics of live site has dropped to zero when looking figure "Usage Type = Origin Page Views". Average before was ~300 daily views.

Our Site is active, and there has not been any changes in the status.

Anyone any ideas what may be the reason for this? Tried to see if there was new usage type introduced but no help.

I tried via support by they just pointed here:

"Dear Aki, 

Thank you for contacting EMEA Support. Your case number is: 07021238 
I am sending you this email to notify you that I have reviewed your request. I suggest that you contact developer.force.com/communityboard to best assist you regarding this case. I will go ahead and have this case closed temporarily since this case will be handled by our DeveloperForce.com

Thanks for choosing Salesfore and have a nice day. 

Best Regards, 
Rammel Sildo 
Salesforce Support 
Support@salesforce.com 
Basic Support EMEA 353-1-440-3503" 

  • February 15, 2012
  • Like
  • 0

We are looking for experienced force.com developer partner in Guadalajara area, Mexico.

 

We have development and implementation projects where we would need help in apex and visualforce coding, as well as in other areas. Work is possible remotely but high availability from the partner is required.

 

Essential skills:

-Force.com administrator (>2 yrs)

-apex and visualforce

-JavaScript

-Force.com API

-Other Websevices experience like Amazon EC2 is plus

-Experience in integrating force.com to backend or other systems

-Fluent English and Spanish language

 

Please reply to the thread or send a private message if you meet the requirements.

Message Edited by AT on 02-24-2010 07:34 PM
  • February 24, 2010
  • Like
  • 0
 Can anyone see what's wrong here ? Still not able to get the code assertions to succeed. :smileyindifferent::smileysad::smileymad:
 
The simple batch process reparents account's contacts. It works ok, but in the testing I am not able to get assertions to succeed. 
 

global class BatchMerger implements Database.Batchable<SObject>{

  private final String query; global BatchMerger(String q){query = q;} global database.querylocator start(Database.BatchableContext BC){return Database.getQueryLocator(query);} global void execute(Database.BatchableContext BC, Sobject[] scope){ Map <Id, Account> dupes = new Map <Id, Account>(); for(sobject s : scope){ Account a = (Account)s; dupes.put(a.Id, a); } // Look for dupes Contacts List <Contact> contacts = new List <Contact>(); for(Contact c : [select Id, AccountId from Contact where AccountId in :dupes.keySet()]){ c.AccountId = dupes.get(c.AccountId).Real_Acct__c; contacts.add(c); } // updates Database.Saveresult[] src=Database.update(contacts); } global void finish(Database.BatchableContext BC){ }}

 

TEST DATA CREATIONS...

 

...

String query = 'select Id, Real_Acct__c, dupe__c ' +'from Account ' +'where Real_Acct__c != null ' +'and dupe__c = true ' +'limit 200'; BatchMerger cln = new BatchMerger(query); Id batchProcessId = Database.executeBatch(cln); Test.StopTest(); AsyncApexJob[] jobs = [select TotalJobItems, Status, Id from AsyncApexJob where Id = :batchProcessId]; system.assertEquals(1, jobs[0].TotalJobItems); <-- THIS IS OK! system.assertEquals(0, [select count() from Opportunity where AccountId = :dupes[0].Id]); <-- THIS FAILS, actual being 1 - the one opp in that in test data was assigned to this account dupes[0].

 

Thanks for help!

  
  • September 25, 2009
  • Like
  • 0

 global class BatchMerger implements Database.Batchable<SObject>{

  private final String query; global BatchMerger(String q){query = q;} global database.querylocator start(Database.BatchableContext BC){return Database.getQueryLocator(query);} global void execute(Database.BatchableContext BC, Sobject[] scope){ Map <Id, Account> dupes = new Map <Id, Account>(); for(sobject s : scope){ Account a = (Account)s; dupes.put(a.Id, a); } // Look for dupes Contacts List <Contact> contacts = new List <Contact>(); for(Contact c : [select Id, AccountId from Contact where AccountId in :dupes.keySet()]){ c.AccountId = dupes.get(c.AccountId).Real_Acct__c; contacts.add(c); } // updates Database.Saveresult[] src=Database.update(contacts); } global void finish(Database.BatchableContext BC){ } }

 

I have above simple batch to reparent account contacts. It works ok, but in the testing I am not able to get assertions to succeed.

 

 

TEST DATA CREATIONS...

 

...

String query = 'select Id, Real_Acct__c, dupe__c ' +'from Account ' +'where Real_Acct__c != null ' +'and dupe__c = true ' +'limit 200'; BatchMerger cln = new BatchMerger(query); Id batchProcessId = Database.executeBatch(cln); Test.StopTest(); AsyncApexJob[] jobs = [select TotalJobItems, Status, Id from AsyncApexJob where Id = :batchProcessId]; system.assertEquals(1, jobs[0].TotalJobItems); <-- THIS IS OK! system.assertEquals(0, [select count() from Opportunity where AccountId = :dupes[0].Id]); <-- THIS FAILS, actual being 1 - the one opp in that in test data was assigned to this account dupes[0].

 

 Can anyone see what's wrong here ?

 

Thanks for help!

 

  • September 23, 2009
  • Like
  • 0

Can you render http response as content for VF page?

 

Trying to achieve Basic authentication on a site using HTTP class e.g. https://www.site.net, and then show the resulted html response in the VF page...

  • March 25, 2009
  • Like
  • 0

I tried this out to get translated texts to my Visualforce PDF.

 

I have for example en_US.xml file in my static resource zip file that I try to read. However I got error: 

 

 

ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog.
An unexpected error has occurred. Your development organization has been notified.

 

I create new PageReference to the xml file, then throw that content to my xml parser.

 

This is my test method that fails with that error:

 

static testMethod void testXml(){ // test with content blob // Get the content blob from the localization file PageReference pr = new PageReference('/resource/1235260888000/Budget__pdfresources/en_US.xml'); Blob conBlob = pr.getContent(); ContentXmlParser c2 = new ContentXmlParser(); String str2 = conBlob.toString(); TempCover[] tmpc2 = c2.parseCovers(str2); system.debug(tmpc2); System.assert(tmpc2.size() == 1); System.assertEquals('Dear customer,', tmpc2[0].salutation); System.assert(tmpc2[0].body == 'Thank you for your invitation to offer for the project. Based on the information ... '); }

 

 Any idea what's wrong or am i trying the impossible ?

 

  • February 24, 2009
  • Like
  • 0

 <apex:pageBlock title="Linked Equipments"> <apex:pageBlockTable value="{!Opportunity.Opportunity_Equipments__r}" var="item"> <apex:column value="{!item.Asset__r.Name}"/> <apex:column value="{!item.Asset__r.Description}"/> <apex:column value="{!item.Asset__r.UsageEndDate}"/> <apex:column value="{!item.Asset__r.SerialNumber}"/> <apex:column value="{!item.Asset__r.PurchaseDate}"/> </apex:pageBlockTable> </apex:pageBlock>

 

I have a page where user can relate Assets to Opportunity. After pressing "add" commandbutton I rerender the datatable that show currently related Assets. However the above markup does not seem to work and show new related Assets after rerender. I only got it working after writing my own getter method.

 

But is it possible to get it working using the std controller record collection ? (Opportunity.Opportunity_Equipments__r)

 

 

Thanks for help

  • February 15, 2009
  • Like
  • 0
I get this error constantly while trying to deploy. Where the issue may be?

  • January 09, 2009
  • Like
  • 1
Hi,

I am trying to finsh test method for my controller but something is wrong.. I get "REQUIRED_FIELD_MISSING" on my upsert call.

I have created successfully test data and I am adding the id parameter to the page. Any ideas? below code...

Code:
public static testMethod void testUserPage() {
 
 
 User_Request__c u = UserRequest.setupTestReq();
 

    // Construct the standard controller for user request.
    ApexPages.StandardController s = new ApexPages.standardController(new User_Request__c());
    
    // Switch to runtime context 
    Test.startTest();
    
    // Construct the user req class
    UserRequest ux = new UserRequest(s);

   // Call save on the ux
    PageReference result = ux.save();

    // Switch back to test context
    Test.stopTest();
    
    // Verify the navigation outcome is as expected
    System.assertEquals(result.getUrl(), s.view().getUrl());
    

}

// Create test user request
 private static User_Request__c setupTestReq() {
 
  Id rid = [select Id from UserRole limit 1].Id;
  Id pid = [select Id from Profile limit 1].Id;
  
  User_Request__c u = new User_Request__c(
   
   First_Name__c = 'Dummy',
   Last_Name__c = 'Test',
   Role_ID__c = rid,
   ProfileID__c = pid,
   User_Name__c = 'dummy@test.com',
   Title__c = 'Sales',
   Legacy_User_ID__c = 'dummy',
   Language__c = 'Finnish',
   Country__c = 'Finland'
  
  );
  
  insert u;
  system.debug('ID is: '+u.id);
  
     PageReference pref = Page.UserRequest;
     pref.getParameters().put('id',u.id);
     Test.setCurrentPage(pref);
     
     return u;
     
 }

 

  • December 29, 2009
  • Like
  • 0
Hello,

I am just throwing this in the air as I left thinking it after the Sites developer webinar.

If replacing part(s) of web property with Sites - how to address the content management task ?

I.e. today you may have easy to use wysiwyg editor for content managers, Sites uses visualforce that is different. You may let them modify data in salesforce that is then drawn to the Site - but not quite as flexible as content editor.

Anyone already addressed this ?
  • December 02, 2008
  • Like
  • 1
Hi folks!

I have two iframes in the page and show only 1 of these at a time. In action method I set which should show and return null PageReference. Iframe 1 contains detail page of an object - Iframe 2 other web content.

Mystically the title bar (apex:detail "title" attribute) of 1st iframe remains after action method is invoked. Is this known issue..?

I noticed that if I remove "subject" attribute from apex:detail,  title bar will not spook around. But I need "subject" attribute because I rerender the apex:detail - if "subject" is not defined, after rerender there is no result.

Code:
********* Page (only relev parts) ***************

<apex:iframe height="-100" width="-100" id="frame1" rendered="{!NOT(frame)}">

<!-- Standard Detail -->
<apex:outputPanel id="det" >
<apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false" relatedListHover="false" />
</apex:outputPanel>

</apex:iframe>

<apex:iframe id="frame2" src="http://www.google.com" rendered="{!frame}"/>

<apex:commandButton ... that invokes action... action="{!button}" />
<apex:commandButton ... other btn invokes other action and rerenders details... action="{!button2}" rerender="det"/>


********* Controller (only main parts) ***************

showFrame = false;

public PageReference button() {
  
  showFrame = true;

  return null;
  }
  
public Boolean getFrame() {
  
  return showFrame;
    
    }

 

  • December 01, 2008
  • Like
  • 0
Hello folks,

Any idea why this happens:
-I have a list of wrapped items with checkbox in each row
-User can tick one and click "Activate" --> controller sets checkbox to true and only-1-logic deactivates old selection
-Partial refresh happens that rerenders the list.

Problem is that old selection still shows as selected - together with the new selection. The "activation" action works fine - after refreshing browser the values get correctly redrawn from the database. Can it somehow come from the controller that may give the existing selections plus the new selection..?

-AT
Code:
<apex:detail relatedList="false" relatedListHover="false" />

<apex:form >
   
<!-- HERE IS THE SELECTION LIST -->
<apex:outputPanel id="verslist">
 <apex:actionstatus id="verstatus" startText="(Activating...)">
  <apex:facet name="stop">
                    <apex:pageBlock title="Versionlist" >
          
        <apex:pageBlockButtons location="top">
              <apex:outputPanel id="button">
                  <apex:commandButton alt="Activate" value="Activate" action="{!activation}" status="verstatus" rerender="verslist"/>
                  
              </apex:outputPanel>
                  
              </apex:pageBlockButtons>
              <!-- vVer records from wrapper class -->
              
              <apex:pageBlockTable value="{!versions}" var="v" id="table">
              <apex:column >
                       <apex:inputCheckbox value="{!v.selected}" onclick="deselectOther(this)"/>
                   <apex:actionSupport event="onclick" action="{!enable}"  rerender="out,button" status="status2"/>
                   
                  </apex:column>
                  <apex:column value="{!v.ver.Name}" />
                  <apex:column value="{!v.ver.Version_Number__c}" />
                  <apex:column value="{!v.ver.Description__c}" />
                  <apex:column value="{!v.ver.Active__c}" />
              </apex:pageBlockTable>
          </apex:pageBlock>
   </apex:facet> 
   
  </apex:actionstatus> 
</apex:outputPanel>
</apex:form>

<apex:outputPanel id="out" >
          <apex:actionstatus id="status2" startText="Refreshing...">
             <apex:facet name="stop"> 
               <apex:outputPanel rendered="{!dpanel}"> 
                  
                 <apex:pageBlock title="Details">
                 <apex:pageBlockTable value="{!products}" var="p" id="restable">
                 
                 <apex:column value="{!p.Product__c}" />
                 <apex:column value="{!p.Quantity__c}" />
                 <apex:column value="{!p.Price__c}" />
                 
          </apex:pageBlockTable>
           </apex:pageBlock>
              </apex:outputPanel>
            </apex:facet> 
          </apex:actionstatus> 
     </apex:outputPanel> 
 
<script>          
        var selectedChkbox;
        
        function deselectOther(chkBox) {
            if (chkBox.checked) {
                if ((chkBox != selectedChkbox) && (selectedChkbox != null)) {
                    selectedChkbox.checked = false;
                }
                selectedChkbox = chkBox;
            }            
        }
        
        
        
</script>  

</apex:page>

 



  • November 19, 2008
  • Like
  • 0
Hi!

I use the below VF code to open an s-control in an iframe - similar result using custom button & s-control in standard sf page. However I cannot add the custom button in VF to get the same behavior.

So I use commadButton and return reference to new VF page with scontrol tag as in below code. However this is not as flexible - it is inline and static size. E.g. It does not react on sidebar collapse which is not nice. VF iframe tag doesnt seem to work as I cannot feed object id.

Any suggestions / workarounds?

Code:
<apex:page standardController="Offer__c" extensions="offerPage" tabStyle="Offer__c">

<apex:scontrol controlName="ListBtn" height="800" width="1000" subject="a06T0000001p2Q0"/>

</apex:page>
  • November 17, 2008
  • Like
  • 0
Hi!

I use the below VF code to open an s-control in an iframe - similar one does using custom button & s-control in standard sf page. However I cannot add the custom button in VF to get the same behavior.

So I use commadButton and return reference to new VF page with scontrol tag as in below code. However this is not as flexible - it is inline and static size. E.g. It does not react on sidebar collapse which is not nice. VF iframe tag doesnt seem to work as I cannot feed object id.

Any suggestions / workarounds?

Code:
<apex:page standardController="Offer__c" extensions="offerPage" tabStyle="Offer__c">

<apex:scontrol controlName="ListBtn" height="800" width="1000" subject="a06T0000001p2Q0"/>

</apex:page>

 
  • November 10, 2008
  • Like
  • 0
Hi,

We open external application in an iframe inside salesforce so that tab bar stays visible.

When we return to the opportunity detail page this also opens in the same iframe. (we pass return url "na1.salesforce.com/{!opp.id}")

What would be the best way to return back to Salesforce so that there is no iframe anymore? Now if inside iframe I go back to the external app again it will have again tab bar thus duplicating the tab bar. Is it best redirecting to s-control that refreshes whole page, etc..?

Any practices for similar case?
  • September 22, 2008
  • Like
  • 0
Hi,

When I hide the tab and sideabar using showHeader="false" the tab style is lost and everything is black. Is this a bug or normal behavior? If normal, how could I use the tab style from my custom object even if header is hidden?

Code:
<apex:page standardController="FL_Tender__c" showHeader="false" sidebar="false" tabStyle="FL_Tender__c">

<apex:detail ></apex:detail>

</apex:page>

 

  • September 22, 2008
  • Like
  • 0
Code:
global class XmlWriterCamos {
 
 WebService static String getXmlStream(Id[] versId) {

//INITIATE XML STREAM
  XmlStreamWriter w = new XmlStreamWriter();

//INPUT START ELEMENT
        w.writeStartElement(null, 'Data', null);
        
        //INPUT CurrentUser INFO
        w.writeStartElement(null, 'CurrentUser', null);
        w.writeStartElement(null, 'ID', null);
        w.writeCharacters(u[0].Id);
        w.writeEndElement(); //end Id
        if(u[0].City != null){
            w.writeStartElement(null, 'City', null);
            w.writeCharacters(u[0].City);
            w.writeEndElement(); //end City
        }
...

Quick shoot:
 
How would you write unit tests for such a code?

  • September 04, 2008
  • Like
  • 0
Are these coming someday? Most of the users cannot anymore live without it so hard to justify overriding std detail pages with VF.
  • August 04, 2008
  • Like
  • 0
Didn't quickly found any attributes in the standard components that would do it.

Is there other way to have 1 column layout easily?
  • August 04, 2008
  • Like
  • 0
Code:
try{
   update o;
   }catch (System.DmlException e){
    
     System.debug('DML Issue: ' + e);
     
     o.Price_Due_Date__c = System.today();
     update o;
       
      }


I try to update Opportunity object and set proper stage. However it may throw exception because this stage cannot be set if field "Price_Due_Date__c" is empty. (validation rule)

Question: Why in debug log I cannot see the message "DML Issue: ..." in case exception was thhrown and Today's date was set?

-Aki
  • June 28, 2008
  • Like
  • 0
I get this error constantly while trying to deploy. Where the issue may be?

  • January 09, 2009
  • Like
  • 1
Hello,

I am just throwing this in the air as I left thinking it after the Sites developer webinar.

If replacing part(s) of web property with Sites - how to address the content management task ?

I.e. today you may have easy to use wysiwyg editor for content managers, Sites uses visualforce that is different. You may let them modify data in salesforce that is then drawn to the Site - but not quite as flexible as content editor.

Anyone already addressed this ?
  • December 02, 2008
  • Like
  • 1
Hello,
   I have an managed package org where I create managed package. Now I am editing one of the object's layout. but receiving following error-
Record deleted
The record you attempted to access has been deleted. The user who deleted this record may be able to recover it from the Recycle Bin. Deleted data is stored in the Recycle Bin for 15 days. 

Click here to return to the previous page.

Can anyone help me that why this is happening. I am not even able to create new layout for the same object. And this is happenning for only one particular object. Thanks! 

Hi,

 

 How can we do something like Set History Tracking for OpportunityTeamMember? OWD setting for Opportunity in my org is Private. Please help.

 

Thanks and Regards.

I'm trying to include related lists for Related Content and Content Deliveries on a VF page and I can't figure out their relationship names. I searched in the docs but couldn't find that info. Can someone help?

Where is that info (list of all standard relationship names) documented?

 

I tried the following and few other names without luck.

 

 

<apex:relatedList list="RelatedContent" />
<apex:relatedList list="Content" />
<apex:relatedList list="ContentDeliveries" />

 

 

Thanks much

  • February 15, 2011
  • Like
  • 0

hi  i created a site where the guest users can edit their personal information. the operation should be on lead object.so i created a custom controller submitt which will save the edited info by user. it worked fine in the develoepr mode. when i put that page in sites its not updating the information on the lead record. when i went to public access settings and checked there are no modify permission for leads on sites. how can i achieve this task through sites. 

I'm trying to move a custom field from one sandbox into another using the Force.com Migration Tool, and getting a funky "Cannot rename standard profile" error.  

 

Here's my package file which goes in the "$PROJECT_ROOT/unpackaged" folder:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>Profile</name>
    </types>
    <types>
      <members>Account.Test__c</members>
      <name>CustomField</name>
    </types>
    <version>18.0</version>
</Package>

 

 

 

Here's my ant build.xml file which sits in the $PROJECT_ROOT folder:

 

 

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
    <property file="build.properties"/>
    <property environment="env"/>

    <target name="retrieveUnpackaged">
      <mkdir dir="retrieveUnpackaged"/>
      <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveUnpackaged" unpackaged="unpackaged/package.xml"/>
    </target>

    <target name="deployUnpackaged">
      <sf:deploy username="${sf.deploy.username}" password="${sf.deploy.password}" serverurl="${sf.deploy.serverurl}" deployRoot="retrieveUnpackaged"/>
    </target>
</project>

 

 

This properties file all goes in the $PROJECT_ROOT folder:

 

 

# build.properties
#

sf.username = <username>@<org>.sandbox1
sf.password = <password>
sf.serverurl = https://test.salesforce.com

sf.deploy.username = <username>@<org>.sandbox2
sf.deploy.password = <password>
sf.deploy.serverurl= https://test.salesforce.com

 

To run, execute the following two commands:

 

 

ant retrieveUnpackaged
ant deployUnpackged

 

 

When I try to deploy to the second sandbox I am getting the following error:

 

 

Error: profiles/Guest License User.profile(Guest License User):Cannot rename standard profile

 

 

My package is pretty straightforward and I can't imagine what I might be doing to get this error.  Any thoughts?

 

 

Thanks,

Greg

Hi All,

I built a VF page with custom controller which calls another VF page that returns a PDF. The PDF is is extracted via getContent(), and attached to an email. It all works fine in the sandbox through the UI, but the test method fails, unfortunately without detailed log information.

 

I already found these two threads but none really points to an explanation why it fails in test methods while working fine in the UI:

http://community.salesforce.com/t5/Apex-Code-Development/error-quot-System-VisualforceException-quot-at-getContent/td-p/173307?view=by_date_ascending

 

http://community.salesforce.com/t5/Apex-Code-Development/RageReference-getContent-failing-on-Spring-10-release/td-p/168272

 

Here is the relevant code from the action method:

 

    public PageReference send(){

        for (string address:CCAddresses)
        {
        	if(!address.endsWith('@symmetricom.com')) address += '.full';
        }
        
        PageReference pdfPage = Page.quotePDF;
        pdfPage.getParameters().put('id',theQuote.ID);
        //pdfPage.setRedirect(true);
        System.Debug('pdfPage::::::::::::::::::::::::::::::::::::::: ' + pdfPage);
        transient Blob theBlob;
        theBlob = pdfPage.getContent();
        
        transient Attachment a = new Attachment (
            parentID = theQuote.ID,
            name = 'SymmQuote ' + theQuote.Name + '.pdf',
            body = theBlob);
        

 It fails at the line theBlob = pdfPage.getContent(); when called from the test method, otherwise it works fine. Error message is:

System.VisualforceException: List has no rows for assignment to SObject

The quotePDF page uses the same controller and I was wondering if that causes the issue. Maybe the test cannot handle another instance of the same controller? The PageReference for the pdfPage is created correctly

 

here is the test method:

 

		PageReference pageRef2 = Page.quoteSend;
		Test.setCurrentPage(pageRef2);
		ApexPages.currentPage().getParameters().put('id',quote1.Id);
		quoteLineEdit_v1 editController2 = new quoteLineEdit_v1();
		
		editController2.send();

 

 

 

 

 

 

 

 

 

hey guys, i get this error all of the sudden.

"System.VisualforceException: core.apexpages.exceptions.ApexPagesGenericException:

Class.GenerateAttachEmailCertificate_WS.GenerateAttachEmailCertificate: line 10, column 18
Class.GenerateAttachEmailCertificate_WS.testingEmail: line 93, column 14
External entry point".

 

line 9 and 10:

 

PageReference pdf = new PageReference('/apex/CertificatePrintToPdf?id=' + id); Blob pdfBody = pdf.getContent();

 

and line 93 is inside my test method:

 

testSend = GenerateAttachEmailCertificate_WS.GenerateAttachEmailCertificate(testId, testVer, testLoc);

 

im pretty sure it was 100% coverage, but now im in the middle of deploying a new class into production, and i got that error.

 

can anyone help me please?

thanks in advance.

 

 

 

 

 

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

 

 

I have a standard Salesforce edit page where the first 2 fields are picklist and the next one is a date field. Everytime the page loads in edit mode, salesforce automatically brings the date field in focus and the calendar widget pops up. This can be very confusing to the users as the date field is required to be populated only in certain cases. I also do not have the option of moving a text field before the date field.

Is there a way to remove the focus or allow me to have some other field in focus?

Do you know if there's any way to know in witch enviroment (production or sandbox) is running an Apex application (class, trigger...)?

 

I mean inside the code of course. Any "global variable" that tells the enviroment?

  • October 20, 2009
  • Like
  • 0

This can't be right can it?

 

I just got this error... 

 

 Error: List controllers are not supported for CampaignMember

 

 

All I want is a paginated list display of CampaignMember records...

 

In reality I would love an enhances list of CampaignMember records but I can't do that... Any ideas. 

 

I need to work with this object specifically.

 

update: <apex:listViews type="CampaignMember" /> works but won't suffice as I need to be able to specify what type of element is displayed in the list.

 

As it's an 'editable' grid like list I need to create.

Message Edited by pbulacz on 10-19-2009 05:45 PM
 Can anyone see what's wrong here ? Still not able to get the code assertions to succeed. :smileyindifferent::smileysad::smileymad:
 
The simple batch process reparents account's contacts. It works ok, but in the testing I am not able to get assertions to succeed. 
 

global class BatchMerger implements Database.Batchable<SObject>{

  private final String query; global BatchMerger(String q){query = q;} global database.querylocator start(Database.BatchableContext BC){return Database.getQueryLocator(query);} global void execute(Database.BatchableContext BC, Sobject[] scope){ Map <Id, Account> dupes = new Map <Id, Account>(); for(sobject s : scope){ Account a = (Account)s; dupes.put(a.Id, a); } // Look for dupes Contacts List <Contact> contacts = new List <Contact>(); for(Contact c : [select Id, AccountId from Contact where AccountId in :dupes.keySet()]){ c.AccountId = dupes.get(c.AccountId).Real_Acct__c; contacts.add(c); } // updates Database.Saveresult[] src=Database.update(contacts); } global void finish(Database.BatchableContext BC){ }}

 

TEST DATA CREATIONS...

 

...

String query = 'select Id, Real_Acct__c, dupe__c ' +'from Account ' +'where Real_Acct__c != null ' +'and dupe__c = true ' +'limit 200'; BatchMerger cln = new BatchMerger(query); Id batchProcessId = Database.executeBatch(cln); Test.StopTest(); AsyncApexJob[] jobs = [select TotalJobItems, Status, Id from AsyncApexJob where Id = :batchProcessId]; system.assertEquals(1, jobs[0].TotalJobItems); <-- THIS IS OK! system.assertEquals(0, [select count() from Opportunity where AccountId = :dupes[0].Id]); <-- THIS FAILS, actual being 1 - the one opp in that in test data was assigned to this account dupes[0].

 

Thanks for help!

  
  • September 25, 2009
  • Like
  • 0

How can we  redirect a trigger to a standard salesforce URL? Like when the user updates a cutom field in Opportunity, I want him to go to the new Partner reated list page directly when he hits save. Usually you can only see the new partner page only when you click New in Partner subsection from the opportunity details page. But I want to mandate the partner related list page when user selects YES for a custom field in Opportunity page.

I've made some changes last week on some of my Appex classes and this morning with the same configuration and when I try to save my changes on the server I get this error message:

 

File only saved locally, not to server

 

So I've created a new project, a new workfolder and  made a checkout of everything and without even changing the code, I still get this error. I have some Appex pages too, but they work fine (compile ans save on server).

 

I notice on ''Monitor Deployment'' that the deployment status is supposedly completed and all my classes have the API version 15 but when I create new classes I can only select API version 16 now. Is this related to my problem?

 

Does some of you knows a good way to fix this?

OK, I must be going crazy because I think this was working yesterday...  I need to have a VF page with a

multiselect list, which I can't seem to get working.  Here's the simplest case I've been able to boil it

down to.

VF Page:


<apex:page controller="TestController" sidebar="false" showHeader="false"> <apex:pageBlock title="Values" rendered="true" id="Pageid"> <apex:form > <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Test: " for="pickTest"/> <apex:selectList value="{!Values}" size="4" id="pickTest" multiselect="true" > <apex:selectOptions value="{!ValueOptions}"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:commandButton action="{!testIt}" value="Test It!"/> </apex:pageBlockSection> </apex:form> </apex:pageBlock> </apex:page>

 


Controller:

public class TestController { private String [] m_lstVals; public void setValues (String [] lstVals) { m_lstVals = lstVals; } public String [] getValues () { return m_lstVals; } public List<SelectOption> getValueOptions() { List<selectoption> lstOptions = new List<SelectOption>(); lstOptions.add(new SelectOption ('one', 'one')); lstOptions.add(new SelectOption ('two', 'two')); lstOptions.add(new SelectOption ('three', 'three')); return lstOptions; } public PageReference testIt () { if (m_lstVals == null) { System.debug ('No values'); return null; } for (String s : m_lstVals) { System.debug ('Selected value: ' + s); } return null; } public static testmethod void testController () { TestController tc = new TestController (); List<SelectOption> so = tc.getValueOptions(); } }

 


 

 

When I select 'one' and 'two' and press the 'test It' button, I get the following in the debug log:

Conversion Error setting value 'one two' for '#{Values}'.

When I set 'multiselect' to 'false' (and change the accessor methods to just Strings) everything works

correctly.  It must be something really silly/simple here!  Could someone take a look and point out my

mistake?

Thanks in advance!

Hi All,
 
 
We are currently facing an issue regarding SMS integration. 
 
We need to send the SMS automatically when a case is saved/edited. For this we have an apex class which consists  of  HTTPS callouts to access the SMS gateway of Value first 
and a trigger which invokes this apex class when ever a case is saved/edited.
 
Now, when ever the trigger is fired i'm getting this exception     "System.CalloutException: Callout from triggers are currently not supported"
 
I think it can be possible by S-Control  but the process should automatic.  
 
And this is very urgent for our project 
 
Pls suggest any solution /workaround  for the same.
 

 
Any help is appreciable.
 
 
Thanks  
Jagan.
  • January 28, 2009
  • Like
  • 0
Hi,

I have a Contract Terms Custom Object which has a dependent picklist named 'Territory' depending on 'Region' picklist. I have used these two picklist in my page using the inputField tag but I am not getting the behaviour of the depending picklist. As soon as I change the Region value, the Territory picklist values should change depending on the value selected but it does not happen.

Here is the piece of code
Code:
        <apex:pageBlock title="Section 2" rendered="{!showSecondSection}">
            <p>To what geography does this rate apply— </p>
             Region: <span style="padding:10px;"/>
             <apex:inputField value="{!contractTerms.REGION__c}"></apex:inputField>
             <p> Territory: <span style="padding:10px;"/>
             <apex:inputField id="territory" value="{!contractTerms.TERRITORY__c}"/></p>
             <p><span style="padding:10px;"/><apex:commandButton action="{!showSection3}" 
value="Continue" styleClass="btn"></apex:commandButton></p><br/> </apex:pageBlock>

 
Can anyone please help me resolve this issue?

Thanks,
Jina