• gregs
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 23
    Replies

I am getting a DML not allowed on generic list error when running some apex code that inserts a list of custom objects into the database.  The code snippet below creates two custom objects and stores them as concrete types in a generic list (List<sObject>).  However, when i try to insert the custom objects into the database using a single insert statement on the list, i get the DML not allowed on generic list error, even though when i inspect the output in the debug window I can clearly see that the list contains two concrete custom objects… Any idea why I am getting this error?  This seems like an inconsistency...

 

code:
List<sObject> itemsToInsert = new List<sObject>();


sObject outputCategoryTypeSO = new AgreementLineItemCategoryType__c(AgreementLineItemCategory__c = outputCategorySO.Id);itemsToInsert.add(outputCategoryTypeSO);


outputCategoryTypeSO = new AgreementLineItemCategoryType__c(AgreementLineItemCategory__c = outputCategorySO.Id);itemsToInsert.add(outputCategoryTypeSO);


system.debug(LoggingLevel.INFO, 'itemsToInsert = '+itemsToInsert);
if (!itemsToInsert.isEmpty()) {

    Database.insert(itemsToInsert);

}

debug log:
11:11:58:442 USER_DEBUG [210]|INFO|itemsToInsert = (AgreementLineItemCategoryType__c:{AdjustmentType__c=% Discount, AgreementLineItemCategory__c=a5GS00000004CxzMAE, PriceMethod__c=Per Unit, Product_Type__c=Maintenance, ItemSequence__c=1, PriceType__c=One Time, ConfigurationId__c=a3LS00000008btoMAA, IsOptionRollupLine__c=false, Quantity__c=1.00000, BasePriceMethod__c=Per Unit, Term__c=1, PriceUom__c=Each, SellingFrequency__c=One Time, LineNumber__c=1, ChargeType__c=Standard Price, Description__c=Acrobat Desk-09946063, AdjustmentAmount__c=2.00000, Frequency__c=One Time, LineType__c=Product/Service, SummaryGroupId__c=a3YS0000000CchoMAC, Uom__c=Each}, AgreementLineItemCategoryType__c:{AdjustmentType__c=% Discount, AgreementLineItemCategory__c=a5GS00000004CxzMAE, PriceMethod__c=Per Unit, Product_Type__c=Maintenance, ItemSequence__c=1, PriceType__c=One Time, ConfigurationId__c=a3LS00000008btoMAA, IsOptionRollupLine__c=false, Quantity__c=1.00000, BasePriceMethod__c=Per Unit, Term__c=1, PriceUom__c=Each, SellingFrequency__c=One Time, LineNumber__c=2, ChargeType__c=Standard Price, Description__c=Acrobat Desk-09946064, AdjustmentAmount__c=3.00000, Frequency__c=One Time, LineType__c=Product/Service, SummaryGroupId__c=a3YS0000000CchoMAC, Uom__c=Each})
11:11:58:442 DML_BEGIN [215]|Op:Insert|Type:SObject|Rows:2
11:11:58:443 EXCEPTION_THROWN [215]|System.TypeException: DML not allowed on generic List<SObject>

 

What is really interesting is that if i make a simply change to the code to insert the items one at a time it works:

 

if (!itemsToInsert.isEmpty()) {

    for (sObject insert_item:itemsToInsert)  {

        system.debug(LoggingLevel.INFO, 'insert_item = '+insert_item);

        Database.insert(insert_item);

    }

}


Thanks


  • November 09, 2011
  • Like
  • 0

We have a self service portal that we want to convert to a customer portal based system so it can be integrated with a force.com sites implementation hosted in the same org.  There are currently many self service users already setup in the system.  Can these be easily converted to customer portal users so I don't have to recreate all users when setting up the customer portal?  If so, how could this be done?  Thanks

  • July 28, 2011
  • Like
  • 0

I have a force.com sites visualforce page that is publicly exposed and is not rendering the Notes & Attachments related list even though this renders correctly for authenticated users or for other salesforce related objects that i have explicitly set permissions for in my guest access profile.   Here is the vf page snippet:

 

 

