• TLF
  • NEWBIE
  • 146 Points
  • Member since 2008

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 38
    Questions
  • 141
    Replies

Here's the Apex REST class:

@RestResource(urlMapping='/abc/def/*')
global with sharing class TheRESTclass
{
  @HttpGet
  global static String doGet(RestRequest req, RestResponse res)
  { return 'hello'; }
}

 

From the Apigee Salesforce console, I call the following URL (using OAuth authentication):

https://na7.salesforce.com/services/apexrest/abc/def

 

I've also tried it with the namespace in there:

https://na7.salesforce.com/services/apexrest/namespace/abc/def

 

But I keep getting this error:

 "message": "Could not find a match for URL /namespace/abc/def", "errorCode": "NOT_FOUND"

 

I've looked at multiple tutorials and they all guided me in the same direction. So I don't know what I could be possibly missing. Do I need to comfigure Remote Site Settings or do any other type of configuration?

 

Thanks in advance.

I'd like to create a validation rule that ensures that if a lookup field in my custom object is non-null, it refers to a record with a particular record type. I know how to write that validation rule using RecordTypeId:

 

    myfield__r.RecordTypeId = "012800000006Rz1"

 

But the custom object containing this rule will eventually be packaged into an App Exchange offering, so I can't rely on the Id always being the same. How can I write this rule to check the field's RecordType.Name?

 

I've tried the following, but I get "Field RecordType does not exist"

 

    myfield__r.RecordType.Name = "My RecordType Name"

 

Any ideas?

 

  • April 20, 2009
  • Like
  • 1

Ok, I feel kind of dumb asking this, but I'm trying to get double quote characters to appear in either the title or subtitle attributes of an <apex:sectionHeader>. I tried using &quot;, but that gets converted into "&#34;" in the rendered page. I also tried using the " character directly, but the Visualforce compile gets confused by the nested quotes in the title or subtitle attribute. Am I missing something obvious?

  • June 26, 2012
  • Like
  • 0

I've defined three different APEX REST endpoints (call them endpoint A, B and C). Each of these endpoints implements a GET method. I've created a Visualforce page that uses Javascript/AJAX to make calls to these REST endpoints through the AJAX proxy. Everything seems fine until I need to make HTTP GET calls to these three APEX REST endpoints in rapid succession (GET A, GET B, GET C). Analysis of the requests/responses shows that all three request are formed correctly, but the response to GET C is identical to the response for GET B. It seems like it is returning a cached response from the GET B call rather than the real response to the GET C call. If I slow things down, to allow more time in between the calls, the responses are what I would expect. Has anyone encountered anything like this?

  • March 20, 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

I'm trying to implement a custom Lead conversion operation using Apex. I had everything working fine until I added more than one possible "converted" Lead Status value. Initially, I had one "converted" Lead Status value ("Qualified"). When I execute the following code it converts fine:

 

Lead myLead = new Lead(FirstName='Test', LastName = 'Lead', Company='Test Company', Email='testlead@test.com');
myLead.RecordTypeId = [SELECT Id FROM RecordType WHERE DeveloperName='Client' AND SObjectType='Lead'].Id;
insert myLead;

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true AND MasterLabel = 'Qualified' LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());

 

However, I've added a new "converted" Lead Status value called "Converted2" and added this to my Lead Process. When I execute the same code, only specifying the "Converted2" status as my converted status, I get the following error:

 

System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Converted2: []

 

If I convert the Lead using the standard Lead conversion page, I am able to select "Converted2" as the converted status and the Lead converts successfully. Any ideas?

  • October 25, 2011
  • Like
  • 0

Has anyone else noticed that if you run unit tests using the Apex Test Runner tab in the Force.com IDE that the log output seems to be getting truncated? This is not the normal "maximum log file size exceeded" issue. It just gets truncated with no message in the log output. This seems to have started happening around the Summer '11 release, around the same time that the 100% coverage problem started (http://boards.developerforce.com/t5/Apex-Code-Development/Bug-Salesforce-Test-Coverage-System/td-p/292099). This is not something unique to my environment, because one of my coworkers is seeing the same problem when he tries to run unit tests in the Force.com IDE. It's kind of inconvenient, because the truncation occurs quite early in the log output, meaning you often don't get to see the log output you are interested in. The workaround is to run your tests in the Salesforce UI.

  • June 29, 2011
  • Like
  • 0

