• Mat Schaffer
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies

So I'm working on a component which uses quotas (via RevenueForecast object), but I'd like the app to be able to operate without quotas.

 

I have a method in my controller like this:

  public RevenueForecasts[] getRevenueForecasts() { ... }

 

But if I try to deploy the app into an org that doesn't have customizable forecasting enabled I get a compile error because the org doesn't know about RevenueForecast.

 

Is there some way to code to a generic type (maybe sObject?) so that I can just return a null quota if the org doesn't have RevenueForecast objects available?

 

Thanks,

Mat

So content seems to get escaped for HTML automatically, but I'd like to create JSON in a page if possible.  I can't seem to find any way to do this.

 

I posted an example app at http://github.com/matschaffer/apex-injection-test that shows the output I'm trying to pull and escape. Right now the javascript injection executes successfully.

 

It's looking like I may need to just stick to HTML or do the javascript escaping myself in an Apex class. I found this which looks promising http://apex-google-visualization.googlecode.com/svn/trunk/GoogleVisualizations/src/classes/JSONObject.cls but they've commented out the quote() method so I'll have to figure out how to get it back in there.

 

Thanks in advance for any advice,

Mat

So I have a file in my project src/document/hooplalogo.jpg and I'm trying to deploy it using the ant migration tool. I noticed on http://www.salesforce.com/us/developer/docs/api_meta/Content/file_based.htm that you can't use the wildcard on document resources so I tried adding this to my package.xml:

 

  <types>
    <members>hooplalogo.jpg</members>
    <name>Document</name>
  </types>

 

But when I run `ant deploy` I get this:

 

Error: package.xml(hooplalogo.jpg):An object 'hooplalogo.jpg' of type Document was named in package.xml, but was not found in zipped directory

 

It looks like maybe the migration tool just doesn't support deployment of documents. Is that the case?

 

Thanks in advance for any help,

Mat

 

So I'm working on a component which uses quotas (via RevenueForecast object), but I'd like the app to be able to operate without quotas.

 

I have a method in my controller like this:

  public RevenueForecasts[] getRevenueForecasts() { ... }

 

But if I try to deploy the app into an org that doesn't have customizable forecasting enabled I get a compile error because the org doesn't know about RevenueForecast.

 

Is there some way to code to a generic type (maybe sObject?) so that I can just return a null quota if the org doesn't have RevenueForecast objects available?

 

Thanks,

Mat

So content seems to get escaped for HTML automatically, but I'd like to create JSON in a page if possible.  I can't seem to find any way to do this.

 

I posted an example app at http://github.com/matschaffer/apex-injection-test that shows the output I'm trying to pull and escape. Right now the javascript injection executes successfully.

 

It's looking like I may need to just stick to HTML or do the javascript escaping myself in an Apex class. I found this which looks promising http://apex-google-visualization.googlecode.com/svn/trunk/GoogleVisualizations/src/classes/JSONObject.cls but they've commented out the quote() method so I'll have to figure out how to get it back in there.

 

Thanks in advance for any advice,

Mat

So I have a file in my project src/document/hooplalogo.jpg and I'm trying to deploy it using the ant migration tool. I noticed on http://www.salesforce.com/us/developer/docs/api_meta/Content/file_based.htm that you can't use the wildcard on document resources so I tried adding this to my package.xml:

 

  <types>
    <members>hooplalogo.jpg</members>
    <name>Document</name>
  </types>

 

But when I run `ant deploy` I get this:

 

Error: package.xml(hooplalogo.jpg):An object 'hooplalogo.jpg' of type Document was named in package.xml, but was not found in zipped directory

 

It looks like maybe the migration tool just doesn't support deployment of documents. Is that the case?

 

Thanks in advance for any help,

Mat

 

I'm using the metadata API and deleting some of the custom fields on custom sobjects. I'm able to get them deleted, but when I go into SalesForce Web, I then have to erase the deleted fields.

 

Is there any way to programatically erase the fields also?

 

 

Here's the code that is deleting the fields.

private List<AsyncResult> ThrottledDelete(List<Metadata> deleteItems, int ThrottleSize) { List<AsyncResult> AllResults = new List<AsyncResult>(); while (deleteItems.Count() > 0) { List<Metadata> SmallList; if (deleteItems.Count() < ThrottleSize) { SmallList = deleteItems; deleteItems = new List<Metadata>(); } else { SmallList = deleteItems.GetRange(0, ThrottleSize); deleteItems = deleteItems.Except(SmallList).ToList(); } AsyncResult[] results = metaService.delete(SmallList.ToArray()); results = WaitForResults(results, 1000); AllResults.AddRange(results); } return AllResults; }

 

 

Thanks for any input,

Jeff

I am having the following error in my unit tests. I was unable to find any information on this error in the documentation. Would like to know if possible whether this is a current limitation in Apex, that is not documented, or I am missing something.

This woks fine in pre-summer 08 orgs, but is failing in my Summer 08 enabled sandboxes.

Here is my code

Code:
static testMethod void InsertInvestmentAccountBulkTriggerBypass(){


User user = [Select Id From User Where Id =: UserInfo.getUserId()];
user.Bypass_Triggers__c = 'SCS_Investment_Account_Time_Series__c;Asset';

update user;

System.assert(GlobalSettings.bypassTriggers('Asset'));
System.assert(GlobalSettings.bypassTriggers('SCS_Investment_Account_Time_Series__c'));

Test.startTest();
Map<Id, Asset> IAMap = unitTests.createTestAsset(200);
System.assertEquals(200, IAMap.size());
Test.stopTest();
}




public static Map<Id, Asset> createTestAsset(Integer numberOfRecords){

Map<Id, Asset> IAMap = new Map<Id, Asset>();
Asset [] IAs = new List<Asset>();

Account client = unitTests.createTestAccount();
Product2 fund = [Select Id from Product2 LIMIT 1]; //TODO: extract out as a helper method

for (Integer i=0; i<numberOfRecords; i++){
Asset IA = new Asset();

IA.Name = 'unitTest_IA';
IA.AccountId = client.Id;
IA.Product2Id = fund.Id;

IAs.add(IA);
}


public static Account createTestAccount(){

Account a = new Account();
a.Name = 'Test Account';
a.Employee_Id__c = '123456';
insert a;

System.assertEquals(1, [Select count() from Account where Id = : a.Id]);

return a;
}

insert IAs;

for(Asset ia : IAs){
IAMap.put(ia.Id, ia);
}

return
}

Full error message:

System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on non-setup object is not supported after you have updated a setup object: Account

Stack trace:
Class.unitTests.createTestAccount: line 94, column 9
Class.unitTests.createTestAsset: line 146, column 26
Class.TimeSeriesUnitTests.InsertInvestmentAccountBulkTriggerBypass: line 27, column 32



Basically, I need to update a current user record, prior to testing triggers. Problem is that I am not allowed to update a user record and then execute DML statements on other objects.


Message Edited by AxxxV on 05-28-2008 02:29 PM
  • May 28, 2008
  • Like
  • 0