<apex:page standardController="MyCustomObject__c" extensions="MyControllerExtensionClass" showHeader="true" sidebar="true" cache="false" tabStyle="MyCustomObject__c" action="{!onLoad}">
<apex:form> 
….
</apex:form>
<!--
include attachments related list below the form
since apex:relatedList tags cannot be nested within form tags
-->
<apex:relatedList list="NotesAndAttachments" rendered="true" />
</apex:page>
Is there a reason the notes and attachments related list is not rendering?  Also there is noplace on the guest permissions page i see where i can explicitly give the user permissions to view, create, edit and delete attachments...
thanks

 

  • May 10, 2011
  • Like
  • 0

I am getting the following error trying to save/compile an apex class which is managed beta (not yet released):

 

Managed type that is released without a supertype can not subsequently extend another type

 

Why am i getting this error on the BaseExtObject class below if i have the following classes and interfaces defined:

 

 

global virtual interface ObjectAInterface {...}
global virtual interface ObjectBInterface {...}
global virtual interface ObjectCInterface {...}
global virtual class BaseObject implements ObjectAInterface, ObjectBInterface, ObjectCInterface {…}
global virtual class BaseExtObject extends BaseObject {…}

 

 

  • February 08, 2011
  • Like
  • 0
Does anyone know of any way for a developer to provide a managed visualforce page inside a managed package that customers can override with their own visualforce page layout and/or controller logic? The use case is we have an out of the box visualforce page in our managed package that users want to customize to add their own custom fields the as well as add some logic to the page that pre-populates some of the fields when it is loaded based on some logic. While this could easily be done with s-controls or unmanaged code, is there a way to do this using managed code?
  • May 14, 2010
  • Like
  • 0
Is it possible to for a client application using the WebRequest .NET class to create a custom SOAP request that can send an http request via the web services api and parse the response? I know i need to include the current session id and server url in the request, but how do i create the rest of the request content? What i want to do is call the merge fields servlet, /servlet/MergeFields.servlet (previously used by the connect for office toolkit and office toolkit 3.0) and retrieve the xml response it sends back. How can i do this? Can someone point me to some sample .net source code? Here is what i have so far:

//hardcode mergefield servlet url since there is no web services api method to get it
String url = host + "/servlet/servlet.MergeFields";
String postData = "?encoding=UTF-8";

//create request to get mergefields from salesforce mergefields servlet
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "text/xml";
request.ContentLength = postData.Length;

//how do i add the session and login credentials here?
//and is the url in the create call above the url i want to send, or is is the soap endpoint, something like
//https://na7.salesforce.com/services/Soap/u/17.0

//encode data
byte[] data = Encoding.ASCII.GetBytes(postData);
Stream input = request.GetRequestStream();
input.Write(data, 0, data.Length);
input.Close();

//get response
HttpWebResponse myResponse = (HttpWebResponse)request.GetResponse();
Stream respStream = myResponse.GetResponseStream();

StreamReader streamRead = new StreamReader(respStream);
String respStr = streamRead.ReadToEnd();

XmlDocument doc = new XmlDocument();
doc.LoadXml(respStr);
  • November 12, 2009
  • Like
  • 0

I have a formula field that i want to display a hyperlink to a visualforce page if the value if the current userid is a member of a given queue.  What i want to do is something like this:


IF (

$User.Id IN [select Id,Name,Type,(select UserOrGroupId From GroupMembers) from Group where Type='Queue'], "some link if true",

"some link if false"

)

 

Is there any way to do something like this straight from a formula field without just going to a visualforce page that has that logic in the controller?

  • August 25, 2009
  • Like
  • 0

Sometimes when my visualforce page gets called from the UI it just seems to "hang" or timeout and never renders.  Upon looking at the log, i see the following entry:


Status Success Application Browser
Request Type Application Operation /apex/myCustomPage
Duration (ms) 191 Log Length 86
Log Element thePage called method {!checkManageability} returned type PageReference: none 