What am I missing here? I had just finished typing up a big long posting in the "Rich Text" editor on the Visualforce developer forum. I clicked the "Preview" tab before posting to see what it looked like. IT WIPED OUT MY POSTING! This is reproducible in FF and IE 8. Not sure where else to post this, but this is a real PITA.

  • May 06, 2011
  • Like
  • 0

Hi,

 

I've got a commercial Visualforce application that is deployed to clients via managed package. During testing in my developer edition and sandbox environments everything appears to work fine, yet we get numerous developer script exception notification emails from clients using the application. I tried to replicate the errors being reported, without much success until one day I managed to reproduce. The application has a number of pages that include apex:commandButton controls that use the "rerender" attribute to specify Ajax requests and partial page updates. The problems seem to occur when clients with slow internet connections click on one of the Ajax commandButtons before the page load has completed. The exceptions being raised are almost always coming from the <init> method of the Visualforce controller (the constructor). Typically, an ID of an SObject is passed to the page, and I'm retrieving an SObject via SOQL in the constructor. The errors seem to indicate that the constructor is being invoked but the page parameters are incomplete. So, this raises a few questions:

 

  • Has anyone else observed behavior like this?
  • Have you come up with a solution?
  • Why does clicking on a button that's supposed to do an Ajax submit result in invoking the constructor of the page controller? Shouldn't the controller already be instantiated at that point?

It seems like the most logical solution is to somehow disable the buttons until the page is completely loaded. I tried a few things to try to achieve this, but I've been unsuccessful.

  • I first tried adding javascript event handlers for the document.ready and window.load events. In document.ready, I disable input:submit buttons by adding the btnDisabled style and setting disabled=true. Then in window.load, re-enabled. This code worked, except that when the connection is slow, the page appears well before the document.ready event fires. During this time, the buttons remain clickable, and an error is generated (sometimes).
  • I tried adding a boolean field in my controller called "actionsEnabled". I added disabled="{!NOT(actionsEnabled)}" to the buttons. In the controller, I added an action method that set actionsEnabled=true and added this as the <apex:page> "action" method. This did not work either.

Not sure what else to try here. Any thoughts?

  • May 06, 2011
  • Like
  • 0

Ok, I know there are a lot of posts on this topic, and I am familiar with the two Visualforce techniques for doing this (using an outputField bound to an SObject currency field, and using the outputText value="{0,number,###,##0.00}" ). However, in my use case, I'm trying to display a currency value in the title of a pageBlock:

 

 

<apex:pageBlock title="Refund Amount: {!refundAmount}" >

 

I can't really use the outputText or outputField options here, so I think I need to do the formatting in my controller. The Apex documentation states that String.format(String, List<String>) works "in the same manner as apex:outputText." Has anyone actually used this method to format a Decimal value into a properly formatted currency String in Apex code?

  • November 17, 2010
  • Like
  • 0

I'm trying to use the XmlStreamWriter class to create an Xml document for to be used to generate a REST API call to a third party API. The API expects ISO-8859-1 character encoding. I build my Xml document as follows:

 

 

String camNs = 'http://api.xxxxxx.com/xsd/xxxxx';
String camPrefix = 'cam';
XmlStreamWriter w = new XmlStreamWriter();
w.writeStartDocument('ISO-8859-1', '1.0');
w.writeStartElement(camPrefix, 'campaign', camNs);
w.writeNamespace(camPrefix, camNs);

.
.
.

w.writeEndElement();
w.writeEndDocument();
String xmlOutput = w.getXmlString();
w.close();
return xmlOutput;

 

When I try to execute this code I get the following error: System.XmlException: Underlying stream encoding 'UTF-8' and input paramter for writeStartDocument() method 'ISO-8859-1' do not match.

 

According to the Apex docs, the Apex XmlStreamWriter class is based on the Stax API. The javadocs for the Stax API state the following for the XmlStreamWriter.writeStartDocument(String encoding, String version) method:

 

Note that the encoding parameter does not set the actual encoding of the underlying output. That must be set when the instance of the XMLStreamWriter is created using the XMLOutputFactory.

Unfortunately, the Apex implementation only has a no-argument constructor for the XmlStreamWriter class, so how can I set the encoding for the underlying stream when the XmlStreamWriter instance is created? It seems to me that the Apex implementation is limited to UTF-8 encoding.

 


 

 

 

  • September 20, 2010
  • Like
  • 0

