• BDArnz
  • NEWBIE
  • 49 Points
  • Member since 2006

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 40
    Replies
Hello, I tried for a long time to figure out how to update/refresh a parent detail record page after an embedded VF page was updated.  Apex associated with the embedded VF page can change field values on the parent detail record but it was virtually impossible to get the detail page to refresh so the user could see the new values without refreshing the entire browser window.

Dr. Paul Coleman recently blogged about the very solution I needed.  Not only does it refresh the parent but it also dynamically resizes the embedded VF page depending on how many records are being displayed on the VF page.  Very Cool! See it here: http://salesforcehacks.blogspot.com/2014/12/resizing-embedded-vf.html

I won't supply the entire code here but rather focus on my current problem.  The code works well when the user is in the standard SF interface.  But we have some users that are using the Service Console and the code doesn't work there.

The code uses Javascript to specifically address the iFrame where the embedded VF page resides.  When the page is rendered outside of the Service Console, the iFrame is named with the id of the VF Page so it's easy to getComponentByName() using the Id:

<iframe frameborder="no" height="600px" id="066800000006mxu" marginheight="0" marginwidth="0" name="066800000006mxu" scrolling="yes" title="CT_RMALineItems" width="100%"></iframe>

But when the page is rendered inside the console, the name is more complicated:

<iframe frameborder="no" height="600px" id="sc-evf-fdc3fddc-8e17-44f5-bc43-bed1a8a8ced4-066800000006mxu" marginheight="0" marginwidth="0" name="sc-evf-fdc3fddc-8e17-44f5-bc43-bed1a8a8ced4-066800000006mxu" scrolling="yes" title="CT_RMALineItems" width="100%"></iframe>

Does anyone know how this name is arrived at or how to figure it out so I can modify Dr. Coleman's code to work in the Service Console?

Thanks.
  • December 09, 2014
  • Like
  • 0

I'm working on being able to translate a part number (stored as a string) from one extenal system to another.  I have a custom table setup each record will have both part numbers and would like the user to be able to enter either number and have SF provide the other.  If a number is not found in the table, query an external system (using HTTP callout) to retrieve it then save it in the table so future requests for the same number don't have to callout to the external system (essentially add records on the fly).

Here's the flow:  user enters a part number from system A.  This field is a string.  Apex queries the custom table to see if it is saved.
 

List<Part__c> p = new List<Part__c>();
p = [Select Return__c, Regional_Scrap__c, Return_Factory__c, Factory_Approval__c, Name, Description__c, SAP_Number__c From Part__c Where Name = :li.Part_Number__c];

First time part number is used, the query will return 0 records [p.size()=0].  Apex will then use the HTTP callout to query the external system to get the other part number.  Callout is working fine.  Response gets parsed into a List<String> and the field value set.

HTTPResponse res = http.send(req);
bodyval = res.getBody();
list<string> dfresults = bodyval.split('\t', 10);
li.SAP_Number__c = dfresults[4];