What does this mean when checkManageability returns PageRerference none?

  • August 10, 2009
  • Like
  • 0

Is v4.0 of the office toolkit included in the latest release of the office edition (1.8.0.7)?  I see there was an installer for the toolkit on the force.com site, but didn’t see any notes about whether or not it was included in the latest version of the office edition (connect for office)… If it is not in there, are there plans to replace the 3.0 version of the toolkit currently in the connect for office product with the 4.0 version?

  • May 29, 2009
  • Like
  • 0

We have had some customers install our applications from the appexchange, which uses the LMA to track and enforce who installs the app.  However, in some circumstances, and we are not sure when or why, the lead, contact, and/or account info collected at the time of installation is missing so we cannot determine who installed the app.

 

Can you think of any reason this would occur?

 

Also, there is apparently no update version history shown when a person updates an app to a newer version.  Only the initial install date is recorded.  We need to know when they last updated the app as well.  Is there any way to get that info from the LMA?

Message Edited by gregs on 04-30-2009 11:36 AM
  • April 30, 2009
  • Like
  • 0

How can I use a relative salesforce URl link in a visualforce email template?  For example, instead of the following, which works, but uses a hard coded host url:

 

<a href="https://na6.salesforce.com/{!relatedTo.Id}">https://na6.salesforce.com/{!relatedTo.Id}</a>

I want something lilke this, but the outputLink tags cause an error when the email is sent from the email api using this template...

 

<apex:outputLink value="/{!relatedTo.Id}">{!relatedTo.Id}</apex:outputLink>

 

Since there is not a way to associate a custom controller with a visualforce email template, how can I specify the URL in a non-hardcoded way?

  • March 20, 2009
  • Like
  • 0

i am getting an error "sObject type weblink is not supported" when trying to query the weblink table from the api within an application to get the name of a custom button and link.  what permissions do i need to setup for the user's profile in the ui for this to work?

  • February 02, 2009
  • Like
  • 0

Why is the error occuring below when i run the following sql inside an scontrol (where tags are enabled on my custom object)?

 

select Id,TagDefinitionId,ItemId,CreatedDate,SystemModstamp,IsDeleted,Name,Type from MyCustomObjectName__Tag where ItemId = 'a0PR0000000jlUM'

 

message: sf:UNKNOWN_EXCEPTION

fields: UNKNOWN_EXCEPTION: An unexpected error occured.  Please include this errorId if you contact support: ...... some error code

 

 

but if i run the same code as anonymous apex, i get a different error:

 

13:50:26 ERROR - Evaluation error: System.Exception: ORA-00904: "T"."KEY_PREFIX": invalid identifier : select /*gatherSlowStats*/ count(1) from core.tag t where (t.entity_id = ?) and rownum <= ? and (t.organization_id = ?) and (t.key_prefix = ?)
13:50:26 ERROR - Evaluation error: AnonymousBlock: line 1, column 33

 

Any reason why i am getting these errors?

 

 

 

 

Message Edited by gregs on 01-23-2009 01:55 PM
  • January 23, 2009
  • Like
  • 0
I am trying to deploy some updated and new Apex classes to a sandbox using an ant script.  The initial deployment worked perfectly with no errors, however, when i try to deploy a new class and an updated class it causes the following error:
 
C:\Users\devuser\Documents\dev\devDeploy>ant deployCode > deployCodeLog.txt
 
BUILD FAILED
C:\Users\devuser\Documents\dev\devDeploy\build.xml:45: UNKNOWN_EXCEPTION msg: While running test DevActionTest - UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 1874638991-94 (637441531)
 
What is causing this error?  How can I determine what is going wrong?  The error is complaining about a test class that runs perfectly fine by itself or with all other classes when running all tests in the UI or all tests through the ant deployment script.


Message Edited by gregs on 11-19-2008 07:00 PM
  • November 20, 2008
  • Like
  • 0

The apex manual says the following about deploying classes to production:

Understanding deploy
The deploy call completes successfully only if all of the following are true:

• 75% of your Apex scripts are covered by unit tests, and all of those test complete successfully.
Note the following:
◊ When deploying to a production organization, every unit test in your organization namespace is executed
◊ Calls to System.debug are not counted as part of Apex code coverage in unit tests.
• Every trigger has some test coverage.
• All classes and triggers compile successfully.

Question: Doe EACH apex class need to get >75% code coverage or only ALL CLASSES AS A WHOLE?

  • November 17, 2008
  • Like
  • 0
I am trying to debug a testmethod and have included several system.debug statements in the method.  However, when I run the testmethod from the user interface in salesforce and look at the debug log, many of the debug statements are not showing up in the log even though I know they are getting executed.  Is this a bug or is there another way to see debug output from testmethods?
  • August 28, 2008
  • Like
  • 0
Can the office toolkit (v3.0 or a future 4.0 release) be used with single sign on so that a user only needs to logon once to the application in an office edition enabled app such as the word addin that allows users to insert merge fields into a word document?  If so, any idea how?  If not, could an office app created with the office toolkit use a pure web service to do this in conjunction with vba toolkit code?
  • August 27, 2008
  • Like
  • 0
How can i get access to the frontdoor urlDetail, edit and new values for an object from its descibe info in Apex?  I don't see this field in the documentation....
  • August 14, 2008
  • Like
  • 0
I am creating a moderate class which is about 38,769 bytes in Eclipse but when I try to save it back to salesforce i get the message:
"Save error: The total size of apex code in this application after removing comments exceeds the maxiumum character size of 1000000".
I don't see how this can be since i clear have less than 1,000,000 bytes.  Any ideas? 
  • August 01, 2008
  • Like
  • 0
Does anyone know of a good source code formatter than can be used for Apex code to make it consistent?  Open source would be best... thanks
  • August 01, 2008
  • Like
  • 0
Does anyone know of any way for a developer to provide a managed visualforce page inside a managed package that customers can override with their own visualforce page layout and/or controller logic? The use case is we have an out of the box visualforce page in our managed package that users want to customize to add their own custom fields the as well as add some logic to the page that pre-populates some of the fields when it is loaded based on some logic. While this could easily be done with s-controls or unmanaged code, is there a way to do this using managed code?
  • May 14, 2010
  • Like
  • 0

We have a Approval Processees developed within Salesforce on Opportunity. However, since Salesforce does not provide any reporting capabilities on these Processees, we are going to populate different object to then use for reporting, on the Opp Trigger.

 

We can get most of the information from the Process related objects within Salesforce, but I do not see the name of the Steps or Process in these objects.

 

Is there a way to get the name of the Processes Steps and Processes Name, which we would to display in our reports, either by doing SOQL or by using Approval related APIs.

 

Thanks

 

Regards.

 

  • October 01, 2009
  • Like
  • 0

The last two days I have received the message "Incompatible viewstate version detected!" when attempting to access different custom VF pages. I have never encountered it before and it doesn't cause any exceptions that I can log and I cannot seem to duplicate it either.

 

Curious if anyone has seen the same message or knows what it is referring to.

  • March 06, 2009
  • Like
  • 0

i am getting an error "sObject type weblink is not supported" when trying to query the weblink table from the api within an application to get the name of a custom button and link.  what permissions do i need to setup for the user's profile in the ui for this to work?

  • February 02, 2009
  • Like
  • 0
Hi..
    
       Here I am using styleclass in my PDF.. I have two issues..
 
1. I got my expected output while I am using outputtext instead of outputfield.. If I am using outputfield in VF page
    my styleclass doesnt work..
 
                If I am using inline style with outputfield  my PDF is rendered correctly...
 
                What is the problem here...
 
2.I got one blank first page in my PDF.... How to avoid it...
 
