• BBeaird
  • NEWBIE
  • 103 Points
  • Member since 2011

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 21
    Questions
  • 47
    Replies

Hello everyone,

 

We are trying to use the new API Salesforce made available during Winter '13: Test.setMock.

We followed the documentation, but encountered the following issue that we were unable to resolve: a System.CalloutException, complaining that we had "uncommitted work pending".

 

Of course we do, our testmethod starts by setting up some Test Data that's necessary for the test to work, and that includes inserting and updating data.

In an actual execution, there would be no data creation, as the data would already be present. Actually doing the callout doesn't raise the Uncomitted work pending exception, so the Test Data really is at fault.

 

We did use Test.startTest() and Test.stopTest() to differentiate Test Data creation from Test Execution but this (as expected) didn't work.

We also tried some hacks, including the System.runAs(new User( Id = UserInfo.getUserId()){} that had, in the past, allowed us to circumvent "Mixed DML operations". This didn't work either.

 

We considered using the Test.loadData method, but we're inserting related objects and couldn't figure out a clean enough way to make it work (maybe we should try using ExternalID's?).

 

 

For the moment, our workaround is to modify the class generated from the WSDL, adding a if (Test.isRunningTest()) {} else {}, but that means we have to modify the autogenerated code, which is suboptimal.

 

 

Did anyone try to use this new API and run into the same issue? How did you solve it?

I have many Apex classes generated from WSDLs. I am using mock webservices to test my other classes, which call those generated classes. However, all of my generated classes show as 0% covered. I know for a fact that they are succesfully being called in the tests.

 

This was not always the case - I know they used to show a percentage as recently as last Fall. Is anyone else experiencing this? We should not have to write separate (and useless) test methods to simply instantiate methds in those generated classes.

I'm doing a callout to a webservice that results in me getting a PDF file. The trick is the response contains some XML first followed by the PDF binary in an "attachment." I can't seem to figure out how to get Apex to reliably separate out just the binary bit. I also have not control over the webservice, so I can't just have them send me only the binary file. All the documentation I've found only applies for converting an HTTP resonse body directly into a blob, which won't work for me because I need the blob to ignore on the non-binary stuff at the beginning of the request. How can Salesforce handle xml attachments like this?  I've also tried just base64 encoding the entire response into a string, but I can't figure out how to reliably parse down to just the PDF section.

 

If I do a test via  SoapUI, this is the XML view:

 

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:Respons>
         <Result>
            <ResponseXML><![CDATA[<RESPONSE>
            <DOCS_FOUND>1</DOCS_FOUND>
            <DOCS_EXTRACTED>1</DOCS_EXTRACTED>
                 </RESPONSE>]]></ResponseXML>
            <StatusXML>&lt;STATUS>SUCCESS&lt;/STATUS></StatusXML>
            <Documents>
               <IndexDetails/>
               <FileAttachmentList>
                  <FileName>12345.pdf</FileName>
                  <Attachment>
                     <xop:Include href="cid:12345@example.jaxws.sun.com" xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
                  </Attachment>
               </FileAttachmentList>
            </Documents>
         </Result>
      </ns2:DocDNAExtractResponse>
   </S:Body>
</S:Envelope>

 

 

Here's the raw view (the binary I care about starts at the %PDF-1.4 line):

 

HTTP/1.1 200 OK
Date: Tue, 19 Feb 2013 14:04:29 GMT
Transfer-Encoding: chunked
Content-Type: multipart/related;start="<rootpart*e488a5c6-7989-44e0-85d8-2b25c6d0fbb8@example.jaxws.sun.com>";type="application/xop+xml";boundary="8";start-info="text/xml"
Set-Cookie: JSESSIONID=tGv1R!-1853; path=/; secure; HttpOnly
X-Powered-By: Servlet/2.5 JSP/2.1

--uuid:e488a5c0fbb8
Content-Id: <rootpart*e4fbb8@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:DocResponse xmlns:ns2="http://mysite/"><Result><ResponseXML>&lt;RESPONSE>&#xd;
&lt;DOCS_FOUND>1&lt;/DOCS_FOUND>&#xd;
&lt;DOCS_EXTRACTED>1&lt;/DOCS_EXTRACTED>&#xd;
&lt;/RESPONSE>&#xd;
</ResponseXML><StatusXML>&lt;STATUS>SUCCESS&lt;/STATUS></StatusXML><Documents><IndexDetails></IndexDetails><FileAttachmentList><FileName>0001.pdf</FileName><Attachment><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:12cd3@example.jaxws.sun.com"/></Attachment></FileAttachmentList></Documents></Result></ns2:DocResponse></S:Body></S:Envelope>
--uuid:e488a5c6-7989-44e0-85d8-2b25c6d0fbb8
Content-Id: <12c5bcf4-441c-4a5d-910a-3181fafc4dd3@example.jaxws.sun.com>
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

%PDF-1.4
%âãÏÓ
4 0 obj <</Length 6778/Filter/FlateDecode>>stream
<<Lots more PDF binary stuff after this part>

 

I've been banging my head against the wall trying to customize the exception page. I created my own and pointed my site to use it as the exception error page. I modified it so that it should apply my SiteTemplate to it. However, whenever an exception occurs, it still just displays the out of the box "Error: Error occurred while loading a Visualforce page." message with the standard Force.com styling, which we definitely do not want for our branded customer site. 

 

I noticed that if I don't have it apply my SiteTemplate and then really water it down to essentially just text, then it finally displays that text without the Force.com styling and message. But as soon as I start adding components or anything else, it reverts back to the Salesforce styling.

 

Also, if navigate directly to /apex/<myexceptionpage>, the styling works perfectly. It's just when I hit an actual exception and get directed to it that the styling breaks on me.

 

 

How do I get around this? I really don't want my exception page showing that styling/message...

Maybe I'm missing something here, but it seems like I can't do anything to make my custom site template apply to the Visualforce exception page. I've even created my own exception page and pointed my site to use it, but anytime I hit an exception, I get the ugly Force.com branded "Error: Error loading Visualforce page" message. Has anyone else had issues with trying to customize the exception page with a template?

We are developing a new site that will be used by both Customers and Partners. For now, the functionality is the same and both users will be seeing the exact same pages. However, because their license types are different, one uses a site associated with customer portal and the other uses a site associated with the partner portal.

 

Is there no way to consolidate these into a single login page such that if I can detect which users are partners, I could then direct their login to go through the partner site? We really don't want to have two separate login URL's...

When executing a test method (using API version 24.0), I am getting this error:

Internal Salesforce Error: 883366085-8175 (-1490970800) (-1490970800).

 

I have isolated the problem to this section of code that attempts to multiply a currency value (stored in a custom setting):

double chinaRate = [SELECT conversionrate FROM currencytype WHERE isocode = 'CNY'].conversionRate;
VL_CountrySettings__c countrySetting = new VL_CountrySettings__c();
countrySetting.Name = 'us';
countrySetting.Allowance__c = 40.00; //This is a currency field
insert countrySetting;

VL_CountrySettings__c usSettings = VL_CountrySettings__c.getInstance('us');
decimal allowance_value = chinaRate * usSettings.Allowance__c; //This line causes the error

 

If I run that exact same code anonymously (without the insert because the record is accessible when not testing), it runs fine without error.

 

Any ideas why I'm getting this strange error and only in a test method? I also opened a case and am waiting on a response.

I'm trying to get SSO working with mobile and the Outlook plugin. We're using Ping Federate for our idp. The wiki documentation states that all Salesforce needs is to be passed the RelayState parameter. Does anyone know what's involved to get this working? For whatever reason, RelayState is not coming back as a parameter with the SAML assertion.  I have our idp URL set in the "IDP Login URL" field in the Salesforce SSO settings, and I can tell during the redirect that RelayState is getting passed from Salesforce.

 

Has anyone gotten this working with Ping?

I've seen several pieces of documentation and forums posts indicating that passing the RelayState POST parameter  through the SSO process back to Salesforce will enable users to dynamically be redirected to the desired page. This is also necessary for using mobile with SSO in combination with using a My Domain URL (http://wiki.developerforce.com/page/Single_Sign-On_for_Desktop_and_Mobile_Applications_using_SAML_and_OAuth).

 

I know the POST to my identify provider (Corporate Ping Instance) is working. Now, the team who managed our Ping config are having trouble figuring out how to configure Ping to pass the RelayState back through to Salesforce. Does anyone have any experience doing that with Ping or with other provider software? Since I've never worked with it and don't have access, I'm having trouble giving them some direction on how they can give me what I need.

We have had Federated SSO set up for awhile now in our production org. I would like to set it up in at least one of our sandboxes as well. Is there any way to do this without having our IDP admins maintain separate endpoints for each sandbox? We are using My Domain, so it seems like the SAML Assertion would need to be pretty specific to each one and as far as I can tell does not have a way to dynamically forward users to the desired sandbox. It would be even better if production and sandbox orgs could point to the same SSO url, but it seems like that is even less likely.

 

Any thoughts on this? Is anyone else using SSO across multiple environments?

We are starting development on a new customer portal.  Our users will be High-Volume Portal users. Our requirements for granting record access are beyond what the built-in sharing wizards can handle, so we were advised to use apex managed sharing instead.  The problem is that when we have tried doing inserts into share tables (either standard of custom objects), we're getting this error:

 

System.DmlException: Insert Failed. First Exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, User/Group ID: id value of incorrect type: --3Z0000006vM70IAU: [UserorGroupId]

 

This was the code used:

 

AccountShare accountShare = new AccountShare();
accountShare.AccountId = '001Z00000078hL1';
accountShare.AccountAccessLevel = 'Edit';
accountShare.OpportunityAccessLevel = 'Edit';
accountShare.UserOrGroupId = '003Z0000006vM7O';
insert accountShare;

 

This error seems to be telling me that you can't use apex to share records with high volume portal users. If we can't do this, I do not know how else we will be able to provide customers with the access they need. I have read over the limitations at https://login.salesforce.com/help/doc/en/customer_portal_about_HVPUs.htm, but those do not explicitly rule out apex managed sharing.

 

 

We will not be using the out of the box customer portal.  Ours will be 100% custom apex and visualforce. Our main objects are Account, Asset, Contract (a custom object referencing Account), and Payment (a custom object referencing contract) .  We need the ability for users to view contracts from other accounts other than the account they are listed as a contact under. This is a core use case for us. We also need users to be able to view records from the Payment object that are related to any contract they have access to. The portal sharing wizards do cover these use cases - all they do is give the user access to objects directly related to the account under which they are a contact.

 

Any suggestions for how to do this sharing would be greatly appreciated.

Is there any good way of refreshing a sandbox from production without totally losing anything in that sandbox that hasn't yet been pushed to production?  Something like a merge rather than a total ovewrite?

 

We have a sandbox that has a long-running project going on.  There is also a second sandbox used for more short-term changes.  The latter sandbox has its changes deployed to production once a month or so.  We like to keep our sandboxes refreshed from production pretty frequently, so we would like to refresh the first sandbox with the long-running project after production is updated.  However, if we do that, we'll lose all the changes for the project that aren't ready to go to production yet.

 

Does anyone have a good process for this?  Do you just not refresh sandboxes until all your changes are deployed?  What about longer term (3-6 month) projects? 

We are trying to set up integration with an external webservice.  We seem to be getting pretty close, but it looks like something is still off in our WSDL.  When I try to do the callout, I get this:

 

FATAL_ERROR|System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://ILRequestService/ILRequestServiceResponse=ILRequest

 

I suspect it has to do with the 4th line of the response.  It's like the APEX parsing doesn't know what to do with that line.  Seems like it might be namespace-related, but I don't know what to change.  I've tried messing around with the WSDL to make elements "qualified" instead of "unqualified", but that did not seem to help.  If anyone could give some insight on this, it would be much appreciated.

 

The actual method I'm using is getILRequestObject.

 

Below is the relevant info:

 

XML Request

<?xml version="1.0" encoding="UTF-8"?>
<ILRequest sourceEnvironment="UAT" sourceSystem="AE">
<parameters>
<dataSet>US</dataSet>
<methods>
<method>amort</method>
</methods>
<requests type="contract">
<key>001-0580963-000</key>
</requests>
</parameters>
</ILRequest>


 

XML Response

<?xml version="1.0" encoding="UTF-8" ?>
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Body>
 <se:getILRequestObjectResponse xmlns:re="http://ILRequestService/ILRequestServiceResponse" xmlns:se="http://ILRequestService/ILRequestService">
 <re:ILRequest sourceEnvironment="AE" sourceSystem="UAT">
 <parameters>
<dataSet>US</dataSet>
<ApplicationName />
<companyCode />
<financeType />
</parameters>
 <requests>
 <key id="12345" type="contact">
 <amort currency="" id="123456" interestRate="5.090062">
 <amortDetail cnt="1">
<paymentAmt>0.00</paymentAmt>
<principalAmt>-99.99</principalAmt>
<interestAmt>99.99</interestAmt>
<balanceAmt>12345.00</balanceAmt>
<dueDate>12/29/2009</dueDate>
<paymentNum>0</paymentNum>
<vatAmt>0.00</vatAmt>
<miscAmt>0.00</miscAmt>
<bookedInterest>0.00</bookedInterest>
<totPayAmt>0.00</totPayAmt>
<specialMiscAmt>0.00</specialMiscAmt>
<specialVatAmt>0.00</specialVatAmt>
<rentAmt>0.00</rentAmt>
</amortDetail>
</amort>
</key>
</requests>
</re:ILRequest>
</se:getILRequestObjectResponse>
</soapenv:Body>
</soapenv:Envelope>



 

 

WSDL

 

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions name="ILRequestService" targetNamespace="http://ILRequestService/ILRequestService" xmlns:bons1="http://ILRequestService/ILRequestServiceRequest" xmlns:bons2="http://ILRequestService/ILRequestServiceResponse" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://ILRequestService/ILRequestService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://ILRequestService/ILRequestService">
<xsd:import namespace="http://ILRequestService/ILRequestServiceResponse"/>
<xsd:import namespace="http://ILRequestService/ILRequestServiceRequest"/>
<xsd:element name="getILRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="request" nillable="true" type="xsd:string"/>
<xsd:element name="source" nillable="true" type="xsd:string"/>
<xsd:element name="country" nillable="true" type="xsd:string"/>
<xsd:element name="currency" nillable="true" type="xsd:string"/>
<xsd:element name="method" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getILRequestResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="response" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getILRequestObject">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bons1:ILRequest"/>
<xsd:element name="country" nillable="true" type="xsd:string"/>
<xsd:element name="currency" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getILRequestObjectResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bons2:ILRequest"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ILRequestService/ILRequestServiceResponse" xmlns="http://ILRequestService/ILRequestServiceResponse" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="keyType">
<xs:sequence>
<xs:element minOccurs="0" name="amort" type="amortType"/>
<xs:element minOccurs="0" name="contract" type="contractType"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<xs:element name="ILRequest" type="ILRequest"/>
<xs:complexType name="methodsType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="method" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="errorMessagesType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="ErrorMessage" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="contractType">
<xs:sequence>
<xs:element name="customerName" type="xs:string"/>
<xs:element name="invDeliveryFlag" type="xs:string"/>
<xs:element name="ddFlag" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<xs:complexType name="ILRequest">
<xs:sequence>
<xs:element name="parameters" type="parametersType"/>
<xs:element name="requests" type="requestsType"/>
<xs:element name="Error" type="errorType"/>
</xs:sequence>
<xs:attribute name="sourceSystem" type="xs:string"/>
<xs:attribute name="sourceEnvironment" type="xs:string"/>
</xs:complexType>
<xs:complexType name="requestsType">
<xs:sequence>
<xs:element name="key" type="keyType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="amortDetailType">
<xs:sequence>
<xs:element name="paymentAmt" type="xs:string"/>
<xs:element name="principalAmt" type="xs:string"/>
<xs:element name="interestAmt" type="xs:string"/>
<xs:element name="balanceAmt" type="xs:string"/>
<xs:element name="dueDate" type="xs:string"/>
<xs:element name="paymentNum" type="xs:string"/>
<xs:element name="vatAmt" type="xs:string"/>
<xs:element name="miscAmt" type="xs:string"/>
<xs:element name="bookedInterest" type="xs:string"/>
<xs:element name="totPayAmt" type="xs:string"/>
<xs:element name="specialMiscAmt" type="xs:string"/>
<xs:element name="specialVatAmt" type="xs:string"/>
<xs:element name="rentAmt" type="xs:string"/>
</xs:sequence>
<xs:attribute name="cnt" type="xs:string"/>
</xs:complexType>
<xs:complexType name="parametersType">
<xs:sequence>
<xs:element minOccurs="0" name="dataSet" type="xs:string"/>
<xs:element minOccurs="0" name="methods" type="methodsType"/>
<xs:element minOccurs="0" name="ApplicationName" type="xs:string"/>
<xs:element minOccurs="0" name="companyCode" type="xs:string"/>
<xs:element minOccurs="0" name="financeType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="errorType">
<xs:sequence>
<xs:element minOccurs="0" name="ErrorCode" type="xs:string"/>
<xs:element minOccurs="0" name="ErrorMessages" type="errorMessagesType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="amortType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="amortDetail" type="amortDetailType"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
<xs:attribute name="interestRate" type="xs:string"/>
<xs:attribute name="currency" type="xs:string"/>
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ILRequestService/ILRequestServiceRequest" xmlns="http://ILRequestService/ILRequestServiceRequest" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="methodsType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="method" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="requestsType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="key" type="xs:string"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
<xs:element name="ILRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="parameters" type="parametersType"/>
</xs:sequence>
<xs:attribute name="sourceSystem" type="xs:string"/>
<xs:attribute name="sourceEnvironment" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:complexType name="parametersType">
<xs:sequence>

<xs:element minOccurs="0" name="dataSet" type="xs:string"/>
<xs:element minOccurs="0" name="methods" type="methodsType"/>
<xs:element name="requests" type="requestsType"/>
<xs:element minOccurs="0" name="ApplicationName" type="xs:string"/>
<xs:element minOccurs="0" name="companyCode" type="xs:string"/>
<xs:element minOccurs="0" name="financeType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getILRequestRequestMsg">
<wsdl:part element="tns:getILRequest" name="getILRequestParameters"/>
</wsdl:message>
<wsdl:message name="getILRequestResponseMsg">
<wsdl:part element="tns:getILRequestResponse" name="getILRequestResult"/>
</wsdl:message>
<wsdl:message name="getILRequestObjectRequestMsg">
<wsdl:part element="tns:getILRequestObject" name="getILRequestObjectParameters"/>
</wsdl:message>
<wsdl:message name="getILRequestObjectResponseMsg">
<wsdl:part element="tns:getILRequestObjectResponse" name="getILRequestObjectResult"/>
</wsdl:message>
<wsdl:portType name="ILRequestService">
<wsdl:operation name="getILRequest">
<wsdl:input message="tns:getILRequestRequestMsg" name="getILRequestRequest"/>
<wsdl:output message="tns:getILRequestResponseMsg" name="getILRequestResponse"/>
</wsdl:operation>
<wsdl:operation name="getILRequestObject">
<wsdl:input message="tns:getILRequestObjectRequestMsg" name="getILRequestObjectRequest"/>
<wsdl:output message="tns:getILRequestObjectResponseMsg" name="getILRequestObjectResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ILRequestServiceExport2_ILRequestServiceHttpBinding" type="tns:ILRequestService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getILRequest">
<soap:operation soapAction=""/>
<wsdl:input name="getILRequestRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getILRequestResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getILRequestObject">
<soap:operation soapAction=""/>
<wsdl:input name="getILRequestObjectRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getILRequestObjectResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ILRequestServiceExport2_ILRequestServiceHttpService">
<wsdl:port binding="tns:ILRequestServiceExport2_ILRequestServiceHttpBinding" name="ILRequestServiceExport_ILRequestServiceHttpPort">
<soap:address location="**endpoint**"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Is there any way to stop the default behavior of clearing out query string variables from the URL when using a PageReference with redirect set to false?

 

I have a page that renders different links depending on a "country" variable.  The Australia URL looks something like:

 

http://mydomain/tools/mytool?country=au

 

There is a form on that page, and on submit, you are redirected to the "mytool2" page which uses the same controller.  Since the PageReference redirect is set to false, this is not a client-side redirect.  However, for whatever reason, when the redirect happens, my browser's URL suddenly has the country query string truncated and becomes http://mydomain/tools/mytool.

 

While this doesn't affect any functionality, the problem is that this could confuse my Australian customers if they ever try and bookmark the post-submitted page URL that is missing the correct query string.  And if they hit the site without ?country=au, they will end up with incorrect links for their locale.

 

Why is Salesforce deleting my query string at all?  Is there any way to avoid this from happening?

 

Here is a simplified version of what the code looks like:

 

"mytool" (Page 1 with form)

<apex:page showheader="false" sidebar="false" controller="myController">
<apex:form >
<apex:pageblock title="Choose from the following options"
			mode="maindetail">
  **Various form input fields**
  <apex:commandbutton value="Submit" action="{!Submit}" />
</apex:pageblock>
</apex:page>

 


"mytool2" (Page 2)

 

<apex:page sidebar="false" standardstylesheets="false" cache="false"
	showHeader="false" controller="myController">

**Various outpanels displayed depending on what was selected from the first page**

</apex:page>

 


 

"myController" (Controller used by both pages)

public with sharing class myController{
  public PageReference submit(){
    return Page.mytool2;
  }
}

 

 



Stumped on an error: Non-selective query against large object type (more than 100000 rows). My query is on the assets object which does have over 700k records. However, the exact query runs fine in a class or anonymous block. It only throws the error when executing from a trigger. I've tried indexing one of the fields in the WHERE clause, but I'm still getting the error. Open ticket with Salesforce has not been helpful, so I'm rather desperate - has anyone here run into this?

 

Query:


Select id, name, SerialNumber from Asset where IsVisionLink__c = false and Exception_from_Disable__c = true  and source__c != null and source__c = 'CN_CCFL_OU'

 

 

Again - query runs just fine in an anonymous block.  The source__c field has been marked as an external id, which should mean it is indexed.  Why am I still getting this error?  Have an open ticket with Salesforce, but they have not been helpful thus far.

  • September 21, 2011
  • Like
  • 0

I have a public unauthenticated site that I am working to deploy to other countries and other languages besides English.  My first one will be in Spanish.  I have converted everything to labels and have added Spanish translation to the labels.  My intent is to change the language by hitting the page with a "lang" query string.  

 

However, even when I test by manually setting the language parameter in the apex:page tag, nothing is being translated.  Everything is always in English no matter what I do.  What's going on here?  Is there something special about doing translation for Force.com sites?

 

Page tag:

<apex:page controller="CalcController" sidebar="false"  showHeader="false" language="es">

 

Example label tag (has a Spanish translation but is always displaying in English)

{!$Label.denotes_required_field}

 

  • September 12, 2011
  • Like
  • 0

I'm trying to do an HTTP callout for this REST webservice; everything seems to be working except that I'm getting an empty body for the response when I know there should be something there.  If I paste the exact endpoint URL into my browser, I see xml returned.  What could possibly make force.com see an empty response?

 

Code is below.  The webservice is MapAbc's reverse geocode service.  I've left off the last section of the URL which represents our org's key.

 

 

	Http h = new Http();
	HttpRequest req = new HttpRequest();
	
	string url = 'http://search1.mapabc.com/sisserver?highLight=false&config=SPAS&ver=2.0';
	url = url + '&resType=xml';	//Response type
	url = url + '&enc=utf-8&spatialXml=<spatial_request method=\'searchPoint\'>';
	url = url + '<x>106.66423034667969</x>';	//Latitude
	url = url + '<y>26.61029052734375</y>';		//Longitude
	url = url + '<xs></xs><ys></ys>';
	url = url + '<poiNumber>0</poiNumber>';
	url = url + '<range>NaN</range><pattern>0</pattern><roadLevel>0</roadLevel><exkey></exkey></spatial_request>';
	url = url + '&a_k=***OurKey****';	//Key
	url = url + '&a_nocache=615704261174';
	
	req.setEndpoint(url);
    	req.setMethod('GET');    
	HttpResponse res  = new HttpResponse(); 
	res = h.send(req);
	string resBody=res.getBody();
        system.debug('Response Body is: ' + resBody);   //Why is this null???	   

 

Debug logs:

 

08:34:49.056 (56000000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
08:34:49.056 (56802000)|METHOD_ENTRY|[1]|01pK00000000Nrc|MapAbcTest.MapAbcTest()
08:34:49.056 (56859000)|SYSTEM_MODE_ENTER|false
08:34:49.056 (56909000)|SYSTEM_MODE_EXIT|false
08:34:49.056 (56942000)|METHOD_EXIT|[1]|MapAbcTest
08:34:49.056 (56988000)|CONSTRUCTOR_ENTRY|[1]|01pK00000000Nrc|<init>()
08:34:49.057 (57059000)|SYSTEM_MODE_ENTER|false
08:34:49.057 (57107000)|SYSTEM_MODE_EXIT|false
08:34:49.057 (57166000)|CONSTRUCTOR_EXIT|[1]|01pK00000000Nrc|<init>()
08:34:49.057 (57297000)|METHOD_ENTRY|[2]|01pK00000000Nrc|MapAbcTest.testing()
08:34:49.058 (58417000)|SYSTEM_MODE_ENTER|false
08:34:49.058 (58943000)|SYSTEM_METHOD_ENTRY|[26]|System.HttpRequest.setEndpoint(String)
08:34:49.059 (59003000)|SYSTEM_METHOD_EXIT|[26]|System.HttpRequest.setEndpoint(String)
08:34:49.059 (59081000)|SYSTEM_METHOD_ENTRY|[28]|System.HttpRequest.setMethod(String)
08:34:49.059 (59133000)|SYSTEM_METHOD_EXIT|[28]|System.HttpRequest.setMethod(String)
08:34:49.059 (59240000)|SYSTEM_METHOD_ENTRY|[30]|System.Http.send(APEX_OBJECT)
08:34:49.059 (59350000)|CALLOUT_REQUEST|[30]|System.HttpRequest[Endpoint=http://search1.mapabc.com/sisserver?highLight=false&config=SPAS&ver=2.0&resType=xml&enc=utf-8&spatialXml=<spatial_request method='searchPoint'><x>106.66423034667969</x><y>26.61029052734375</y><xs></xs><ys></ys><poiNumber>0</poiNumber><range>NaN</range><pattern>0</pattern><roadLevel>0</roadLevel><exkey></exkey></spatial_request>&a_k=***OurKey***&a_nocache=615704261174, Method=GET]
08:34:49.287 (287725000)|CALLOUT_RESPONSE|[30]|System.HttpResponse[Status=OK, StatusCode=200]
08:34:49.287 (287820000)|SYSTEM_METHOD_EXIT|[30]|System.Http.send(APEX_OBJECT)
08:34:49.287 (287933000)|SYSTEM_METHOD_ENTRY|[31]|System.HttpResponse.getBody()
08:34:49.287 (287986000)|SYSTEM_METHOD_EXIT|[31]|System.HttpResponse.getBody()
08:34:49.288 (288079000)|SYSTEM_METHOD_ENTRY|[32]|System.debug(ANY)
08:34:49.288 (288154000)|USER_DEBUG|[32]|DEBUG|Response Body is: null
08:34:49.288 (288199000)|SYSTEM_METHOD_EXIT|[32]|System.debug(ANY)
08:34:49.288 (288275000)|SYSTEM_MODE_EXIT|false

 

And finally - this is what I get when I copy and paste that exact endpoint into a browser window:

 

<spatial_response type="SpatialBean" servername="mSIS03" versionname="1.0.9">
<SpatialBean ver="1.0">
<Province ver="1.0">
<name>贵州省</name>
<code>520000</code>
</Province>
<City ver="1.0">
<name>贵阳市</name>
<code>520100</code>
<telnum>0851</telnum>
</City>
<District ver="1.0">
<name/>
<code/>
<x/>
<y/>
<bounds/>
</District>
<roadList type="list">
<Road ver="1.0">
<id>08511789</id>
<name>贵遵高速</name>
<direction>EastNorth</direction>
<distance>38.340862</distance>
<width>12</width>
<ename>Guizun Expressway</ename>
<level>41000</level>
</Road>
<Road ver="1.0">
<id>0851804</id>
<name>服务区</name>
<direction>EastNorth</direction>
<distance>73.932838</distance>
<width>4</width>
<ename>Service area</ename>
<level>43000</level>
</Road>
<Road ver="1.0">
<id>08512255</id>
<name>贵遵高速出口</name>
<direction>WestSouth</direction>
<distance>339.452545</distance>
<width>8</width>
<ename>Guizun Expressway Exit</ename>
<level>44000</level>
</Road>
<Road ver="1.0">
<id>08512254</id>
<name>贵遵高速入口</name>
<direction>WestSouth</direction>
<distance>339.452545</distance>
<width>8</width>
<ename>Guizun Expressway Entrance</ename>
<level>44000</level>
</Road>
<Road ver="1.0">
<id>08511942</id>
<name>兴筑东路</name>
<direction>WestSouth</direction>
<distance>364.536499</distance>
<width>20</width>
<ename>(unnamed road)</ename>
<level>44000</level>
</Road>
</roadList>
<poiList type="list"/>
<crossPoiList type="list">
<cross>
<name>贵遵高速-服务区</name>
<x>106.663529</x>
<y>26.599138</y>
</cross>
</crossPoiList>
</SpatialBean>
</spatial_response>

 

 

  • September 08, 2011
  • Like
  • 0

I feel like maybe I don't understand the purpose of "rerender."  I want to be able to click a button that calls a method in my controller.  The method then calls out to a webservice to grab a value.  The method then updates the record.  Finally, the fields should be refreshed on the page.   From looking at countless examples, here is the code I've come up with.   The problem is that nothing is being rerendered after the controller method finishes.  If I refresh the page manually, I see the updated fields.  How can I make the fields refresh without having to manually force it?

 

Page

 <apex:commandButton value="test" status="myStatus" action="{!testing}" reRender="theblock"/>

  <apex:actionStatus startText="(processing...)" stopText="" id="myStatus" />

 

 

<apex:pageBlock id="theblock" >
<apex:outputField value="{!Asset.Current_Hours__c}"/>

 

 

 

 

Controller

public void testing(){
     

updateSingleRecord(obj.Id);       //Method that does a webservice call and also updates Current_Hours field on the record.

       
    }

How do you pass the currently selected value of a picklist to a controller via apex:param?  I have a picklist where a user selects a value and clicks a button.  I want the value they selected to be passed to my controller method.  I can't seem to find the syntax for getting the value.  Code is below.

 

<apex:pageBlock >
<apex:pageblockSection >

<apex:inputField id="startMode" value="{!Asset.Start_Mode__c}" />

<apex:commandButton  value="Update" action="{!setMachine}" status="myStatus" rerender="thediv">
             <apex:param name="vlsetting" value="'{!$Component.startMode}'"  assignTo="{!vlsettingValue}"/>           
 </apex:commandButton>
 <apex:actionStatus id="myStatus">
            <apex:facet name="start">
            Setting Start Mode
            </apex:facet>
 </apex:actionStatus>

 

 

It seems like it should not be that hard to figure this out, but I can't seem to Google the right keywords.

Is there any way I can access the fields on a standard page with javascript using the $Component function or something similar without needing to hard-code the element ID?

 

I'm using the standard asset page.  I have a button that calls a webservice to update a couple fields on the page.  I would like to write some additional javascript to update the appropriate fields on the page without needing to initiate a page refresh.  I know I can probably accomplish this by hard-coding the element ID's based on what I see in the generated page source, but I know that's not a good practice.  All the javascript component documentation I've found assumes you are doing a visualforce page, but I really need to figure this out from within the standard page, where I have no control over what ID's are assigned to components.

Is there a way to do Javascript remoting from a button on a standard page?  Or some way to get the same result with a different method?  Basically, I need a button that users can press to kick off a function in another class.

Hi guys

 

My client's instance has been upgraded to Winter 14 and today I noticed the "Code Coverage (%)" column is no longer showing on Classes and Triggers page.

 

Does anyone else have the same experience?

Now you have to click on the name of the class in order to see its code coverage.  Information is still there, but getting to it is now not convenient.....

 

Is it a Winter 14 "feature"?

 

Thanks

King

I have already trimmed my generated wsdl class by cutting down the wsdl but when my test class written is showing no coverage no green no red its 0% coverage..any ideas.It will be great help 

 

Thanks

 

  • January 31, 2013
  • Like
  • 0

Two of my sandboxes upgraded today to Spring 13, and I can't Deploy metadata to them using the Force.com IDE. I'm seeing the errors:

 

   Problem: Unknown type name 'MobileSettings' specified in package.xml
   Problem: Unknown type name 'SecuritySettings' specified in package.xml

Has anyone seen this or know of a workaround?

 

Dan

 

I've been banging my head against the wall trying to customize the exception page. I created my own and pointed my site to use it as the exception error page. I modified it so that it should apply my SiteTemplate to it. However, whenever an exception occurs, it still just displays the out of the box "Error: Error occurred while loading a Visualforce page." message with the standard Force.com styling, which we definitely do not want for our branded customer site. 

 

I noticed that if I don't have it apply my SiteTemplate and then really water it down to essentially just text, then it finally displays that text without the Force.com styling and message. But as soon as I start adding components or anything else, it reverts back to the Salesforce styling.

 

Also, if navigate directly to /apex/<myexceptionpage>, the styling works perfectly. It's just when I hit an actual exception and get directed to it that the styling breaks on me.

 

 

How do I get around this? I really don't want my exception page showing that styling/message...

We are developing a new site that will be used by both Customers and Partners. For now, the functionality is the same and both users will be seeing the exact same pages. However, because their license types are different, one uses a site associated with customer portal and the other uses a site associated with the partner portal.

 

Is there no way to consolidate these into a single login page such that if I can detect which users are partners, I could then direct their login to go through the partner site? We really don't want to have two separate login URL's...

I have recently started using the new Developer Console quite a bit. It's a great tool, but I am experiencing an error that I have never seen before when using it: 

 

Organization Administration Locked

The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later. 

 

When this happens a lock is placed on an Apex class and I cannot edit it.  Any idea how to get out of this locked state? I have tried logging out of Salesforce and logging back in again multiple times.

  • October 31, 2012
  • Like
  • 0

Hello everyone,

 

We are trying to use the new API Salesforce made available during Winter '13: Test.setMock.

We followed the documentation, but encountered the following issue that we were unable to resolve: a System.CalloutException, complaining that we had "uncommitted work pending".

 

Of course we do, our testmethod starts by setting up some Test Data that's necessary for the test to work, and that includes inserting and updating data.

In an actual execution, there would be no data creation, as the data would already be present. Actually doing the callout doesn't raise the Uncomitted work pending exception, so the Test Data really is at fault.

 

We did use Test.startTest() and Test.stopTest() to differentiate Test Data creation from Test Execution but this (as expected) didn't work.

We also tried some hacks, including the System.runAs(new User( Id = UserInfo.getUserId()){} that had, in the past, allowed us to circumvent "Mixed DML operations". This didn't work either.

 

We considered using the Test.loadData method, but we're inserting related objects and couldn't figure out a clean enough way to make it work (maybe we should try using ExternalID's?).

 

 

For the moment, our workaround is to modify the class generated from the WSDL, adding a if (Test.isRunningTest()) {} else {}, but that means we have to modify the autogenerated code, which is suboptimal.

 

 

Did anyone try to use this new API and run into the same issue? How did you solve it?

Folks,

 

 

If you try using the isempty() function similar to the list and set methods  for strings then it will throw an error.

Instead use the below syntax

 

String st = 'Hello'; 
Boolean val= String.isEmpty(st);

 

 

Thanks,
Rakesh B

 

When executing a test method (using API version 24.0), I am getting this error:

Internal Salesforce Error: 883366085-8175 (-1490970800) (-1490970800).

 

I have isolated the problem to this section of code that attempts to multiply a currency value (stored in a custom setting):

double chinaRate = [SELECT conversionrate FROM currencytype WHERE isocode = 'CNY'].conversionRate;
VL_CountrySettings__c countrySetting = new VL_CountrySettings__c();
countrySetting.Name = 'us';
countrySetting.Allowance__c = 40.00; //This is a currency field
insert countrySetting;

VL_CountrySettings__c usSettings = VL_CountrySettings__c.getInstance('us');
decimal allowance_value = chinaRate * usSettings.Allowance__c; //This line causes the error

 

If I run that exact same code anonymously (without the insert because the record is accessible when not testing), it runs fine without error.

 

Any ideas why I'm getting this strange error and only in a test method? I also opened a case and am waiting on a response.

We have had Federated SSO set up for awhile now in our production org. I would like to set it up in at least one of our sandboxes as well. Is there any way to do this without having our IDP admins maintain separate endpoints for each sandbox? We are using My Domain, so it seems like the SAML Assertion would need to be pretty specific to each one and as far as I can tell does not have a way to dynamically forward users to the desired sandbox. It would be even better if production and sandbox orgs could point to the same SSO url, but it seems like that is even less likely.

 

Any thoughts on this? Is anyone else using SSO across multiple environments?

I have an external web service that's called from a class generated from a wsdl file.  I've wrapped the invoke method with a Test.isRunningTest() check so that my tests don't fail due to a callout.  My assert comes back successful, but code coverage remains at 0%.

 

(code posted below)

 

Any thoughts and/or ideas would be greatly appreciated.

 

Thank you in advance!

Sam

 

APEX Test:

@isTest

private Class MyService

{

    publicstatictestMethodvoid TestMyService()

    {

        try

        {

            MyService.AccountServiceSoap cs = new MyService.AccountServiceSoap();

            DateTime dt = cs.GetFirstInstallAppointmentAvailable('token', '', '', '', '', '10023', 982);

            

            //With the callout, I know that the returned result will be 1/1/1900

            DateTime expected = DateTime.newInstanceGMT(1900,1,1);

            

            System.Debug('ClickServiceTest Pre dt:' + dt + ' / expected:' + expected);

            

            System.AssertEquals(dt,expected);

            

            System.Debug('ClickServiceTest Post dt:' + dt + ' / expected:' + expected);

        }

        catch(Exception ex)

        {

            System.Debug('Error: ' + ex.getMessage());

        }

    }

}

 

 

APEX Class:

//Generated by wsdl2apex

public class MyService {
public class Available_element {
public String token;
public String address1;
public String address2;
public String city;
public String stateAbbrev;
public String postalCode;
public Integer serviceCodeID;
private String[] token_type_info = new String[]{'token','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] address1_type_info = new String[]{'address1','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] address2_type_info = new String[]{'address2','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] city_type_info = new String[]{'city','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] stateAbbrev_type_info = new String[]{'stateAbbrev','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] postalCode_type_info = new String[]{'postalCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] serviceCodeID_type_info = new String[]{'serviceCodeID','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
private String[] field_order_type_info = new String[]{'token','address1','address2','city','stateAbbrev','postalCode','serviceCodeID'};
}
public class AvailableResponse_element {
public DateTime GetFirstInstallAppointmentAvailableResult;
private String[] GetFirstInstallAppointmentAvailableResult_type_info = new String[]{'GetFirstInstallAppointmentAvailableResult','http://www.w3.org/2001/XMLSchema','dateTime','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
private String[] field_order_type_info = new String[]{'GetFirstInstallAppointmentAvailableResult'};
}
public class AccountServiceSoap {
public String endpoint_x = 'http://someservice.com';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://tempuri.org/', 'MyService'};

public DateTime GetFirstInstallAppointmentAvailable(String token,String address1,String address2,String city,String stateAbbrev,String postalCode,Integer serviceCodeID) {
MyService.Available_element request_x = new MyService.Available_element();
MyService.AvailableResponse_element response_x;
request_x.token = token;
request_x.address1 = address1;
request_x.address2 = address2;
request_x.city = city;
request_x.stateAbbrev = stateAbbrev;
request_x.postalCode = postalCode;
request_x.serviceCodeID = serviceCodeID;
Map<String, MyService.AvailableResponse_element> response_map_x = new Map<String, MyService.AvailableResponse_element>();
response_map_x.put('response_x', response_x);

if(Test.isRunningTest())
{
return DateTime.newInstanceGMT(1900,1,1);
}

WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://tempuri.org/GetFirstInstallAppointmentAvailable',
'http://tempuri.org/',
'GetFirstInstallAppointmentAvailable',
'http://tempuri.org/',
'GetFirstInstallAppointmentAvailableResponse',
'MyService.AvailableResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.GetFirstInstallAppointmentAvailableResult;
}
}
}

  • March 09, 2012
  • Like
  • 0

Hi,

since the upgrade to spring'12 many of my tests fail if I run them from theApex Test Execution page. But if I run them from the Apex Classes page (run all tests) they all pass fine!

 

It looks like the way the system processes simultanious tests in teh Test Execution Page has been changed. In the failing scripts I first delete all instances of a custom object and then insert a new instance, to be sure only that instance is in the database while testing. The error message I get since this week in many of my testclasses is:

 

System.DmlException: Delete failed. First exception on row 0 with id a03A0000001ItxxIAC; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []

 

Any tricks/ explanation or comment from salesforce?

thanks.

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

I have a class which does HTTP callouts.  Because I am needing to do more than 10 callouts at a time, I am using a Batch class to call that class.  At this point, I can call that class without issue by directly calling the batch execute via system log.  The next step I need to do is put the Batch in a scheduler that runs every hour.  So I now have 4 classes:

 

1.) My original class that does the HTTP callouts

2.) The batch class which calls #1 scoped one record at a time to avoid the 10-callout limit

3.) A schedulable class which executes the batch class and has a method to invoke system.scheduler

 

But now I'm stuck because it seems no matter how I organize things, I get one of these errors:

 

1.) Future method cannot be called from a future method (I'm getting this one with my current code setup)

2.) You have uncommitted work pending (I get this one if the callout method isn't a future method)

3.) Too many callouts - 2 (I get this one if I make the callout method NOT a future method and somehow try to update the assets all together in the batch class)

 

What the heck am I supposed to do to get this class scheduled??  Below is my code.

 

Class #1: The HTTP Callout Class

global class VLStatus {

 

  @future(callout=true)
   global static void getMachineStatus(String asstId){

        Asset asst = new Asset();
        asst = [select id, name, SerialNumber from Asset where Id = :asstId];

 

       //code that does my callout stuff and sets the asset fields

      update asset;

  }

 

Class #2: The Batch Class

global class VLStatusBatch implements Database.Batchable<Asset>, Database.AllowsCallouts{

//Get list of machines that we are still waiting on for a response
Asset[] AssetsToUpdate = [Select id, name, SerialNumber from Asset where Pending_VL_Response__c = 1];

global Iterable<Asset> start(database.batchablecontext BC){
    return (AssetsToUpdate);    
}

global void execute(Database.BatchableContext BC, List<Asset> scope){
    for(Asset a : scope){
            VLStatus.getMachineStatus(a.Id);
    }    
}

global void finish(Database.BatchableContext info){
    }//global void finish loop

}

 

 

 

Class #3: The Schedulable Class

global class HourlyScheduler implements Schedulable{
    global HourlyScheduler (){}

    public static void start(){
        //Seconds Minutes Hours Day_of_month Month Day_of_week optional_year
        System.schedule('Pending Machine Status Update', '0 5 1-23 * * ?', New HourlyScheduler());

    }

    global void execute(SchedulableContext ctx){
        VLStatusBatch b = new VLStatusBatch();
        database.executebatch(b);    
    }
}

 

I'm having a problem sending e-mail from an APEX controller extension. Here's the code followed by the results from the debug log.

 

public class leadExtension {

public leadExtension(ApexPages.StandardController controller) {
this.lead = (Lead)controller.getRecord();

// Create a new single email message object
// that will send out a single email.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

// Strings to hold the email addresses to which you are sending the email.
String[] toAddresses = new String[] {'********@hsabank.com'};

// Assign the addresses for the To list to the mail object.
mail.setToAddresses(toAddresses);

// Specify the address used when the recipients reply to the email.
mail.setReplyTo('********@hsabank.com');

// Specify the name used as the display name.
mail.setSenderDisplayName('HSA Bank');

// Specify the subject line for your email address.
mail.setSubject('New Contact Request: ' + lead.FirstName);

// Set to True if you want to BCC yourself on the email.
mail.setBccSender(false);

// Optionally append the salesforce.com email signature to the email.
// The email address of the user executing the Apex Code will be used.
mail.setUseSignature(false);

// Specify the text content of the email.
mail.setPlainTextBody('Please add this new contact...');

mail.setHtmlBody('Please add this new contact...');

// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}

private final Lead lead;
}
<apex:page tabStyle="Lead" standardController="Lead" extensions="leadExtension" >
    <apex:form >
    <apex:sectionHeader title="New Contact Request" />
    <h1>Notice Sent</h1>
    <p>
        Congratulations, your request to add a new Contact has been submitted. 
    </p>
    <apex:outputField title="First Name:" value="{!Lead.FirstName}"/>
    </apex:form>
</apex:page>
Element thePage called method {!checkManageability} returned type PageReference: none
***Begining Page Log for /apex/New_Contact_Request
20090801203603.582:Class.leadExtension.<init>: line 38, column 42: Single email queued for send (pending commit) : replyTo: ********@hsabank.com, subject: New Contact Request: Randy, senderDisplayName: HSA Bank, bccSender: false, saveAsActivity: true, useSignature: false, toAddresses: [********@hsabank.com], plainTextBody: Please add this new contact..., htmlBody: Please add this new contact...,
20090801203603.582:Class.leadExtension.<init>: line 39, column 9: Email result true
20090801203603.582:External entry point: returning from end of method public leadExtension<Constructor>(ApexPages.StandardController) in 38 ms
Cumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

1 most expensive method invocations:
Class.leadExtension: line 3, column 12: public leadExtension<Constructor>(ApexPages.StandardController): executed 1 time in 38 ms


***Ending Page Log for /apex/New_Contact_Request?id=00Q8000000SRUBJ&core.apexpages.devmode.url=1&scontrolCaching=1

 

I suppose I should first point out that I'm fairly new to Salesforce, and this is the first class I've tried to develop on my own. So, please be gentle with me! :smileywink: 

 

Based on what I can see, everything appears to be working fine, and the associated Visualforce page displays without error. The code is running inside leadExtension constructor. The problem is that the e-mail never arrives. I've got a couple different Developer Edition orgs, and I've tied this code in both. I get the same result.

 

I get other e-mails from Salesforce, like the security token re-set, e-mail change confirmation, etc. So, I know mail is getting through from them.

 

Also, I checked the Email Logs, and it doesn't appear to show any e-mails being sent at the time that I tried to send them.

 

So, I'm a little stumped. Can somebody point me in the right direction.

Message Edited by DRSnyder on 08-01-2009 02:08 PM
Message Edited by DRSnyder on 08-03-2009 11:15 AM

Hello everyone,

 

We are trying to use the new API Salesforce made available during Winter '13: Test.setMock.

We followed the documentation, but encountered the following issue that we were unable to resolve: a System.CalloutException, complaining that we had "uncommitted work pending".

 

Of course we do, our testmethod starts by setting up some Test Data that's necessary for the test to work, and that includes inserting and updating data.

In an actual execution, there would be no data creation, as the data would already be present. Actually doing the callout doesn't raise the Uncomitted work pending exception, so the Test Data really is at fault.

 

We did use Test.startTest() and Test.stopTest() to differentiate Test Data creation from Test Execution but this (as expected) didn't work.

We also tried some hacks, including the System.runAs(new User( Id = UserInfo.getUserId()){} that had, in the past, allowed us to circumvent "Mixed DML operations". This didn't work either.

 

We considered using the Test.loadData method, but we're inserting related objects and couldn't figure out a clean enough way to make it work (maybe we should try using ExternalID's?).

 

 

For the moment, our workaround is to modify the class generated from the WSDL, adding a if (Test.isRunningTest()) {} else {}, but that means we have to modify the autogenerated code, which is suboptimal.

 

 

Did anyone try to use this new API and run into the same issue? How did you solve it?