I have two custom objects that represent an order with line items. Order is the master in a master/detail relationship, and OrderItem is the detail. I'm seeing no rhyme, nor reason to the default order in which OrderItems are returned in a relationship query. Here is a little code snippet and resulting debug output that shows what I mean:

 

 

Anonymous execution was successful.

19.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
Execute Anonymous: Order__c o = [SELECT Id, (SELECT Id, Name, CreatedDate, LastModifiedDate FROM OrderItems__r) FROM Order__c WHERE Id = 'a0880000008hBdKAAU'];
Execute Anonymous: for (OrderItem__c item : o.OrderItems__r) {
Execute Anonymous: System.debug(item);
Execute Anonymous: }
Execute Anonymous:
Execute Anonymous:
13:15:22.454|EXECUTION_STARTED
13:15:22.454|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
13:15:22.454|SOQL_EXECUTE_BEGIN|[1,20]|Aggregations:1|SELECT Id, (SELECT Id, Name, CreatedDate, LastModifiedDate FROM OrderItems__r) FROM Order__c WHERE Id = 'a0880000008hBdKAAU'
13:15:22.471|SOQL_EXECUTE_END|[1,20]|Rows:1
13:15:22.471|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.472|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010782, CreatedDate=2010-09-01 12:39:58, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0LzAAL}
13:15:22.472|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.472|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.472|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010783, CreatedDate=2010-09-01 12:40:41, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0M4AAL}
13:15:22.472|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.472|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.473|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010784, CreatedDate=2010-09-01 12:40:41, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0M5AAL}
13:15:22.473|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.473|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.474|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010785, CreatedDate=2010-09-01 12:40:41, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0M6AAL}
13:15:22.474|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.474|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.474|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010786, CreatedDate=2010-09-01 12:40:41, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0M7AAL}
13:15:22.474|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.474|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.475|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010813, CreatedDate=2010-09-02 11:48:19, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0xpAAD}
13:15:22.475|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.475|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.475|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010788, CreatedDate=2010-09-01 12:40:41, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0M9AAL}
13:15:22.475|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.475|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.476|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010791, CreatedDate=2010-09-01 20:24:43, LastModifiedDate=2010-09-02 17:15:18, Id=a028000000CY0afAAD}
13:15:22.476|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.476|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.477|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010792, CreatedDate=2010-09-01 20:25:16, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0akAAD}
13:15:22.477|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.477|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.477|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010812, CreatedDate=2010-09-02 11:47:38, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0xkAAD}
13:15:22.477|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.477|METHOD_ENTRY|[3,5]|System.debug(SOBJECT:OrderItem__c)
13:15:22.478|USER_DEBUG|[3,5]|DEBUG|OrderItem__c:{Order__c=a0880000008hBdKAAU, Name=ITEM-000010787, CreatedDate=2010-09-01 12:40:41, LastModifiedDate=2010-09-02 17:13:39, Id=a028000000CY0M8AAL}
13:15:22.478|METHOD_EXIT|[3,5]|System.debug(SOBJECT:OrderItem__c)

 

When you look closely at the list of OrderItem objects returned they do not seem to be sorted in any particular order. They aren't in order by Name, Id, CreatedDate or LastModifiedDate. I don't have an ORDER BY clause in my relationship query, so I am wondering what the default order is. Any ideas? The reason I'm asking is because I'm using a Visualforce email template to render the child OrderItem objects. Visualforce email templates have their own, internal controller that retrieve the child OrderItems in this default order, and therefore they are rendered in this strange, unexpected order. If I at least knew what order they are sorted in, I could possibly do something at the time of insert to insure they are rendered properly in my email template.

  • September 02, 2010
  • Like
  • 0

I have a requirement to automatically convert a Lead if the Lead status is a specific value (the Lead is to be converted when Lead.Status = 'Complete Request - Convert'). I wrote an insert/update trigger that performs the conversion process. It seems to be working fine when I test it by creating a Lead thru the Salesforce UI. If I create it with the specified status value, it is immediately converted upon saving my new record. So, I then wrote a unit test to test it programmatically. My unit test code looks like this:

 

 

	// Tests successful conversion of a single Lead inserted directly in the 'Complete Request - Convert' status