Here is my code
Code:
<apex:page standardcontroller="Account"  renderas="pdf"
<style>
.centerHeader1
{
font-size:130%;
font-weight:bold;
text-align:center;
}
.leftHeader
{
font-size:50%;
text-align:right;
}
.centerHeader2
{
font-size:50%;
text-align:center;
}
.imageHeader
{
width:90px;
height:50px;
}
</style>
<apex:form >
<div style="page-break-before:always">
<table width="100%"><tr>
<td align="left" width="33%">
<apex:outputtext styleclass="leftHeader" value="leftHeader class"/><br/>
</td>
<td align="center" width="33%">
<i>
<apex:outputtext styleclass="centerHeader1" value="centerHeader1 class"/></i><br/>
<apex:outputtext styleclass="centerHeader2" value="centerHeader2 class"/>
</td>
<td align="right" width="33%">
<!-- <apex:image value="{!$Resource.Logo_PDF}" styleclass="imageHeader"/> -->
</td>
</tr>
</table>
<br/><br/>
<!-- <apex:outputfield value="{!Account.Name}" styleclass="centerHeader1"/> -->
<apex:outputtext value="{!Account.Name}" styleclass="centerHeader1"/>
</div>
</apex:form>
</apex:page>

 
Hi All,
 
I have an urgent issue. Please give me ideas. Many thanks
 
-- one trigger on account
-- this trigger deployed into producton in a managed package. That means we can not do any modification on that. Even no way to edit "active" checkbox.
-- Code "Schema.getGlobalDescribe().get('Account');" in this trigger
-- when I use apex dataloader mass upload data, an error depressed me
 

caused by: System.Exception: Too many fields describes: 11

I think the Governors and Limits for describe call in trigger allows max no. is 10 as well.  Is that true?????????

-- This trigger calls apex class code. In the apex class code there is a Webservice method callout. In this apex class code, there is a "future" annotation as well. In the apex developer document, governors say

Total number of methods with the future annotation allowed  per Apex invocation7     :   10

Total number of Web service methods allowed :  10

I believe if mass update records number > 10 , those limits will reach and some error  will occur.

-- How can I turn off the trigger in Production which in managed package (released version).

 

Any idea appreciated!!! or Any clarification for that???

Hi,

I had EmployeeBefore and EmployeeAfter triggers. I deleted them from Eclipse but how do I get rid of it in SF. I created a new trigger called EmployeeTrigger. When I run tests it is still executing those two deleted triggers along with Employee Trigger. So for some reason I need to delete it from Salesforce. Under src, I right clicked on Triggers and said save to server but it is still executing both before and after triggers.


Quick help would be appreciated.

thanks in advance,
kathyani
I am trying to deploy some updated and new Apex classes to a sandbox using an ant script.  The initial deployment worked perfectly with no errors, however, when i try to deploy a new class and an updated class it causes the following error:
 
C:\Users\devuser\Documents\dev\devDeploy>ant deployCode > deployCodeLog.txt
 
BUILD FAILED
C:\Users\devuser\Documents\dev\devDeploy\build.xml:45: UNKNOWN_EXCEPTION msg: While running test DevActionTest - UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 1874638991-94 (637441531)
 
What is causing this error?  How can I determine what is going wrong?  The error is complaining about a test class that runs perfectly fine by itself or with all other classes when running all tests in the UI or all tests through the ant deployment script.


Message Edited by gregs on 11-19-2008 07:00 PM
  • November 20, 2008
  • Like
  • 0
Hey,

Anybody come across this problem before?  Here's some code to send out a single e-mail:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage ();
mail.setToAddresses ( new String[] { 'xxx.yyy.zzz' } );
mail.setSubject ( 'TEST' );
mail.setPlainTextBody ( 'TEST' );

Messaging.sendEmailResult[] results = Messaging.sendEmail ( 
                                           new Messaging.SingleEmailMessage[] { mail } , False
                                      );
for ( Messaging.sendEmailResult result : results ) {
    if ( !result.isSuccess () ) {
        System.debug ( result );
} }

Note the deliberately bogus e-mail address.  When you run this, the following text is debug'ed out:

Messaging.SendEmailResult[
  getErrors=(
    Messaging.SendEmailError[
      getFields=null;
      getMessage=Invalid to address xx.yyy.zzz;
      getStatusCode=System.StatusCode.INVALID_EMAIL_ADDRESS;
      getTargetObjectId=null;
    ]
  );
  isSuccess=false;
]

 
Note that the getErrors() "member" is a Messaging.SendEmailError[] array, as specified in the Apex Ref Guide.

Now change the loop to

for ( Messaging.sendEmailResult result : results ) {
if ( !result.isSuccess () ) {
Messaging.sendEmailError[] errs = result.getErrors ();
}
}

Seems reasonable, based on the first code fragment - but in fact it doesn't even compile:
Illegal assignment from LIST:Database.Error to LIST:Messaging.SendEmailError

So - change the loop as follows:

Code:
for ( Messaging.sendEmailResult result : results ) {
if ( !result.isSuccess () ) {
Database.error[] errs = result.getErrors ();
}
}

and it compiles, but now throws a run-time error, to the effect that you can't cast a Messaging.SendEmailError object to a
Database.error. Seems like some sort of internal inconsistency.

OK - now here's the real WTF about this: Everything I've written here was demonstrably true until 30 min ago - but as of now -
 the last loop does not throw that run-time error any more! I would just discard this msg, but it took me a certain amount of effort
and now I'd like to share my worry about the behaviour of production orgs (yes, I was testing both in Sandbox and in Prod
throughout) changing in the middle of a working day.

Thoughts/insight anyone?
 
  • November 17, 2008
  • Like
  • 0
We are suddenly facing a new problem in our code this week.

Schema.SObjectType.Contact.fields.getMap() was returning values when the code is unmanaged state - but when we move this class into a Managed package we are find that it return an empty value.

We saw this first time over the weekend - did anything change with the upgrade this week - any change in API etc...

Any assistance or insight would be appreciated.

Thanks
RG

Hi,

I want to be able to get all the fields for the Opportunity. I am writing custom code for cloning an opportunity.
I had the following piece of code which was working but suddenly has stopped working.

Code:
        Map<String, Schema.SObjectField> m = Schema.SObjectType.Opportunity.fields.getMap();
        System.debug('isEmpty = ' + m.isEmpty());

This now returns an empty map.
Any ideas why this call would return an empty map.

Thanks,
Rohit

Can the office toolkit (v3.0 or a future 4.0 release) be used with single sign on so that a user only needs to logon once to the application in an office edition enabled app such as the word addin that allows users to insert merge fields into a word document?  If so, any idea how?  If not, could an office app created with the office toolkit use a pure web service to do this in conjunction with vba toolkit code?
  • August 27, 2008
  • Like
  • 0
How can i get access to the frontdoor urlDetail, edit and new values for an object from its descibe info in Apex?  I don't see this field in the documentation....
  • August 14, 2008
  • Like
  • 0
I am creating a moderate class which is about 38,769 bytes in Eclipse but when I try to save it back to salesforce i get the message:
"Save error: The total size of apex code in this application after removing comments exceeds the maxiumum character size of 1000000".
I don't see how this can be since i clear have less than 1,000,000 bytes.  Any ideas? 
  • August 01, 2008
  • Like
  • 0
I'm passed an object id and want to clone it. I'm guessing I need to write a soql query to get an instance of the object then clone it but I don't want to hard code all the field names as they may change. Is there a way to do a select * or a way of getting the object that doesn't involve hard coding?

We have an application that runs in a web tab and for this one specific user we are getting this error when they click on the tab.

INVALID_FIELD: SELECT ProfileId FROM User WHERE Id = '123456ABCDEFG' ^ ERROR at Row:1:Column:8 No such column 'ProfileId' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

Note: I have masked the Id, we are using a real Id not 123456ABCDEFG

I believe but cannot confirm that it is because the user does not have permission to "View Setup and Configuration"... any ideas?

Cheers!

  • September 22, 2005
  • Like
  • 0