The other number looks fine after the parsing and setting the field value.  Since the initial query returned no records (as expected) I then copy save the data into the table (so future need doesn't result in another callout to the external system)

Part__c Prt = new Part__c();
Prt.Name = li.Part_Number__c;
Prt.SAP_Number__c = li.SAP_Number__c;
insert Prt;

This is working.  I can see the new part in the table (on the tab using a list view).

NOW, i want to translate this number back the other way.  So I provide the SAP Number and query the Part table expecting to find the record that was just saved.

p = [Select Return__c, Factory_Approval__c, Regional_Scrap__c, Return_Factory__c, Description__c, Name, SAP_Number__c From Part__c Where SAP_Number__c = :li.SAP_Number__c];

Unfortunately this query ALSO returns 0 records so the loop continues and since "It didn't find the record" it adds it a second time and now I have 2 records.  it will not create any additional records.  If I repeat the second part and ask for hte SAP number, it will return the second record that was created.  I can even delete the intial record (created from the HTTP callout) and will not create a second record.

So my question is, any idea why the query after the initial record is created returns 0???



 



 

  • August 13, 2014
  • Like
  • 0

Help!  Please!

 

I've been using the Office Toolkit version 3 for years to query information from SF into an Excel spreadsheet.  Just recently I'm seeing an error:

 

Microsoft Visual Basic

Run-time error '-2147467259 (80004005)':

 

An internal server error has occured while processing your request.

Url:https://na6-api.salesforce.com/services/Soap/c/13.0/00D300000006bcc

 

 This does not appear to be a connection issue.  The code will login the user in with no error.  it then runs a successful query to get contacts and then another query to get some information from a related table and then a query to get a list of opportunities associated with the selected contact.  Once the chosen opportunity is selected, it then attempts to get some detail about the opportunity.  That is the specific query where it bombs with this error.

 

The specific line of code is:

 

Set qr = cSFComm.Query(sQueryString, False)

 

This same exact specific line is the same one all of the other queries has passed through to get query results.

 

This particular query string is:

 

Select Id, OwnerId, Distributor_or_Sales_Representative__c, Purchase_Order_Num__c, Sales_Order_Number__c, Quote_Num__c, Target_Ship_Date__c, Market_Level_1_Industry__c, Market_Level_2_Application__c, Market_Level_3_Substrate__c, Market_Level_4_End_Use__c, Valve__c, Name From Opportunity Where id = '0068000000i7IwbAAE'

 

I tried upgrading to toolkit version 4 but get the exact same issue.

 

Anyone have any ideas?

  • February 15, 2013
  • Like
  • 0

I have a VF page showing multiple custom objects with related lists.  (Lists within lists actually).  I have enabled inline edit for all of the fields and it works great.  Double click the field, edit, click save.  Save, cancel and new buttons all show and hide as expected.

 

My challenge is when inserting new records.  I do NOT want to go the standard object detail screen to enter the information into the fields.  (multiple linked and nested objects/lists means a lot of 'bouncing' back and forth that I want to avoid the user getting lost in.  I would like for them to stay on the same page essentially inserting the record directly into the list).

 

My 'New' button adds a record to the list which adds and displays the new record properly.  It has default text instructing the user to double click to edit.  I would rather have the newly created record show up already 'in' inline edit mode.

 

Does anyone know of a way to initiate in-line edit mode without requiring the user to click or double click somewhere?  I'm open to solutions either from the VF page doing it or the controller...

 

Thanks for listening (or reading...)

  • October 23, 2012
  • Like
  • 0

In short, my need is to make buttons show/hide when in-line editing is open on a record inside a table on a VF page. 

 

this code:

 

<apex:inlineEditSupport event="ondblClick" showonEdit="saveButton,cancelButton" />

 Works beautifully when the save and cancel buttons are in the <pageBlockButtons> tag.

 

My model is a little complex however.  I have 3 custom objects A, B & C.  A is related to multiple records in B.  And each record in B is related to multiple records in C.  (All normal lookup relationships).  SF standard UI page would have Detail A & related list B on a single page.  Detail B would have related list C on a single page.  I would like to have A, B & C all on the same page.  It was a pretty short VF leap to connect C back to A and create a page:  Detail A, related list B and related list C on the single VF page.  The problem is that it's not easy to connect which records C connect to which records B.  Got it?

 

I did some digging and figured out how to create nested tables.  So now I have Detail A, then my table which has B1 followed by all of it's related Cs then B2 followed by it's related Cs, etc through all of the records B.  This looks great.  I can now see A, B and C and it's easy to see which Cs belong to which Bs all on a single VF page.  I needed a couple of wrapper classes in the controller.

 

NOW I want to enable in-line editing inside this table so each record (whether it's a B or a C) can be edited directly from this single page rather than have to jump over to the respective detail pages and then have to find my way back.  in-line editing is cool.  It worked when my table only had Bs or Cs.  In those cases having the buttons in their respective <pageBlockButton> tag worked well.

 

Here's the page markup:

<apex:page Title="Seven Step"
	StandardController="X7_Step__c" 
	Extensions="SevenStepEXT" 
	TabStyle="X7_Step__c">

	<apex:form >
		
		<apex:detail subject="{!this7Step.Id}" relatedList="false" title="true" id="X7StepDetail" inlineEdit="true"/>


    	<b>Step 3 Potential Root Causes and Analysis</b>
    	<apex:pageBlock >
			<apex:repeat value="{!wrapout}" var="w">
					<table 
						border="3"
						cellpadding="3"
						id="table">
						<tr>
							<td style="width:150px">
								<b>Rating:&nbsp;&nbsp;</b>
       							<apex:outputField value="{!w.Cause.Rating__c}">
       								<apex:inlineEditSupport event="ondblClick"/>
       							</apex:outputField>
							</td>
							<td style="width:400px">
								<b>Possible Cause:&nbsp;&nbsp;</b>
								<apex:outputField value="  {!w.Cause.Name}">
									<apex:inlineEditSupport event="ondblClick" showonEdit="saveButton,cancelButton"/>
								</apex:outputField>
							</td>
							<td rowspan="2">
								<apex:commandButton action="{!w.SaveCause}" id="saveButton" value="Save"  style="display: none;"/>
								<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"  style="display: none;"/>
							</td>
						</tr>
						<tr>
							<td colspan="2" style="width:550px">
								<b>Detail:&nbsp;&nbsp;</b>
       							<apex:outputField value="{!w.Cause.Root_Cause__c}">
       								<apex:inlineEditSupport event="ondblClick"/>
       							</apex:outputField>
							
							</td>
						</tr>
					</table>
					
					
            	<apex:pageBlockTable value="{!w.steps}" var="wo">
            		<apex:column >
            			<apex:outputField value="{!wo.step.Step__c}"/>
            		</apex:column>
             		<apex:column >
            			<apex:outputField value="{!wo.step.Result__c}"/>
            		</apex:column>
            	</apex:pageBlockTable>
            	<hr/>
			</apex:repeat>        	
    	</apex:pageBlock>
	</apex:form>
</apex:page>	

 And the controller extension:

public with sharing class SevenStepEXT {
	Public X7_Step__c this7Step {get;set;}
	Private List<Root_Cause__c> Causes = new List<Root_Cause__c>();
	Private Map<ID,List<Testing_Steps__c>> CauseStepMAP = new Map<Id,List<Testing_Steps__c>>();	
	Private Set<ID> CauseIDs = new Set<ID>();
    public List<wrapper> wrapout {get; set;}
	

    Public SevenStepEXT (ApexPages.StandardController stdController) {
        this7Step = (X7_Step__c)stdController.getRecord();
        wrapout = new List<wrapper>();

        Causes = [select Id,
        			Name,
        			Case__c,
        			Cause__c,
        			Rating__c,
        			Root_Cause__c,
        			X7_Step__c 
        			from Root_Cause__c 
        			where X7_Step__c = :this7Step.id AND IsDeleted = false];
        for(Root_Cause__c rc:Causes){CauseIDs.add(rc.id);}
        for(Testing_Steps__c ts:[select Id,
        							Name,
        							Case__c,
        							Result__c,
        							Root_Cause__c,
        							Step__c,
        							X7_Step__c 
        							from Testing_Steps__c 
        							where Root_Cause__c=:CauseIDs AND IsDeleted = false]){
            if(CauseStepMAP.containsKey(ts.Root_Cause__c)){
                CauseStepMAP.get(ts.Root_Cause__c).add(ts);//adds Test Step for this Cause to the Test Step list in the map    
            }else{
                CauseStepMAP.put(ts.Root_Cause__c,new List<Testing_Steps__c>{ts});//adds new Test Step list for this Cause to the map    
            }
        }

        for(Root_Cause__c c:Causes){
            wrapper tmpwrapper = new wrapper();
            tmpwrapper.Cause=c;
            List<wrapper2> t2 = new List<wrapper2>();
            for(Testing_Steps__c s:CauseStepMAP.get(c.id)){
                wrapper2 twrap2 = new wrapper2();

                twrap2.Step=s;
                t2.add(twrap2);
            }
            tmpwrapper.Steps=t2;
            wrapout.add(tmpwrapper);
        }
    }


    //wrapper 1
    class wrapper{
    	Public Boolean ShowButtons {get;set;}
        public Root_Cause__c Cause {get; set;}
        //This is a list of other wrappers that is nested in the first list        
        public List<wrapper2> Steps {get; set;}
        public wrapper(){
            if(Cause==null){Cause = new Root_Cause__c();}//initialize the Cause holder
            if(Steps==null){Steps = new List<wrapper2>();}//initialize the Steps listholder
        	ShowButtons = false;
        }
    
	    Public void SaveCause(){
	    	Update Cause;
	    }
    	
    	Public void toggleButtons(){
    		if (ShowButtons == true){
    			ShowButtons = false;
    		}else{
    			ShowButtons = true;
    		}
    	}
    
    }





    //wrapper 2 - the Test Steps
    class wrapper2{
        Public Testing_Steps__c Step {get; set;}
        public wrapper2(){
            if(Step==null){Step = new Testing_Steps__c();}//initialize the Testing_Step__c holder
        }
    }

 

 

The table renders perfectly (it still needs some formatting...) and the in-line edit mode enables when doubleclicking the fields.  The buttons do work properly when they're visible.  Save saves the individual specific record and cancel aborts.  The problem is that I DON'T want them visible until in-line edit is enabled. and I want them to go away after saving.  I can't make the buttons work in the <pageBlockButton> tag because the save is not in context with the record so it made sense to have the buttons appear in a cell in the same row as the record and have the save method in the appropriate wrapper class.  Everything is in context and everything saves.  How do I make them come and go?

 

I have tried using a render boolean value but I don't know how to trigger a method in the controller to switch the value upon in-line edit mode and I can't get that even to rerender...

 

Anyone have any ideas on this?

 

 

  • October 10, 2012
  • Like
  • 0

Can someone tell me where these are coming from?

 

It is not related to any code.  I am not loading any projects at all.  I get these messages as soon as I start Eclipse.  (trying to work with projects fail for a variety of reasons...)

 

!SESSION 2012-05-10 13:45:45.373 -----------------------------------------------
eclipse.buildId=M20110210-1200
java.version=1.7.0_04
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:07:58.856
!MESSAGE  WARN [2012-05-10 14:07:58,829] (IntroEditorInput.java:loadDocument:130) - org.xml.sax.SAXParseException; lineNumber: 149; columnNumber: 32; The entity name must immediately follow the '&' in the entity reference.


!ENTRY org.eclipse.ui 4 4 2012-05-10 14:08:51.034
!MESSAGE Invalid preference page path: HTML Syntax
!ENTRY com.salesforce.ide.core 4 0 2012-05-10 14:08:58.939
!MESSAGE ERROR [2012-05-10 14:08:58,935] (PackageManifestFactory.java:getPackageManifest:115) - Unable to create package manifest
java.lang.ClassCastException: com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
!ENTRY com.salesforce.ide.core 4 0 2012-05-10 14:08:58.950
!MESSAGE ERROR [2012-05-10 14:08:58,948] (ProjectContentPropertyPage.java:createContents:77) - Factory exception occurred when marshalling package manifest into DOM document
com.salesforce.ide.core.factories.FactoryException: java.lang.ClassCastException: com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
caused by: java.lang.ClassCastException: com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:10:04.631
!MESSAGE  WARN [2012-05-10 14:10:04,630] (Utils.java:loadDocument:823) - Unable to load document: C:\Eclipse 3.6.2\Workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\CAR SDP\com.salesforce.ide.core\packageCache.xml (The system cannot find the file specified)


!ENTRY org.eclipse.jface 4 2 2012-05-10 14:10:04.703
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
java.lang.ClassCastException: com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
(PackageManifestFactory.java:547)
ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:10:11.510
!MESSAGE  WARN [2012-05-10 14:10:11,508] (ConnectionFactory.java:clearCache:212) - Clearing the following cached connections


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:10:11.511
!MESSAGE  WARN [2012-05-10 14:10:11,510] (DescribeObjectRegistry.java:clearCache:657) - Clearing cached describes


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:10:11.512
!MESSAGE  WARN [2012-05-10 14:10:11,511] (MetadataFactory.java:clearCache:123) - Clearing the following cached metadata stubs

!SESSION 2012-05-10 14:36:46.206 -----------------------------------------------
eclipse.buildId=M20110210-1200
java.version=1.7.0_04
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.ui 4 4 2012-05-10 14:37:18.536
!MESSAGE Invalid preference page path: HTML Syntax

!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:37:38.631
!MESSAGE  WARN [2012-05-10 14:37:38,609] (Utils.java:loadDocument:823) - Unable to load document: C:\Eclipse 3.6.2\Workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\CAR SDP\com.salesforce.ide.core\packageCache.xml (The system cannot find the file specified)


!ENTRY org.eclipse.jface 4 2 2012-05-10 14:37:39.340
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".

!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:40:18.278
!MESSAGE  WARN [2012-05-10 14:40:18,276] (ConnectionFactory.java:clearCache:209) - No cached connections


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:40:18.279
!MESSAGE  WARN [2012-05-10 14:40:18,278] (DescribeObjectRegistry.java:clearCache:654) - No cached describes


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:40:18.280
!MESSAGE  WARN [2012-05-10 14:40:18,279] (MetadataFactory.java:clearCache:120) - No cached metadata stubs

!SESSION 2012-05-10 14:52:37.914 -----------------------------------------------
eclipse.buildId=M20110210-1200
java.version=1.6.0_27
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.ui 4 4 2012-05-10 14:53:54.899
!MESSAGE Invalid preference page path: HTML Syntax

!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:54:34.796
!MESSAGE  WARN [2012-05-10 14:54:34,756] (ConnectionFactory.java:clearCache:209) - No cached connections


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:54:34.797
!MESSAGE  WARN [2012-05-10 14:54:34,796] (DescribeObjectRegistry.java:clearCache:654) - No cached describes


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 14:54:34.798
!MESSAGE  WARN [2012-05-10 14:54:34,797] (MetadataFactory.java:clearCache:120) - No cached metadata stubs

!SESSION 2012-05-10 14:54:37.631 -----------------------------------------------
eclipse.buildId=M20110210-1200
java.version=1.6.0_27
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.osgi 2 0 2012-05-10 14:55:00.449
!MESSAGE While loading class "com.salesforce.ide.upgrade.internal.UpgradeNotifier$3", thread "Thread[main,6,main]" timed out waiting (5000ms) for thread "Thread[Worker-5,5,main]" to finish starting bundle "com.salesforce.ide.upgrade_24.0.0.201202291629 [209]". To avoid deadlock, thread "Thread[main,6,main]" is proceeding but "com.salesforce.ide.upgrade.internal.UpgradeNotifier$3" may not be fully initialized.
Root exception:
org.eclipse.osgi.framework.internal.core.AbstractBundle$BundleStatusException
!ENTRY org.eclipse.ui 4 4 2012-05-10 15:04:59.021
!MESSAGE Invalid preference page path: HTML Syntax

!ENTRY com.salesforce.ide.core 2 0 2012-05-10 15:04:59.213
!MESSAGE  WARN [2012-05-10 15:04:59,191] (ConnectionFactory.java:clearCache:209) - No cached connections


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 15:04:59.214
!MESSAGE  WARN [2012-05-10 15:04:59,214] (DescribeObjectRegistry.java:clearCache:654) - No cached describes


!ENTRY com.salesforce.ide.core 2 0 2012-05-10 15:04:59.215
!MESSAGE  WARN [2012-05-10 15:04:59,215] (MetadataFactory.java:clearCache:120) - No cached metadata stubs

!SESSION 2012-05-10 16:15:29.950 -----------------------------------------------
eclipse.buildId=M20110210-1200
java.version=1.6.0_27
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.ui 4 4 2012-05-10 16:16:04.825
!MESSAGE Invalid preference page path: HTML Syntax

 



I've created a VF page to replace the standard case detail page that uses tabs to show related records from related objects (Assets, Service__c).  I would like to show the case team on it's own tab but I can't seem to get the relationship name.  Everything I try returns the dreaded "'XXXXXX' is not a valid child relationship name for entity Case".

 

My code is pretty simple:

 

		<apex:tab label="Team" name="TeamList" id="tabTeamList">
			<apex:relatedList subject="{!thisCase}" list="TeamMembers" />
		</apex:tab>	

 I used Eclipse schema browser to get to relationship name "TeamMembers", I also tried the child relationship "TeamTemplateRecords" but get the same error. 

 

I did search the forums and about the only suggestion was to ensure the related list is present on the standard detail page which I've done.

 

Does anyone know what relationship name to use?

  • August 04, 2011
  • Like
  • 0

Does anyone know why this page references the wrong object?

 

I've created a VF page to replace the default Case Detail page so I can add an extension controller.  We have linked the Asset object to Cases and also the Service object (a custom object) to Cases.

 

When this new detail page loads I expected the header to show the Case icon typically used and the name of the case.  Instead it shows the Service Icon with the name of the service that is attached to the case.  If I remove the Service from the case the header shows the asset instead.  It's very confusing for the user.  (I can't figure out how to post a screen capture in here...)

 

Here's the code for the page which clearly references the Case standard controller AND uses the tabStyle Case.

 

<apex:page standardcontroller="Case" extensions="CaseExtension" tabStyle="Case">
<!-- https://na6.salesforce.com/apex/case_escalation?id=50080000006nANlAAM -->
	<style>
		.activeTab {background-color: #236FBD; color:white;
			background-image:none}
		.inactiveTab {background-color: lightgrey; color:black;
			background-image:none} 
	</style>
	<apex:form >
	<apex:pageblock Title="Hello {!$User.FirstName} {!$User.LastName}" id="TitleBlock">
	<table border="3">
		<tr>
			<td colspan="2"><h1>Version 1.0</h1><br />
			<font color="blue">1.0 Initial Release</font><br />
			This is a new Case Detail Screen showing details about the associated service and asset.<br />
			It will also be the launching point for escalating cases.<br />
			<br />
			Please provide feedback regarding this page to:
			<apex:outputLInk value="mailto:barnold@nordson.com">  Brett Arnold</apex:outputLInk><br /><br />
			</td>
			<td rowspan="3">Instructions:<br />
			To be added.<br />
			</td>
			<td rowspan="3"><apex:image url="{!$Resource.ServiceMAN}" height="150" width="150" /></td>
		</tr>
		<tr>
			<td>Message:</td>
			<td>
			<apex:outputtext value="{!strMessage}"/>
			</td>
		</tr>
		<tr>
			<td>
			NoSolution/thisCase.IsClosed
			</td>
			<td>
			<apex:outputtext value="{!NoSolution}/{!thisCase.IsClosed}"/>
			</td>
		</tr>
		
	</table>			
	</apex:pageblock>
	</apex:form>
	
	<apex:tabPanel switchType="client" selectedTab="TestStepsTab"
			id="CaseTabPanel" tabClass="activeTab"
			inactiveTabClass="inactiveTab">
		<apex:tab label="Case Details" name="CaseDetailTab" id="tabCaseDetails">
			<apex:detail subject="{!thisCase.Id}" relatedList="false" title="true" id="CaseDetail" inlineEdit="true"/>
			<h3><apex:outputText value="{!NoSolution}"/></h3>
			<apex:relatedList subject="{!thisCase}" list="CaseSolutions" />
		</apex:tab>	
		<apex:tab label="Test Steps" name="TestStepsTab" id="tabTestSteps">
			<apex:pageBlock >
				<apex:pageBlockTable value="{!TestSteps}" var="Steps" id="StepsTaken">
					<apex:column HeaderValue="Contributor" value="{!Steps.CreatedBy.Name}"/>
					<apex:column HeaderValue="Contributed When" Value="{!Steps.CreatedDate}"/>
					<apex:column HeaderValue="Suggested Step" value="{!Steps.Step__c}" />
					<apex:column HeaderValue="Suggested When" value="{!Steps.Presented_When__c}"/>
					<apex:column HeaderValue="Result Reported" value="{!Steps.Result__c}"/>
					<apex:column HeaderValue="Reported When" value="{!Steps.Result_Returned_When__c}"/>
				</apex:pageBlockTable>
			</apex:pageBlock> 
		</apex:tab>
		<apex:tab label="Asset" name="AssetDetailTab" id="tabAssetDetails">
			{!NoAssetAttached}
			<apex:detail subject="{!thisCase.AssetId}" relatedList="false" title="true" inlineEdit="true" />
		</apex:tab>		
		<apex:tab label="Service" name="ServiceDetailTab" id="tabServiceDetails">
			{!NoServiceAttached}
			<apex:detail subject="{!thisCase.Service__c}" relatedList="false" title="true" inlineEdit="true"/>
		</apex:tab>		
	</apex:tabPanel>
	
	
	

</apex:page>

 

Here's the case extension markup:

 

public with sharing class CaseExtension {
	Public Case thisCase {get;set;}
	Private String strMessage{get;set;}
	Public String NoAssetAttached{get;set;}
	Public String NoServiceAttached{get;set;}
	Public String NoSolution {get;set;}
	List<Testing_Steps__c> TestSteps {get;set;}
	
	Public CaseExtension(ApexPages.StandardController stdController) {
		thisCase = (Case)stdController.getRecord();
		thisCase = [Select 
			id,
			AssetId,
			Asset.Name,
			Asset.SerialNumber,
			Service__c,
			Service__r.Classification__c,
			Subject,
			IsClosed
			from Case
			Where Id = :thisCase.Id
			];
		
		if (thisCase.AssetId == Null){
			NoAssetAttached = 'No Asset has been attached to this case.';
		} else {
			NoAssetAttached = '';
		}
		
		if (thisCase.Service__c == null){
			NoServiceAttached = 'This case is not attached to a service record.';
		} else {
			NoServiceAttached = '';
		}
	
		if (thisCase.IsClosed == False){
			NoSolution = 'Case is still open.  No Solutions to display' ;
		} else {
			NoSolution = '';	
		}
	}
	
	Public String getstrMessage(){
		return 'No Messages';
	}
	
	Public List<Testing_Steps__c> getTestSteps(){
		TestSteps = [Select id,
			CreatedById,
			CreatedBy.Name,
			CreatedDate,
			Step__c,
			Presented_When__c,
			Result__c,
			Result_Returned_When__c
			from Testing_Steps__c
			where Case__c = :thisCase.Id
			];
			
		return TestSteps;
	}
	
	Static testMethod void testCaseExtensionController(){
	    //create test data
	    
	    Account testAccount = new Account();
        testAccount.Name = 'ACME Missles Inc.';
        testAccount.ShippingStreet = '1313 Mockingbird Lane';
        testAccount.ShippingCity = 'Somecity';
        testAccount.ShippingState = 'CA';
        testAccount.ShippingPostalCode = '94105';
        testAccount.ShippingCountry = 'USA';
        testAccount.Site = 'Somecity';
        insert testAccount; 
	    
	    Contact testContact = new Contact();
        testContact.FirstName = 'Joe';
        testContact.LastName = 'Smuckatelli';
        testContact.AccountId = testAccount.Id;
        insert testContact;
         
        Asset testAsset = new Asset();
        testAsset.AccountId=testAccount.Id;
        testAsset.ContactId = testContact.Id;
        testAsset.Name = 'S-910 Test Asset';
        testAsset.SerialNumber = 'S12345';
        testAsset.Quote__c = 'Quote # ABCDEF';
        testAsset.Sales_Order__c = '987654';
        testAsset.Status = 'Not Shipped';
        insert testAsset;
         
        Case testCase = new Case();
        testCase.AccountId = testAccount.Id;
        testCase.ContactId = testContact.Id;
        testCase.AssetId = testAsset.Id;
        insert testCase;
         
        Service__c testService = new Service__c();
        testService.Account__c = testAccount.Id;
        insert testService;
         
		//Solution testSolution = new Solution(SolutionName = 'Test Solution', Status = 'New');
		//insert testSolution;

		ApexPages.StandardController c = new ApexPages.StandardController(testCase);
		CaseExtension testCon = new CaseExtension(c);
		ApexPages.CurrentPage().getParameters().put('id',testCase.Id);
		System.AssertEquals('No Messages',testCon.getstrMessage());
		
		List<Testing_Steps__c> testTestSteps = testCon.getTestSteps();

		testCase.Service__c = testService.Id;
		testCase.Status = 'Closed';
		update testCase;
		
		
		CaseExtension testCon2 = new CaseExtension(c);
		
	
	}
}

 

 

I'm using Eclipse to develop Apex code.  I was working on a pretty big controller directly in my production account (I know, I know...) and got a little behind on implementing the test routines.  Eventually the controller would no longer save to my server since the average test coverage dropped below 75%.  I was seeing this error in the 'Problems' window in Eclipse:

 

'Average test coverage across all Apex Classes and Triggers is 74%, at least 75% test coverage is required'  

 

I immediately stopped working on the controller and went back to implement test routines in this and a couple of the other controllers.  Now the controller will save but the error message persists even if I run tests from within Eclipse.  When I run tests directly in the UI I'm told the average coverage is 84%.

 

How can I 'clear' the error message from the Eclipse 'Problems' window? 

  • October 27, 2009
  • Like
  • 0

 

I have a field (Report_Filed__c) in a custom object (Service__c) that I want to insert a date stamp into.  I'm displaying the field in a page block on my VF form.  I have a button that sends out an email version of a report and then inserts the current date into the field.

 

After the email is sent, I use a pagereference in the controller to reload the page.  Unfortunately the newly updated information in the field does not display until I hit my browser's refresh button.

 

Can someone tell my why this is or how to fix it?

 

Here's the Code snippet from the page:  (the rerender in there doesn't fix the problem...)

<apex:form > <apex:pageblock Title="Hello {!$User.FirstName} {!$User.LastName}" id="TitleBlock"> <h1> Version 2.0 </h1><br /> The report was filed on: <apex:outputtext value="{!Service__c.Report_Filed__c}"/><br /> <apex:pageBlockButtons > <apex:commandButton action="{!submitReport}" value="Submit Report" rerender="TitleBlock"> </apex:commandButton> </apex:pageBlockButtons> </apex:pageblock> </apex:form>

 

 

 

Here's the controller:

 

 

public pagereference submitReport(){ //generate the email (code omitted for brevity...) Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail}); //insert the date into the field this.svc.Report_Filed__c = datetime.now(); update this.svc; PageReference editCase = new PageReference('/apex/service_detail_2?id='+this.svc.id); return editCase; }

 

 

Thanks for any insight you can provide...

 

  • March 19, 2009
  • Like
  • 0
I don't understand why I'm getting the error :
 
ErrorError: Unknown property 'MyOpenActivities.MyCasesToDo'
 
Here's the page code:
 
Code:
<apex:page controller="MyOpenActivities">
    <apex:form >
    <apex:pageblock Title="Hello {!$User.FirstName} {!$User.LastName}" id="TitleBlock">
        <h1> Version 1.0 </h1><br />
        Here are the lists for open Technical Support Activities that require your attention.<br />
        Open Cases, Service Activity and Demos.<br />
    </apex:pageblock>
    </apex:form>
    
    <apex:form >
    <apex:pageblock title="My Open Cases">
    
       <apex:pageBlockTable value="{!MyCasesToDo}" var="c">
        
        </apex:pageblocktable>
    </apex:pageblock>
    </apex:form>
</apex:page>

 
Here's the controller:
 
Code:
public class MyOpenActivities {

Public String CurrentUserId {get; set;}
Public List<Case> MyCasesToDo;

Public MyOpenActivities(){
 this.CurrentUserId=UserInfo.getUserId();
}

public List<Case> getMyCasesToDo(string CurrentUserId){
 List<Case> MyCasesToDo = new Case[]{};
 MyCasesToDo = [Select OwnerId, Subject, Status, Service__c, Priority, Origin, Id, Description, ContactId, Account.Name, AccountId From Case Where OwnerId = :CurrentUserId];
 return MyCasesToDo; 
}
 
Static testMethod void testThisController() {
 MyOpenActivities testController = new MyOpenActivities();
 string CurrentUserId=UserInfo.getUserId();
 testController.getMyCasesToDo(CurrentUserId);
 
}

}

 
I've done this exactly the same way on quite a number of other page/controllers.  Any idea why it's happening now?
 
  • September 26, 2008
  • Like
  • 0
I'm working to write tests for a controller and I can't seem to get coverage for a method that returns a PageReference.
 
Code:
public class CaseWizardController2 {
    Public String AcctSearch {get;set;}
    Public Account SelectedAccount {get;set;}
    
    Public PageReference clearSelections(){
        PageReference ClearSelections = new PageReference('/apex/casewizard1');
        ClearSelections.setRedirect(true);
        return ClearSelections;
    }


    static testMethod void testCaseWizard() { 
        CaseWizardController testWizard = new CaseWizardController();
  testWizard.clearSelections();
  System.AssertEquals('/apex/casewizard1',testWizard.ClearSelections().getURL());
        system.debug(logginglevel.INFO, 'Test Method>>>' + testWizard.ClearSelections().getURl());
    }
}

 
The code itself works fine.  I get no errors running the test method.  The System.AssertEquals doesn't bomb out but the results tell me I have no coverage for any of the lines in the ClearSelections method.
 
Does anyone know what I'm doing wrong here?
  • August 15, 2008
  • Like
  • 0
 
Code:
public class CaseWizardController {
    Public String AcctSearch {get;set;}
    Public String ContactSearch {get;set;}
    Public String snSearch {get;set;}
    Public String searchText;
    Public String tempText;
    Public Account selectedAccount {get; set;}
    Public Contact selectedContact {get; set;}
    Public Asset selectedAsset {get; set;}
    Public Integer matchingAssets;
    Public String CaseInit {get; set;}
        
    Public CaseWizardController() {
        this.AcctSearch = ApexPages.currentPage().getParameters().get('AcctSearch');
        tempText = ApexPages.currentPage().getParameters().get('asstId');
        if (tempText == null) {    
            tempText = ApexPages.currentPage().getParameters().get('cntid');
            if (tempText == null) {   
                tempText = ApexPages.currentPage().getParameters().get('acctId');
                if (tempText == null) {   
                } else {
                    reloadAccount();  
                }
            } else {
                searchText = tempText;  
                SelectContact();        
            }
            
        } else {
            selectAsset();        
        }
    }
    
    public String getCaseInit(){
     system.debug(logginglevel.INFO, 'CaseInit Method>>>' + selectedAsset.Name);
             
        if (selectedAsset==null) {        
         if (selectedContact==null){        
          CaseInit = '/apex/casewizard3';        
         } else {
          CaseInit = '/apex/casewizard3—cntId='+selectedContact.Id;        
         }
        } else {
            CaseInit = '/apex/casewizard3–asstId='+selectedAsset.Id;        
        }
       return CaseInit;        
     
    }
    
    
    Public PageReference gotoPage1(String ParamValue){
     PageReference Page1 = new PageReference('/apex/casewizard1'+ParamValue);
     Page1.setRedirect(true);
     return Page1;
    }
        
    static testMethod void testCaseWizard() { 
        CaseWizardController testWizard = new CaseWizardController();
        
        Asset selectedAsset=[Select Warranty_End_Date__c, Status, Ship_Date__c, Sales_Order__c, Name, Id, ContactId, AccountId, SerialNumber From Asset where serialnumber = '2' Limit 1];
        testWizard.gotoPage1('˜asstId='+selectedAsset.Id);
        system.debug(logginglevel.INFO, 'Test Method>>>' + selectedAsset.Name);
        testWizard.getCaseInit();
    }
        

}

Can someone help?  I must be missing something here.  When I run tests on the above controller, it bombs whenever I try to access the variable selectedAsset.  I can't seem to instatiate the variable within the main controller.  The test method sets the variable using a query.  I can see the variable in the debug window.  I'm calling a pagereference and passing an Asset ID to the main controller so why is selectedAsset null when I try to run getCaseInit?
 
In general I'm having trouble settting variables when running my test methods so most of my code that requires variables to be set are not covered.  It's not just the sObject variables.  I'm also having trouble setting parameters that are normally set on the page and passed to the controllers.
 
Can anyone see what I'm missing?
 
Please help.
  • August 14, 2008
  • Like
  • 0
I'm having trouble returning back to the correct page using the retURL parameter.  Here's the function from a customer controller extension that is triggered from a button on a VF page.
 
Code:
 public pagereference createInstall(){
  Service__c tempService = new Service__c();
  tempService.Account__c = this.myAsset.AccountId;
  tempService.Contact_1__c = this.myAsset.ContactId;
  tempService.Description__c = 'INST SO '+this.myAsset.Sales_Order__c;
  tempService.Classification__c = 'New Installation';
  tempService.RecordTypeId = '01230000000DMrlAAG';
  tempService.Start_Date__c = this.myAsset.Target_Ship__c+14;
  tempService.SO__c = this.myAsset.Sales_Order__c;
  tempService.PO__c = this.myAsset.Purchase_Order__c;
  tempService.Quote__c = this.myAsset.Quote__c;
  tempService.Stage__c = 'Not Shipped';
  insert tempService;
  
  
  Link__c tempLink = new Link__c();
  tempLink.Asset__c = this.myAsset.Id;
  tempLink.Service__c = tempService.Id;
  insert tempLink;
  
  PageReference editService = new PageReference('/'+tempService.Id+'/e?retUrl=https://cs2.salesforce.com/'+this.myAsset.Id);
  editService.setRedirect(true);
  return editService;
  
 }

 
This 1st chunk creates a new Service Record (custom object).  The second chunk inserts a record linking the new service to an Asset.  The final 3 lines call up the service edit page so the user can review the new record.  After saving (or cancelling) I would like the user to be returned back to the asset detail page.
 
Passing the retURL should take the user back to the Asset detail page (which is where this code is triggered from).  This is the only part of the code that fails.  The service record gets created just fine, the link gets created just fine, the Service Edit screen opens just fine but when the user clicks 'Save' on that screen they are returned to the SF home page instead of the asset detail screen.
 
I have tried both methods of including the full server address (https://cs2.salesforce.com/recordId) and also the partial method (/recordId).  Both methods return the user to the home page.
 
Anyone know what I'm doing wrong?
  • August 01, 2008
  • Like
  • 0
I've created a VF page using standard components.  I would like to email a report based on the page design.  I've hunted for a method to pull the individual page components and add them to the Apex email HTML body.  Is there any way to do that?
I thought the Input Text object was for referencing class variables instead of object fields.
 
This code seems to work OK since Service__c.Name is a field in my custom object called Service:
 
<apex:inputText value="{!Service__c.Name}" id="ReplyTo_Address"/>
 
This one fails:
 
<apex:inputText value="{!emailToAddress}" id="emailToAddress"/>
 
I have created the appropriate getter method in the controller but when I try to save this page I get the error:
 
Error: Read only property 'ServiceControllerExtension.emailToAddress'
 
Here's the getter code from the controller extension:
 

public String getemailToAddress(){

emailToAddress = 'jbud@company.com';

return emailToAddress;

}

Any Ideas?
 
OK, here's about as general of a problem as I can think of.  I have a custom object in SF called Service that tracks field service work needing to be done.  It's linked to the Account object and also contact.  This allows me to schedule and track field service work.  I've created a one-to-many link to the case module to track cases identified during the service event.
 
I need to be able to output a report on a single service record with all its associated cases.  This would be used for example to send back to the customer as a report on what was done and what cases were found.  Ideally this would be integrated into a custom button to be added to the service page layout so that when the field engineer finishes the work, he clicks the button and the report gets generated and sent.  I can't find any way to grab that service record and all the cases and combine them.  It seems the Word mail merge system is limited with the multiple records coming from the case module.  This also is the case for the email alert system.
 
I'm open to using an S-control or the work flow rules into an email or merging into a word doc or any way to output this information.  Has anyone encountered a similar problem?
  • February 03, 2007
  • Like
  • 0
I see the Office Toolkit does not yet support all the wonderful functionality of the new API 8.0.  Does anyone know when/if that will change?
  • January 16, 2007
  • Like
  • 0
OK, this is driving me crazy!  Maybe I'm doing something stupid but please help if you can.
 
No matter what I do with my query string, it ALWAYS returns ALL the fields.  I thought the 'where' clause was going to be the challenge!
 
I'm running the following query:
 
Set qr = ThisWorkbook.cSFComm.Query("Select CreatedByID, CreatedDate, FirstName, Id From Contact", False)
 
I then loop through this code:

For Each s In qr
    For x = 1 To 25
         MsgBox s.Fields(x).Name
    Next x
Next s
 
And can frustratingly watch it show me each and every field name from the table!
  • December 11, 2006
  • Like
  • 0

I'm working on being able to translate a part number (stored as a string) from one extenal system to another.  I have a custom table setup each record will have both part numbers and would like the user to be able to enter either number and have SF provide the other.  If a number is not found in the table, query an external system (using HTTP callout) to retrieve it then save it in the table so future requests for the same number don't have to callout to the external system (essentially add records on the fly).

Here's the flow:  user enters a part number from system A.  This field is a string.  Apex queries the custom table to see if it is saved.
 

List<Part__c> p = new List<Part__c>();
p = [Select Return__c, Regional_Scrap__c, Return_Factory__c, Factory_Approval__c, Name, Description__c, SAP_Number__c From Part__c Where Name = :li.Part_Number__c];

First time part number is used, the query will return 0 records [p.size()=0].  Apex will then use the HTTP callout to query the external system to get the other part number.  Callout is working fine.  Response gets parsed into a List<String> and the field value set.

HTTPResponse res = http.send(req);
bodyval = res.getBody();
list<string> dfresults = bodyval.split('\t', 10);
li.SAP_Number__c = dfresults[4];

The other number looks fine after the parsing and setting the field value.  Since the initial query returned no records (as expected) I then copy save the data into the table (so future need doesn't result in another callout to the external system)

Part__c Prt = new Part__c();
Prt.Name = li.Part_Number__c;
Prt.SAP_Number__c = li.SAP_Number__c;
insert Prt;

This is working.  I can see the new part in the table (on the tab using a list view).

NOW, i want to translate this number back the other way.  So I provide the SAP Number and query the Part table expecting to find the record that was just saved.

p = [Select Return__c, Factory_Approval__c, Regional_Scrap__c, Return_Factory__c, Description__c, Name, SAP_Number__c From Part__c Where SAP_Number__c = :li.SAP_Number__c];

Unfortunately this query ALSO returns 0 records so the loop continues and since "It didn't find the record" it adds it a second time and now I have 2 records.  it will not create any additional records.  If I repeat the second part and ask for hte SAP number, it will return the second record that was created.  I can even delete the intial record (created from the HTTP callout) and will not create a second record.

So my question is, any idea why the query after the initial record is created returns 0???



 



 

  • August 13, 2014
  • Like
  • 0

I'm trying to deploy a package from one sandbox to another and get a failure message:

 

Cannot deploy InstalledPackage in Package Manifest with any other types!

 

I'm using Eclipse version Helios Service Release 1 along with the Spring 2013 version of Force.com IDE.

 

Any clue what's going on?

 

Thanks.

 

Help!  Please!

 

I've been using the Office Toolkit version 3 for years to query information from SF into an Excel spreadsheet.  Just recently I'm seeing an error:

 

Microsoft Visual Basic

Run-time error '-2147467259 (80004005)':

 

An internal server error has occured while processing your request.

Url:https://na6-api.salesforce.com/services/Soap/c/13.0/00D300000006bcc

 

 This does not appear to be a connection issue.  The code will login the user in with no error.  it then runs a successful query to get contacts and then another query to get some information from a related table and then a query to get a list of opportunities associated with the selected contact.  Once the chosen opportunity is selected, it then attempts to get some detail about the opportunity.  That is the specific query where it bombs with this error.

 

The specific line of code is:

 

Set qr = cSFComm.Query(sQueryString, False)

 

This same exact specific line is the same one all of the other queries has passed through to get query results.

 

This particular query string is:

 

Select Id, OwnerId, Distributor_or_Sales_Representative__c, Purchase_Order_Num__c, Sales_Order_Number__c, Quote_Num__c, Target_Ship_Date__c, Market_Level_1_Industry__c, Market_Level_2_Application__c, Market_Level_3_Substrate__c, Market_Level_4_End_Use__c, Valve__c, Name From Opportunity Where id = '0068000000i7IwbAAE'

 

I tried upgrading to toolkit version 4 but get the exact same issue.

 

Anyone have any ideas?

  • February 15, 2013
  • Like
  • 0

I have a VF page showing multiple custom objects with related lists.  (Lists within lists actually).  I have enabled inline edit for all of the fields and it works great.  Double click the field, edit, click save.  Save, cancel and new buttons all show and hide as expected.

 

My challenge is when inserting new records.  I do NOT want to go the standard object detail screen to enter the information into the fields.  (multiple linked and nested objects/lists means a lot of 'bouncing' back and forth that I want to avoid the user getting lost in.  I would like for them to stay on the same page essentially inserting the record directly into the list).

 

My 'New' button adds a record to the list which adds and displays the new record properly.  It has default text instructing the user to double click to edit.  I would rather have the newly created record show up already 'in' inline edit mode.

 

Does anyone know of a way to initiate in-line edit mode without requiring the user to click or double click somewhere?  I'm open to solutions either from the VF page doing it or the controller...

 

Thanks for listening (or reading...)

  • October 23, 2012
  • Like
  • 0

I have a VF page that is currently in the page layout under the standard "Lead Status" field in SF. I am replicating this field with a VF page that has the drop-down for edit directly in view, since we need our reps to easily change the Status field on their iPads (because in-line editing does not work on iPads). 

 

I need the VF page field name, the dropdown, and the save button all appear in one row, and have the field name directly line up to where all other left-hand column fields align in SF record pages. The VF page currently puts the start of the field name all the way at the edge of the record, unaligned with other field names.

 

What do I need to change to get this to align correctly, and appear all on one row?

 

Here is the VF page:

<apex:page standardcontroller="Lead" extensions="TestLeadCancel">
    <apex:form >
    <apex:outputPanel id="reloadPanel" rendered="{!reloadNeeded}" >
            <script type="text/javascript">
                // redirect the top level window
                window.top.location.href = '{!pageURL}';
            </script>   
        </apex:outputPanel>
        <h2>Lead Status</h2>
           <apex:inputhidden value="{!Lead.Id}"/>
           <apex:inputfield value="{!Lead.Status}"/>
           <apex:commandbutton value="Save" action="{!Save}"/>
    </apex:form>
</apex:page>

 

Here is the class:

public class TestLeadCancel {
    
    ApexPages.StandardController sc = null;
    Lead ld;
    
    public String pageUrl {set;}
    public Boolean reloadNeeded {get; set;}
      
    public TestLeadCancel(ApexPages.StandardController ctlr)  
    {  
       sc = ctlr;
       ld = (Lead) ctlr.getRecord();                 
    }  
    
    public String getPageUrl() {
        PageReference pr = new ApexPages.StandardController(ld).view();
        return pr.getUrl();
    }
             
    public PageReference save()  
    {  
        ld = (Lead) sc.getRecord();
        update ld;        
        reloadNeeded = true;
        return null;            
    }
    
    public PageReference cancel()
    {
        ld = (Lead) sc.getRecord();
        reloadNeeded = true;
        return null;        
    }      
}

 

  • October 10, 2012
  • Like
  • 0

public class AllNewWelcomeLetter{

List<mbMemberAC__c> memberac;

public AllNewWelcomeLetter() {

}

List<Attachment> att;

public PageReference savePdf() {

memberac=[select id,MEnrollmentDate__c,Member_A_C_Client_name__c,Member_Chinese_Name__c,PRIVE_ADDR1__c,PRIVE_ADDR2__c,PRIVE_ADDR3__c,PRIVE_ADDR4__c,name from mbMemberAC__c where WelcomeLetterSenton__c=:null and MEnrollmentDate__c!=:null and MemberStatus__c=:'Active' ];

if(memberac.size()>0){

for(mbMemberAC__c mem:memberac){
//search the pdf name from attachment and judge if the old name is same as the new pdf name,pdf in present memAC is unique
att=[select Name from Attachment where ParentId =:mem.id and name=:mem.Member_A_C_Client_name__c+'.pdf'];

if(att.size()==0){

PageReference pdf = Page.WelcomeLetterForEach;

pdf.getParameters().put('id',mem.id);

Attachment attach = new Attachment();

// the contents of the attachment from the pdf
Blob body;

try {
// returns the output of the page as a PDF
body = pdf.getContent();

// need to pass unit test -- current bug
} catch (VisualforceException e) {
body = Blob.valueOf('Some Text');
}

attach.Body = body;
attach.Name = mem.Member_A_C_Client_name__c+'.pdf';
attach.IsPrivate = false;
// attach the pdf to the account
attach.ParentId =mem.id;
insert attach;

mem.WelcomeLetterSenton__c=date.today();
update mem;
}
}
}else{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, '(error):The object memshipAC is null!');
ApexPages.addMessage(myMsg);
return page.WelcomeLetterPage;

}

return page.ListMembershipAC;
}

}

if i change the number 100 into 10 or less in method savePDF() , then it's ok! otherwise ,there will be the error message occurred,can you tell me how can i solve it. thank you very much!! 

 
  • May 09, 2012
  • Like
  • 0

I recently upgraded my Force.com IDE (and all projects) to the Winter '12 release. Since upgrading, I've been observing that when I attempt to run unit tests against an Apex class, it often takes a very long time to execute. Even relatively simple tests sometimes take a minute or two to complete. The time doesn't seem to be spent during test execution, but rather during the "preparing results..." phase (based on the progress indicator in the IDE). Reducing the log level doesn't seem to have any impact one way or the other. I've also seen it simply get stuck in the "preparing results..." phase to the point where I had to kill the Eclipse process. Anyone else seeing this?

  • January 04, 2012
  • Like
  • 0

Hi,

 

I have a Configuration sandbox and I want to write a trigger to post to chatter groups.  I created the group in PROD and then refreshed the sandbox.  After it was activated, it shows no groups.  So I tried to create the group by hand using the same name and it gives me an error that the group already exists or is in the process of being deleted.

 

I used the dataloader to dump the CollaborationGroup object's data and tried uploading that into the sandbox.  I got errors on all the entries.

 

Others are doing what I'm trying to do.  Surely they must have developed in sandboxes?

 

Let me know if there's some dumb mistake I'm making.

 

Everyone,

 

A month ago, I opened a ticket with SFDC support for inconsistent behavior with command links in pageblocktables.   They have confirmed the issue but still don't have a resolution.

 

So, I was wondering if this effected anyone else.    Anyone else seen a command link fail to call a method in some situations but call that same method just fine in other siutations on the same page?

 

I want to clarify that the command link code is the same in the VF page as it is in a page block table.  However, some times individual rows in the table call the command link upon click but others do not.

 

Thanks

I've created a VF page to replace the standard case detail page that uses tabs to show related records from related objects (Assets, Service__c).  I would like to show the case team on it's own tab but I can't seem to get the relationship name.  Everything I try returns the dreaded "'XXXXXX' is not a valid child relationship name for entity Case".

 

My code is pretty simple:

 

		<apex:tab label="Team" name="TeamList" id="tabTeamList">
			<apex:relatedList subject="{!thisCase}" list="TeamMembers" />
		</apex:tab>	

 I used Eclipse schema browser to get to relationship name "TeamMembers", I also tried the child relationship "TeamTemplateRecords" but get the same error. 

 

I did search the forums and about the only suggestion was to ensure the related list is present on the standard detail page which I've done.

 

Does anyone know what relationship name to use?

  • August 04, 2011
  • Like
  • 0

Does anyone know why this page references the wrong object?

 

I've created a VF page to replace the default Case Detail page so I can add an extension controller.  We have linked the Asset object to Cases and also the Service object (a custom object) to Cases.

 

When this new detail page loads I expected the header to show the Case icon typically used and the name of the case.  Instead it shows the Service Icon with the name of the service that is attached to the case.  If I remove the Service from the case the header shows the asset instead.  It's very confusing for the user.  (I can't figure out how to post a screen capture in here...)

 

Here's the code for the page which clearly references the Case standard controller AND uses the tabStyle Case.

 

<apex:page standardcontroller="Case" extensions="CaseExtension" tabStyle="Case">
<!-- https://na6.salesforce.com/apex/case_escalation?id=50080000006nANlAAM -->
	<style>
		.activeTab {background-color: #236FBD; color:white;
			background-image:none}
		.inactiveTab {background-color: lightgrey; color:black;
			background-image:none} 
	</style>
	<apex:form >
	<apex:pageblock Title="Hello {!$User.FirstName} {!$User.LastName}" id="TitleBlock">
	<table border="3">
		<tr>
			<td colspan="2"><h1>Version 1.0</h1><br />
			<font color="blue">1.0 Initial Release</font><br />
			This is a new Case Detail Screen showing details about the associated service and asset.<br />
			It will also be the launching point for escalating cases.<br />
			<br />
			Please provide feedback regarding this page to:
			<apex:outputLInk value="mailto:barnold@nordson.com">  Brett Arnold</apex:outputLInk><br /><br />
			</td>
			<td rowspan="3">Instructions:<br />
			To be added.<br />
			</td>
			<td rowspan="3"><apex:image url="{!$Resource.ServiceMAN}" height="150" width="150" /></td>
		</tr>
		<tr>
			<td>Message:</td>
			<td>
			<apex:outputtext value="{!strMessage}"/>
			</td>
		</tr>
		<tr>
			<td>
			NoSolution/thisCase.IsClosed
			</td>
			<td>
			<apex:outputtext value="{!NoSolution}/{!thisCase.IsClosed}"/>
			</td>
		</tr>
		
	</table>			
	</apex:pageblock>
	</apex:form>
	
	<apex:tabPanel switchType="client" selectedTab="TestStepsTab"
			id="CaseTabPanel" tabClass="activeTab"
			inactiveTabClass="inactiveTab">
		<apex:tab label="Case Details" name="CaseDetailTab" id="tabCaseDetails">
			<apex:detail subject="{!thisCase.Id}" relatedList="false" title="true" id="CaseDetail" inlineEdit="true"/>
			<h3><apex:outputText value="{!NoSolution}"/></h3>
			<apex:relatedList subject="{!thisCase}" list="CaseSolutions" />
		</apex:tab>	
		<apex:tab label="Test Steps" name="TestStepsTab" id="tabTestSteps">
			<apex:pageBlock >
				<apex:pageBlockTable value="{!TestSteps}" var="Steps" id="StepsTaken">
					<apex:column HeaderValue="Contributor" value="{!Steps.CreatedBy.Name}"/>
					<apex:column HeaderValue="Contributed When" Value="{!Steps.CreatedDate}"/>
					<apex:column HeaderValue="Suggested Step" value="{!Steps.Step__c}" />
					<apex:column HeaderValue="Suggested When" value="{!Steps.Presented_When__c}"/>
					<apex:column HeaderValue="Result Reported" value="{!Steps.Result__c}"/>
					<apex:column HeaderValue="Reported When" value="{!Steps.Result_Returned_When__c}"/>
				</apex:pageBlockTable>
			</apex:pageBlock> 
		</apex:tab>
		<apex:tab label="Asset" name="AssetDetailTab" id="tabAssetDetails">
			{!NoAssetAttached}
			<apex:detail subject="{!thisCase.AssetId}" relatedList="false" title="true" inlineEdit="true" />
		</apex:tab>		
		<apex:tab label="Service" name="ServiceDetailTab" id="tabServiceDetails">
			{!NoServiceAttached}
			<apex:detail subject="{!thisCase.Service__c}" relatedList="false" title="true" inlineEdit="true"/>
		</apex:tab>		
	</apex:tabPanel>
	
	
	

</apex:page>

 

Here's the case extension markup:

 

public with sharing class CaseExtension {
	Public Case thisCase {get;set;}
	Private String strMessage{get;set;}
	Public String NoAssetAttached{get;set;}
	Public String NoServiceAttached{get;set;}
	Public String NoSolution {get;set;}
	List<Testing_Steps__c> TestSteps {get;set;}
	
	Public CaseExtension(ApexPages.StandardController stdController) {
		thisCase = (Case)stdController.getRecord();
		thisCase = [Select 
			id,
			AssetId,
			Asset.Name,
			Asset.SerialNumber,
			Service__c,
			Service__r.Classification__c,
			Subject,
			IsClosed
			from Case
			Where Id = :thisCase.Id
			];
		
		if (thisCase.AssetId == Null){
			NoAssetAttached = 'No Asset has been attached to this case.';
		} else {
			NoAssetAttached = '';
		}
		
		if (thisCase.Service__c == null){
			NoServiceAttached = 'This case is not attached to a service record.';
		} else {
			NoServiceAttached = '';
		}
	
		if (thisCase.IsClosed == False){
			NoSolution = 'Case is still open.  No Solutions to display' ;
		} else {
			NoSolution = '';	
		}
	}
	
	Public String getstrMessage(){
		return 'No Messages';
	}
	
	Public List<Testing_Steps__c> getTestSteps(){
		TestSteps = [Select id,
			CreatedById,
			CreatedBy.Name,
			CreatedDate,
			Step__c,
			Presented_When__c,
			Result__c,
			Result_Returned_When__c
			from Testing_Steps__c
			where Case__c = :thisCase.Id
			];
			
		return TestSteps;
	}
	
	Static testMethod void testCaseExtensionController(){
	    //create test data
	    
	    Account testAccount = new Account();
        testAccount.Name = 'ACME Missles Inc.';
        testAccount.ShippingStreet = '1313 Mockingbird Lane';
        testAccount.ShippingCity = 'Somecity';
        testAccount.ShippingState = 'CA';
        testAccount.ShippingPostalCode = '94105';
        testAccount.ShippingCountry = 'USA';
        testAccount.Site = 'Somecity';
        insert testAccount; 
	    
	    Contact testContact = new Contact();
        testContact.FirstName = 'Joe';
        testContact.LastName = 'Smuckatelli';
        testContact.AccountId = testAccount.Id;
        insert testContact;
         
        Asset testAsset = new Asset();
        testAsset.AccountId=testAccount.Id;
        testAsset.ContactId = testContact.Id;
        testAsset.Name = 'S-910 Test Asset';
        testAsset.SerialNumber = 'S12345';
        testAsset.Quote__c = 'Quote # ABCDEF';
        testAsset.Sales_Order__c = '987654';
        testAsset.Status = 'Not Shipped';
        insert testAsset;
         
        Case testCase = new Case();
        testCase.AccountId = testAccount.Id;
        testCase.ContactId = testContact.Id;
        testCase.AssetId = testAsset.Id;
        insert testCase;
         
        Service__c testService = new Service__c();
        testService.Account__c = testAccount.Id;
        insert testService;
         
		//Solution testSolution = new Solution(SolutionName = 'Test Solution', Status = 'New');
		//insert testSolution;

		ApexPages.StandardController c = new ApexPages.StandardController(testCase);
		CaseExtension testCon = new CaseExtension(c);
		ApexPages.CurrentPage().getParameters().put('id',testCase.Id);
		System.AssertEquals('No Messages',testCon.getstrMessage());
		
		List<Testing_Steps__c> testTestSteps = testCon.getTestSteps();

		testCase.Service__c = testService.Id;
		testCase.Status = 'Closed';
		update testCase;
		
		
		CaseExtension testCon2 = new CaseExtension(c);
		
	
	}
}

 

 

I'm using Eclipse to develop Apex code.  I was working on a pretty big controller directly in my production account (I know, I know...) and got a little behind on implementing the test routines.  Eventually the controller would no longer save to my server since the average test coverage dropped below 75%.  I was seeing this error in the 'Problems' window in Eclipse:

 

'Average test coverage across all Apex Classes and Triggers is 74%, at least 75% test coverage is required'  

 

I immediately stopped working on the controller and went back to implement test routines in this and a couple of the other controllers.  Now the controller will save but the error message persists even if I run tests from within Eclipse.  When I run tests directly in the UI I'm told the average coverage is 84%.

 

How can I 'clear' the error message from the Eclipse 'Problems' window? 

  • October 27, 2009
  • Like
  • 0

When I create a new Force Project I donot get the 'Choose Initial Project Contents' form that I see in all documentation which shows 'Selected Metadata components' as an option.

 

The form I get is entitiled 'Create Newe Force.com Project' and it offers the following options

 

- All packaged components and default unpackaged components

- Contents of package

- Custom unpackaged component types

- none

 

I am using Eclipse SDK version 3.3.2. I am able to attach to projects, refresh form server, deploy etc, but I an perplexed as to why I get a different version of this screen that what I see in the Salesforce documention and online content.

 

Any Ideas?

  • February 04, 2009
  • Like
  • 0