public static testMethod void testSingleInsert() {

RecordType clientLeadRT = [SELECT Id FROM RecordType WHERE DeveloperName = 'Client' AND SObjectType = 'Lead'];

Lead l = new Lead();
l.FirstName = 'Test';
l.LastName = 'Lead1';
l.Company = 'Test Company';
l.Phone = '3335552233';
l.Email = 'tlead1@test.com';
l.Status = 'Complete Request - Convert';
l.Street = '123 Test Street';
l.City = 'Test Town';
l.State = 'TN';
l.PostalCode = '12345';
l.RecordTypeId = clientLeadRT.Id;
insert l;

// Retrieve the Lead... it should have been converted
Lead convertedLead = [SELECT Id, IsConverted, ConvertedContactId, ConvertedAccountId, Status FROM Lead WHERE Id = :l.Id];
System.assert(convertedLead.IsConverted);
System.assertEquals('Qualified', convertedLead.Status);

// Retrieve the converted Contact
Contact convertedContact = [SELECT Id, FirstName, LastName, CompanyName__c, AccountId, RecordType.Name,
Phone, Email, MailingStreet, MailingCity, MailingState, MailingPostalCode
FROM Contact WHERE Id = :convertedLead.ConvertedContactId];
System.assertEquals(l.FirstName, convertedContact.FirstName);
System.assertEquals(l.LastName, convertedContact.LastName);
System.assertEquals(l.Company, convertedContact.CompanyName__c);
System.assertEquals(convertedLead.ConvertedAccountId, convertedContact.AccountId);
System.assertEquals(l.Phone, convertedContact.Phone);
System.assertEquals(l.Street, convertedContact.MailingStreet);
System.assertEquals(l.City, convertedContact.MailingCity);
System.assertEquals(l.State, convertedContact.MailingState);
System.assertEquals(l.PostalCode, convertedContact.MailingPostalCode);
System.assertEquals('Client', convertedContact.RecordType.Name);
}

 

 

The status value 'Complete Request - Convert' is the value that triggers the auto-conversion. When I run this test, I get an exception at the "insert l;" statement (highlighted in red). The error is:

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []

 

I get the same error if I try to create a Lead in this state from the "Execute Anonymous" window.

 

If I create the Lead in a different state, and then update it to "Complete Request - Convert", it works fine. Is there any workaround for this, or can I not insert a Lead that is converted by a trigger in the same transaction?

  • August 05, 2010
  • Like
  • 0

I have a managed/released package that contains a number of Visualforce email templates. I have made some changes to the packaged email templates and want to push these changes out to users of my managed package. I'm noticing that my changes are not being deployed. I even tried deleting one of the email templates from one of the destination orgs and then installing the new version of the package to see if it would "re-install" the updated version of the email template. What I found is that it doesn't install the new copy of the template, and now I seem to have no way of restoring this template to the destination org.

 

Is this a bug? Why aren't managed/released Visualforce email templates upgradable?

  • June 22, 2010
  • Like
  • 0

I have an Apex script that basically performs the following:

 

 

Savepoint sp;
try {

  sp = Database.setSavepoint();

  // Do some dml inserts, updates

} catch (Exception ex) {

  Database.rollback(sp);

  // Make a web service callout

throw ex;
}

 

 

I'm explicitly rolling back my uncommitted dml operations to try to get around the fact that you can't make a callout when you have uncommitted work. This doesn't seem to work. I get the following messages in the system log:

 

 

13:35:26.797|USER_DEBUG|[190,4]|DEBUG|System.QueryException: List has no rows for assignment to SObject
13:35:26.797|METHOD_EXIT|[190,4]|debug(ANY)
13:35:26.797|METHOD_ENTRY|[195,30]|Exception.getMessage()
13:35:26.797|METHOD_EXIT|[195,30]|getMessage()
13:35:26.797|METHOD_ENTRY|[201,6]|Database.rollback(System.Savepoint)
13:35:26.797|SAVEPOINT_ROLLBACK|[201,6]|SavepointValue0
13:35:26.799|METHOD_EXIT|[201,6]|rollback(System.Savepoint)
13:35:26.799|METHOD_ENTRY|[203,5]|IPNMessageWSDL.IPNMessageService.upsertIPNMessage(String, String, String, String)
13:35:26.799|METHOD_ENTRY|[59,13]|MAP:String,IPNMessageWSDL.upsertIPNMessageResponse_element.put(String, IPNMessageWSDL.upsertIPNMessageResponse_element)
13:35:26.799|METHOD_EXIT|[59,13]|put(ANY, ANY)
13:35:26.799|METHOD_ENTRY|[60,13]|WebServiceCallout.invoke(IPNMessageWSDL.IPNMessageService, IPNMessageWSDL.upsertIPNMessage_element, MAP:String,IPNMessageWSDL.upsertIPNMessageResponse_element, LIST:String)
13:35:26.799|EXCEPTION_THROWN|[60,13]|System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
13:35:26.799|METHOD_EXIT|[60,13]|invoke(APEX_OBJECT, APEX_OBJECT, MAP, LIST)
13:35:26.799|METHOD_EXIT|[203,5]|upsertIPNMessage(String, String, String, String)
13:35:26.799|METHOD_ENTRY|[206,5]|System.debug(String)
13:35:26.799|USER_DEBUG|[206,5]|DEBUG|Error invoking upsertIPNMessage web service: System.QueryException: List has no rows for assignment to SObject
13:35:26.799|METHOD_EXIT|[206,5]|debug(ANY)

 

From the log, you can see that I am making the rollback call, yet the web service callout is failing with a error indicating I have uncommitted work pending. Any ideas why this doesn't work?

 

  • May 21, 2010
  • Like
  • 0

Hi,

 

I'm trying to rotate text within Visualforce page that is being rendered as PDF. I've managed to rotate the text in the HTML  version of the page by applying the two browser specific CSS styles that are supported by Firefox and IE below:

 

 

-webkit-transform: rotate(90deg); -moz-transform: rotate(90deg);	

 

filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);

 

But, when I add the renderAs="PDF" attribute to the page and, the text is not rotated. Has anyone ever tried this? Does anyone know of a way to get it to work?

 

  • May 13, 2010
  • Like
  • 0

I'm trying to disable a commandButton on my VF page on click because I'm invoking a possibly long running action in my controller (10 seconds or more), and I wish to prevent the user from clicking the button again, and double submitting. I tried doing this using a simple javascript onclick function that disables the button and returns true. This doesn't work because once I disable the button in javascript, the action method doesn't get invoked in my controller. Any other suggestions?

  • October 29, 2009
  • Like
  • 0

Hi, I'm using the Force.com IDE for Apex/Visualforce development. I'm observing that some, but not all, of my Apex classes will not display the "outline" view in the Eclipse Force.com IDE. There are no compilation problems with these classes, but I cannot see the outline of methods, member variables, etc. Nor will the code assistance work for these classes. I have other classes for which outline and code assistance work fine. Any ideas?

  • September 30, 2009
  • Like
  • 0

I have a VF page that contains two apex:inputField components that are bound to sObject Date fields. A code snippet for these components is provided below:

<apex:selectList id="view" value="{!view}" size="1" title="Select View"> <apex:selectOption itemValue="all" itemLabel="All" /> <apex:selectOption itemValue="new" itemLabel="New" /> <apex:selectOption itemValue="awaitingProcessing" itemLabel="Awaiting Order Processing" /> <apex:selectOption itemValue="awaitingSeatAssignment" itemLabel="Awaiting Seat Assignment" /> <apex:selectOption itemValue="complete" itemLabel="Complete" /> <apex:selectOption itemValue="failed" itemLabel="Failed Processing" /> </apex:selectList> <span>&nbsp;&nbsp;Start Date: </span> <apex:inputField id="startDate" value="{!startDate.birthdate}" /> <span>&nbsp;&nbsp;End Date: </span> <apex:inputField id="endDate" value="{!endDate.birthdate}" /> <span>&nbsp;&nbsp;Records Per Page: </span> <apex:selectList id="pageSize" value="{!pageSize}" size="1" title="Page Size"> <apex:selectOption itemValue="10" itemLabel="10" /> <apex:selectOption itemValue="25" itemLabel="25" /> <apex:selectOption itemValue="50" itemLabel="50" /> <apex:selectOption itemValue="75" itemLabel="75" /> <apex:selectOption itemValue="100" itemLabel="100" /> <apex:selectOption itemValue="200" itemLabel="200" /> </apex:selectList>

 

 

As you can see, I've given each inputField a unique ID (startDate and endDate). When I load the page, if I tab to the "Start Date" field, the date picker pops up under the start date input field as expected. If I tab to the "End Date" field, the date picker also pops up under the start date input field. Also, if I click on the date hyperlink to the right of the end date field, the date is inserted into the start date field! Looking at the page source, I see the following:

<span>&nbsp;&nbsp;Start Date: </span>

<span class="dateInput dateOnlyInput">

<input id="thePage:theForm:filterBlock:startDate" name="thePage:theForm:filterBlock:startDate" onfocus="DatePicker.pickDate(true, 'thePage:theForm:filterBlock:startDate', false);" size="12" type="text" />

<span class="dateFormat">[&nbsp;<a href="javascript&colon;DatePicker.insertDate('7/2/2009', 'thePage:theForm:filterBlock:startDate', true);">7/2/2009</a>&nbsp;]

</span>

</span> <span>&nbsp;&nbsp;End Date: </span>

<span class="dateInput dateOnlyInput">

<input id="thePage:theForm:filterBlock:startDate" name="thePage:theForm:filterBlock:endDate" onfocus="DatePicker.pickDate(true, 'thePage:theForm:filterBlock:startDate', false);" size="12" type="text" />

<span class="dateFormat">[&nbsp;<a href="javascript&colon;DatePicker.insertDate('7/2/2009', 'thePage:theForm:filterBlock:startDate', true);">7/2/2009</a>&nbsp;]

</span>

</span>

 

 

Notice that the id of the generated input text fields are the same, even though I have explicitly assigned different IDs to each. This is why the date picker always seems to be bound to the start date field. Any idea what's going on here? Seems like a bug, but I was just wondering if anyone has any ideas.

 
  • July 02, 2009
  • Like
  • 0

Hi,

 

Maybe I'm missing something, but I'm having a problem using the apex:repeat tag to build a selectList control on my page. Here is the code:

 

<apex:selectList size="1" value="{!myOrder.DeliveryMethod__c}" >
<apex:selectOption itemValue="" itemLabel="-- None --" />

<apex:repeat value="{!deliveryMethods}" var="item">

<apex:selectOption itemValue="{!item}" itemLabel="{!item}" />

</apex:repeat>

</apex:selectList>

 

 

I know by inserting debug code into my page that the deliveryMethods collection has the values I want. But, the resulting selectList contains only the option that I added explicitly. Why am I unable to build the selectList using a repeat? Seems like a bug to me.

 

I know someone out there is going to suggest that I use an apex:selectOptions component, bound to a List<SelectOption> in my controller. Unfortunately I can't do that because this code resides within an apex:component, and I cannot pass a SelectOption[] as an attribute to my component. 

  • June 26, 2009
  • Like
  • 0
I have a package that adds some custom fields to one of the standard object types (the Opportunity object). These fields have custom validation rules associated with them. When I view the validation rule within my Developer Edition instance where I created the package, I see the symbol next to the validation rule that indicates it is contained within my package, however, when I deploy the package to a different Salesforce instance, the fields are added to the Opportunity object, but the validation rules are not present. Has anyone encountered problems with packaging validation rules associated with custom fields?
  • May 05, 2009
  • Like
  • 0
I'm trying to create for a custom object type that I have created. When I go to the queue creation page, my custom object type is not showing up in the list of available objects, while other custom object types are. In my case, my object type is part of a master/detail relationship in which the Account object is the master. Is there a limitation on queues in that you cannot create a queue on custom objects that are "detail" objects in the master/detail relationships? I didn't see this mentioned anywhere in the documentation.
  • April 08, 2009
  • Like
  • 0

Hi,

 

After updating to Summer 13' I get this error message  in my formerly FREE edition when I'm sending out emails with Outbound Emailing service: (SingleEmailMessage)

 

SINGLE_EMAIL_LIMIT_EXCEEDED, Failed to send email: []

 

I dig into it, and found this in the docs:

 

  • Single email messages sent with the sendEmail method count against the sending organization's daily single email limit.When this limit is reached, calls to the sendEmail method using SingleEmailMessage are rejected, and the user receives a SINGLE_EMAIL_LIMIT_EXCEEDED error code. However, single emails sent through the application are allowed.

So, it seems, that in my org the limit of sendig emails changed suddenly. (to around 10/day)

Does anybody have experiences with this, was this intentional? What can / shall I do now??

Thanks,

Robert

The mian goal is to set up web service which accept few parameters and based on that returns the file.

As it is my first try with webservices I do not know too much about it.

 

Input http call is GET type: https://cs8.salesforce.com/services/apexrest/RemoteActivation?company=abc&street=xyz

so parameters are passed in URL, for simplicity lets use just those two parameters.

 

I have found this article http://wiki.developerforce.com/page/Creating_REST_APIs_using_Apex_REST and followed the sample code. 

 

As a result came up with that:

@RestResource(urlMapping='/RemoteActivation/*')
global class as_remoteActivationService {
	
@HttpGet 
	global static String remoteActivation(RestRequest req, RestResponse res) {
		String company = req.params.get('company');
		String street = req.params.get('street');
				
		System.debug('COMPANY: ' + company);
		System.debug('STREET: ' + street);
		return 'Done';
	}

and error when saving:

Save error: Invalid type: HTTP GET/DELETE methods do not support parameters 

 

Now I do not understant it. Example code exacly says:

@HttpGet
  global static List<Case> getOpenCases(RestRequest req, RestResponse res) {

 and I have done the same and getting error. Why?

Ok, I feel kind of dumb asking this, but I'm trying to get double quote characters to appear in either the title or subtitle attributes of an <apex:sectionHeader>. I tried using &quot;, but that gets converted into "&#34;" in the rendered page. I also tried using the " character directly, but the Visualforce compile gets confused by the nested quotes in the title or subtitle attribute. Am I missing something obvious?

  • June 26, 2012
  • Like
  • 0

I've defined three different APEX REST endpoints (call them endpoint A, B and C). Each of these endpoints implements a GET method. I've created a Visualforce page that uses Javascript/AJAX to make calls to these REST endpoints through the AJAX proxy. Everything seems fine until I need to make HTTP GET calls to these three APEX REST endpoints in rapid succession (GET A, GET B, GET C). Analysis of the requests/responses shows that all three request are formed correctly, but the response to GET C is identical to the response for GET B. It seems like it is returning a cached response from the GET B call rather than the real response to the GET C call. If I slow things down, to allow more time in between the calls, the responses are what I would expect. Has anyone encountered anything like this?

  • March 20, 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

Here's the Apex REST class:

@RestResource(urlMapping='/abc/def/*')
global with sharing class TheRESTclass
{
  @HttpGet
  global static String doGet(RestRequest req, RestResponse res)
  { return 'hello'; }
}

 

From the Apigee Salesforce console, I call the following URL (using OAuth authentication):

https://na7.salesforce.com/services/apexrest/abc/def

 

I've also tried it with the namespace in there:

https://na7.salesforce.com/services/apexrest/namespace/abc/def

 

But I keep getting this error:

 "message": "Could not find a match for URL /namespace/abc/def", "errorCode": "NOT_FOUND"

 

I've looked at multiple tutorials and they all guided me in the same direction. So I don't know what I could be possibly missing. Do I need to comfigure Remote Site Settings or do any other type of configuration?

 

Thanks in advance.

I am working on a project that has a very large Visualforce page.  I'm breaking it down into more manageable chunks by using a "State" object that encapsulates information about a particuar state inside of smaller objects.  The base class is abstract, and each state extends that abstract class to provide different functionality.  Anyhow, one state manages a purchase order and has a method called getPO ().  I can access that method via an Apex expression like this:

 

{!curState['PO'].PO_Number__c}

 

In that object (which works perfectly).  Obviously I cannot access the getPO() method directly because the base class does not have that method and the Controller that maintains the state object returns the abstract State obejct, I also have a method called getLineItems() that returns a collection of objects (line items on a purchase order).  The collection is a "List."  I can actually test this such as:

 

<apex:outputText value="{!curState['LineItems']}"/>

 

Which shows the collection as having the correct number of elements.

 

When I attempt to iterate over that collection in a pageBlockTable such as:

 

<apex:pageBlockTable id="lineItems" value="{!curState['LineItems']}" var="t">


it will not compile.  The error message is:

    Save error: Cannot coerce from class core.apexpages.el.adapters.RuntimeTypeMetadataELAdapter to class java.lang.Boolean

 

Perhaps I'm misunderstanding what Datatable should take in the value.  However, if I put the exact same list in the controller class, it WORKS.  Any ideas on how I can fix this?

 

Thanks in advance.

 

  • October 05, 2011
  • Like
  • 0

Hi.

 

One of my client needs to know how an Email Address is validated

by salesforce,because the same validation rule /specification should be done

with another application/system the client uses.

 

This is to balance the Email validation  specification  in both systems/application.

 

Thanks

suresh

Hi,

 

I have a pretty simple custom component that is in a managed package and deployed to an organization that has no namespace. In this case, Salesforce seem to be having an issue resolving the correct namespace. Here is the simplest way of reproducing the issue:

 

1, First create a custom page that will be the target of our button that is in our custom component:

 

<apex:page >
  <h1>Target Page</h1>
</apex:page>

 

 

2. Create a custom controller called TestController:

 

global with sharing class TestController
{

    public TestController()
    {

    }
    
    public PageReference goToNextPage()
    {
    
        return Page.test__TestNextPage__c;
    }
    
    static testMethod void runTestCases()
    {
        TestController t = new TestController();
        system.assertEquals(t.goToNextPage().getUrl(), Page.test__TestNextPage__c.getUrl());
    }   
}

 3. Now create a custom component that will use the above controller:

 

<apex:component controller="TestController" allowDML="true" access="global">
 
 <h1>Test componet</h1>
 <apex:form >
     <apex:pageBlock id="testBlock" title="Test Block" rendered="true">
     
         <apex:pageBlockButtons location="top">
            <apex:commandButton action="{!goToNextPage}" rendered="true" value="Go To Next Page" disabled="false" />
         </apex:pageBlockButtons>
     
     </apex:pageBlock>
 </apex:form>
</apex:component>

4. Now package this up as a managed package and deploy it into an ORG that has no namespace defined.

5. In the new ORG, create a new custom visualforce page that will use the packaged test component:

 

 

<apex:page >
  <h1>Test Page</h1>
 
  <test:TestComponent id="testComponent" rendered="true" />
</apex:page>

6. Now when you navigate to the page, and click on the "Go To Next Page" button you get the following error:

 

URL No Longer Exists

If you then add a namespace to the same ORG, the button starts working. Any ideas, suggestions?

 

Thanks!

 

 

 

 

Hi,

 

I'm trying to rotate text within Visualforce page that is being rendered as PDF. I've managed to rotate the text in the HTML  version of the page by applying the two browser specific CSS styles that are supported by Firefox and IE below:

 

 

-webkit-transform: rotate(90deg); -moz-transform: rotate(90deg);	

 

filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);

 

But, when I add the renderAs="PDF" attribute to the page and, the text is not rotated. Has anyone ever tried this? Does anyone know of a way to get it to work?

 

  • May 13, 2010
  • Like
  • 0

Note : Following is a small development being carried out to demystify salesforce apex webservice and callout features, please correct me if you find my understanding to be incorrect.

 

I am trying to integrate two Salesforce Orgs using Apex. Apex supports both callouts and webservices, then why not leverage both to achieve a 360 connectivity between two Salesforce instances.

 

Org1 : Create a Apex Web Service, Generate its WSDL

global class AccountPlan {

webservice String area;
webservice String region;

//Define an object in apex that is exposed in apex web service
global class Plan {
webservice String name;
webservice Integer planNumber;
webservice Date planningPeriod;
webservice Id planId;
}

webservice static Plan createAccountPlan(Plan vPlan) {

//A plan maps to the Account object in salesforce.com.
//So need to map the Plan class object to Account standard object
Account acct = new Account();
acct.Name = vPlan.name;
acct.AccountNumber = String.valueOf(vPlan.planNumber);
insert acct;

vPlan.planId=acct.Id;
return vPlan;
}

}

 

Org2:  Consume above generated WSDL to generate following Apex Class viz.,AccountPlanClasses

public class AccountPlanClasses {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','LogCategory','1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','LogCategoryLevel','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
............................
............................

 

Now lets try to connect to Org1 from Org2

AccountPlanClasses.Plan plan = new AccountPlanClasses.Plan();
plan.name = 'Chirag';
plan.planNumber = 111;
AccountPlanClasses.AccountPlan a = new AccountPlanClasses.AccountPlan();
a.createAccountPlan(plan);

 

Execution of above code runs into following error

WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor= 

 

I to feel that somewhere I am missing User Credentials to be supplied, but I dont know exactly where. Please guide me to complete this 360 connectivity between two orgs using Apex.

Message Edited by Chirag Mehta on 05-05-2009 06:13 AM
Message Edited by Chirag Mehta on 05-12-2009 07:52 PM
I'm trying to get an actionSupport to work with a lookup field.

Code:
<apex:inputField id="adviser" value="{!claimNotification.Adviser__c}">
 <apex:actionSupport action="{!updateAdviserDetails}" event="onchange" immediate="false" status="stat" rerender="adviserEmail,adviserPhone,adviserFax" />
</apex:inputField>



It works if I type the name of the new adviser in the textbox and tab out of the field but does not work if I click the search button next to the lookup field and select a new adviser that way.

How do I trigger the actionSupport when the search button is clicked?