• JerryH
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 16
    Replies

I've been able to figure out how to programmatically load / read the contents of a StaticResource...

 

    // resource name is "testAccount" in this case

    List<StaticResource> lstResource = [select Body from StaticResource where Name like '%Account'];
    dom.Document doc = new dom.Document();
    doc.load(lstResource.get(0).Body.ToString());

 

...but so far I haven't been able to figure out how to create a new StaticResource out of whole cloth and save it.  The API says it supports all of the standard accessors (create, update, etc.) but so far I haven't been able to get any combinations or permutations to work for me.

 

So is this possible?  And if it is, then what the heck am I doing wrong?

 

Jerry (Very Much Argh!) H.

 

  • January 18, 2011
  • Like
  • 0

Is there any way to retrieve a WRITEABLE reference to an SObject field at runtime?

 

Yes, I've seen all of the Schema.DescribeFieldResult stuff, and it's dandy if you want a READ-ONLY reference to the object metadata, but I was hoping to find a way to remap data from an existing Salesforce standard / default field into a set of user-defined custom fields.

 

What I'd like to do is pass in two field names at runtime and have the code-behind read the value from the first field and write it to the second field -- for purposes of illustration, something like:

 

    String data = Account.[field1];

    Account.[field2] = data;

 

Does anyone have a clue about how to do this?  I could hard-code a bunch of select statements into a bunch of methods, but I'd prefer to have a general-purpose reusable solution.

 

Jerry H.

 

  • December 09, 2010
  • Like
  • 0
We'd like to include a hyperlink on our website that points to the Salesforce free trial signup page (https://www.salesforce.com/form/signup/freetrial-lb.jsp), but I can't find any information about how to add a referral to the URL.
 
My guess (possibly a wrong one) is that we should be including some sort of "referer" information as a query string, so that Salesforce will know the click-through came from our web site... but so far I haven't been able to find anything in the Salesforce documentation about referrals or if / how to add one to an HREF.
 
This is all a W.A.G. on my part, but I'd think Salesforce would be interested in keeping track of click-throughs and referrals from other sites.  Am I wrong about this?
 
Jerry H.

The company I work for is getting ready to publish an Apex application in the AppExchange, and we'd like to be able to make some sort of Salesforce "terms of service" or "end user licensing" agreement available prior to installation -- the standard "I have read the agreement and checked this box to continue with the installation" kind of thing.

 

To clarify, we already have our own "terms of service" agreement we use for *our* applications sold by *our* company.  What I'm after is a TOS / EULA that would be appropriate for someone installing an application from the AppExchange into their own Salesforce.com organization area.

 

Is there a boiler-plate PDF document available from Salesforce for this sort of thing?  If so, where can I find a copy?

 

Thanks!

 

Jerry H.

 

Is there a known issue (or have I missed something in the documentation) with code coverage tests and static resources?  If I try to install my managed package and *do not* check the "Ignore Apex test failures" checkbox in Step 3 of 3 the installation will fail on any unit tests that use pre-configured test data coming from static resources.

 

The test files are wrapped into the installation as static resources, and when I run the code coverage tests from within the Force.com IDE (Eclipse) and / or within the Salesforce UI (Setup > App Setup > Develop > Apex Classes > Run All Tests) everythng passes with flying colors.  But when the coverage tests are run during installation the methods that try to load the static resource files always fail.

 

The odd thing is that the methods that I'm calling for these code coverage tests (REST calls to a web service running on our servers) work fine if I use the actual URL for our REST endpoint, but if I call the same methods using a URL that points to the static resource (e.g. "/resource/12345/Namespace__MyTestFile.xml") the tests will fail.

 

To restate things slightly, just to make sure I'm explaining the problem correctly:

 

-- Code coverage tests are calling all of the same methods using an actual REST endpoint URL and a pseudo endpoint URL that points to a series of static resource URL's.  The unit tests work fine (and pass the code coverage tests during deployment) for the live URL's but fail for the static resource URL's.

 

-- Both live and static resource URL's pass the code coverage tests when I run them from within the IDE and from the Salesforce development UI's.

 

Anyone have any ideas why code coverage tests during an install would fail for static resources?  I'm pretty much stumped at this point.

 

Jerry H.

 

I'm developing a managed package that will import customer data into Salesforce and create new Account / Opportunity / Task / Product records.  Since I'm using the "standard" set of Salesforce objects and schemas all of the information that is imported will be left behind if a customer uninstalls my application.

 

What I'd like to do is offer customers the option to either leave the imported data (how the uninstall works now, by default) *or* to remove both the application and the imported data.  Is there any way to hook into the Salesforce uninstall so that I can call my own code to clean up the imported data?  Maybe an extend / inherit that I can subclass to pick up on an "uninstall event"?

 

Thanks!

 

Jerry H.

 

I'm in the final stages of developing a SalesForce plugin, but I can't figure out how the end user would get to my Apex Page if I don't wrap the page in an Apex Tab.

 

My assumption (possibly incorrect, since I can't find anything that addresses this topic) is that something magical occurs when a plugin is packaged and made available in the AppExchange -- by "magical" I mean that any user who installs my plugin will suddenly "see" a new tab (?) or something (?) after the installation, and they'll be able to click on this thing (whatever it is) to display my Apex Page.

 

Is this actually the case?  Is some sort of "here's the application / plugin you've just installed" tab (or something?), or do I need to add some Apex Tab code to my Apex Page, or do I need to do something else entirely to give the user some sort of clue about how to access the plugin they've just installed?

 

Clues and tips gratefully accepted, URL's to existing SalesForce PDF's (unless you can explicitly provide the relevant quote from said PDF in your reply) not appreciated.  I've downloaded and read dozens of SalesForce PDF's, and done all sorts of Google and other searches of the internet, and I'm not finding an answer to this question.  So any replies consisting of just the comment "read this PDF" will be ignored.

 

Thanks!

 

Jerry H.

 

  • April 26, 2010
  • Like
  • 0

I have a managed package that includes a schedulable Apex class. As part of the post-package-installation instructions, the customer schedules that class to run on a nightly basis.

 

I also have an unmanaged version of this package, developed in a completely separate org, that I have deployed via the IDE to a few test orgs. If the Apex job is scheduled in the target org, the deployment fails, because it won't allow me to deploy a new version of the Apex class while the previous version is still scheduled to execute. I have to unschedule the job, then deploy, and then re-schedule the new version of the class.

 

With the managed package, I was surprised to discover that I can install a new version of the package into an org in which the previous version was already installed, even if the previous version of the Apex class is still scheduled to execute. This behavior of the managed package upgrade process seems different from the behavior of the unmanaged deployment process.

 

What IS the expected behavior when I install an upgrade to a managed package, when a class for that package is already scheduled to execute? Should the upgrade fail? If it shouldn't fail (it doesn't), what version of the code will run the next time the scheduled job runs -- the original version or the upgraded version?

  • June 08, 2011
  • Like
  • 0

I've been able to figure out how to programmatically load / read the contents of a StaticResource...

 

    // resource name is "testAccount" in this case

    List<StaticResource> lstResource = [select Body from StaticResource where Name like '%Account'];
    dom.Document doc = new dom.Document();
    doc.load(lstResource.get(0).Body.ToString());

 

...but so far I haven't been able to figure out how to create a new StaticResource out of whole cloth and save it.  The API says it supports all of the standard accessors (create, update, etc.) but so far I haven't been able to get any combinations or permutations to work for me.

 

So is this possible?  And if it is, then what the heck am I doing wrong?

 

Jerry (Very Much Argh!) H.

 

  • January 18, 2011
  • Like
  • 0

Is there any way to retrieve a WRITEABLE reference to an SObject field at runtime?

 

Yes, I've seen all of the Schema.DescribeFieldResult stuff, and it's dandy if you want a READ-ONLY reference to the object metadata, but I was hoping to find a way to remap data from an existing Salesforce standard / default field into a set of user-defined custom fields.

 

What I'd like to do is pass in two field names at runtime and have the code-behind read the value from the first field and write it to the second field -- for purposes of illustration, something like:

 

    String data = Account.[field1];

    Account.[field2] = data;

 

Does anyone have a clue about how to do this?  I could hard-code a bunch of select statements into a bunch of methods, but I'd prefer to have a general-purpose reusable solution.

 

Jerry H.

 

  • December 09, 2010
  • Like
  • 0

We rolled out an update to our AppExchange package this morning, and although the package is configured as the new version, and our uploaded media has been updated, the listing on the public site is still listed as the old versions of both.

 

What gives?

I'm in the final stages of developing a SalesForce plugin, but I can't figure out how the end user would get to my Apex Page if I don't wrap the page in an Apex Tab.

 

My assumption (possibly incorrect, since I can't find anything that addresses this topic) is that something magical occurs when a plugin is packaged and made available in the AppExchange -- by "magical" I mean that any user who installs my plugin will suddenly "see" a new tab (?) or something (?) after the installation, and they'll be able to click on this thing (whatever it is) to display my Apex Page.

 

Is this actually the case?  Is some sort of "here's the application / plugin you've just installed" tab (or something?), or do I need to add some Apex Tab code to my Apex Page, or do I need to do something else entirely to give the user some sort of clue about how to access the plugin they've just installed?

 

Clues and tips gratefully accepted, URL's to existing SalesForce PDF's (unless you can explicitly provide the relevant quote from said PDF in your reply) not appreciated.  I've downloaded and read dozens of SalesForce PDF's, and done all sorts of Google and other searches of the internet, and I'm not finding an answer to this question.  So any replies consisting of just the comment "read this PDF" will be ignored.

 

Thanks!

 

Jerry H.

 

  • April 26, 2010
  • Like
  • 0

Is this supported?  We're using the Twitter app, and I wrote a schedulable class that calls the AutomationWrapper included in this package to update our conversations every ten minutes.  The code in my class executes on its own as expected, but when it's run via the scheduler, it appears that the HTTP callouts are simply skipped.

 

This is the log.  This code takes an absolute minimum of 2 full seconds to execute when working properly.  When run from the scheduler, its' done in less than 300ms, which leads me to believe that the HTTP callouts are just being skipped.

 

 

18.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO1:30:0.26|EXECUTION_STARTED1:30:0.26|CODE_UNIT_STARTED|[EXTERNAL]Twitter Synch 41:30:0.41|SOQL_EXECUTE_BEGIN|[4,40]|Aggregations:0|select id from sf4twitter__twitter_account__c where name = 'logmeinhelp' limit 11:30:0.48|SOQL_EXECUTE_END|[4,40]|Rows:1|Duration:71:30:0.49|METHOD_ENTRY|[5,14]|sf4twitter.AutomationWrapper.doSearchAccount(Id, Integer)1:30:0.49|ENTERING_MANAGED_PKG|sf4twitter1:30:0.49|SOQL_EXECUTE_BEGIN|[116,42]|Aggregations:0| Select t.Username__c, t.Unknown_Twitter_Usernames__c, t.Twitter_User_Id__c, t.Twitter_Max_Twitter__c, t.Twitter_Max_Message__c, t.SystemModstamp, t.Password__c, t.OwnerId, t.Name, t.LastModifiedDate, t.LastModifiedById, t.IsDeleted, t.Id, t.Enable_Auto_Case_Creation__c, t.CreatedDate, t.CreatedById, t.Bit_ly_Username__c, t.Bit_ly_Password__c, associate_DM__c , ignore_maxid__c, closed_case_duration__c From Twitter_Account__c t Where Id =:taId 1:30:0.58|SOQL_EXECUTE_END|[116,42]|Rows:1|Duration:91:30:0.59|SOQL_EXECUTE_BEGIN|[27,34]|Aggregations:0|select id, name from Account where name = :Label.TWITTER_ACCOUNT_NAME1:30:0.114|SOQL_EXECUTE_END|[27,34]|Rows:0|Duration:551:30:0.115|SOQL_EXECUTE_BEGIN|[60,21]|Aggregations:0|Select Name, Id, OwnerId, Username__c, Unknown_Twitter_Usernames__c, Password__c, Twitter_Max_Message__c, Enable_Auto_Case_Creation__c, Bit_ly_Username__c, Bit_ly_Password__c, Twitter_Max_Twitter__c, associate_DM__c, associate_cases_same_username__c, closed_case_duration__c From Twitter_Account__c LIMIT 10001:30:0.118|SOQL_EXECUTE_END|[60,21]|Rows:2|Duration:31:30:0.132|SOQL_EXECUTE_BEGIN|[156,17]|Aggregations:0|select id, twitterId__c from Case where twitterId__c in :tids1:30:0.136|SOQL_EXECUTE_END|[156,17]|Rows:0|Duration:41:30:0.139|SOQL_EXECUTE_BEGIN|[399,20]|Aggregations:0|select id, twitter_username__c from Contact where twitter_username__c in :twitterUserNames LIMIT 10001:30:0.142|SOQL_EXECUTE_END|[399,20]|Rows:0|Duration:31:30:0.142|SOQL_EXECUTE_BEGIN|[402,17]|Aggregations:0|select id, twitter_username__c from Lead where IsConverted = false and twitter_username__c in :twitterUserNames LIMIT 10001:30:0.153|SOQL_EXECUTE_END|[402,17]|Rows:0|Duration:111:30:0.153|SOQL_EXECUTE_BEGIN|[361,18]|Aggregations:0|Select Id, twitterID__c, ContactId, Twitter_Username__c from Case where twitterID__c in :twitterIds1:30:0.155|SOQL_EXECUTE_END|[361,18]|Rows:0|Duration:21:30:0.156|SOQL_EXECUTE_BEGIN|[366,40]|Aggregations:0|select Id, Case__c, Case__r.ClosedDate, Case__r.Status, Contact__c, twitterid__c, Parent__c, type__c from Twitter_Conversation__c where twitterid__c in :twitterIds LIMIT 10001:30:0.164|SOQL_EXECUTE_END|[366,40]|Rows:0|Duration:81:30:0.164|SOQL_EXECUTE_BEGIN|[371,40]|Aggregations:0|select Id, Case__c, Case__r.ClosedDate, Case__r.Status, Contact__c, twitterid__c, Parent__c, Content__c, Author_Real_Name__c, Author_Name__c, type__c, In_Reply_To_Status_Id__c, In_Reply_To_User_Id__c from Twitter_Conversation__c where twitterid__c in :twitterReply LIMIT 10001:30:0.168|SOQL_EXECUTE_END|[371,40]|Rows:0|Duration:41:30:0.171|SOQL_EXECUTE_BEGIN|[663,18]|Aggregations:0|select id, twitterId__c, Twitter_Username__c, CreatedDate, ContactId, Contact.Twitter_Username__c from Case where ((Status != :Label.TWITTER_CASE_CLOSED or ClosedDate >= :closeDuration) and Twitter_Username__c IN :fromUsernames) or Id IN :repCasesId order by LastModifiedDate desc LIMIT 10001:30:0.181|SOQL_EXECUTE_END|[663,18]|Rows:0|Duration:101:30:0.181|SOQL_EXECUTE_BEGIN|[677,40]|Aggregations:0|select id, Content__c,Case__c, Parent__c, Author_Name__c from Twitter_Conversation__c where Case__c IN :casesIds LIMIT 10001:30:0.183|SOQL_EXECUTE_END|[677,40]|Rows:0|Duration:21:30:0.183|SOQL_EXECUTE_BEGIN|[705,36]|Aggregations:0|select In_Reply_To_Status_Id__c, id, Case__r.Status, Case__r.twitterId__c, Case__r.Twitter_Username__c, Case__r.CreatedDate, Case__r.ContactId, Author_Name__c from Twitter_Conversation__c where (In_Reply_To_Status_Id__c in :repliedRAStatusTwitterIds) and (Case__r.Status != :Label.TWITTER_CASE_CLOSED or Case__r.ClosedDate >= :closeDuration) order by Case__r.LastModifiedDate desc limit 10001:30:0.187|SOQL_EXECUTE_END|[705,36]|Rows:0|Duration:41:30:0.188|DML_BEGIN|[621,42]|Op:Upsert|Type:Case|Rows:01:30:0.188|DML_END|[621,42]|1:30:0.190|SOQL_EXECUTE_BEGIN|[561,20]|Aggregations:0|select id, twitter_username__c from Contact where twitter_username__c in :twitterUserNames LIMIT 10001:30:0.192|SOQL_EXECUTE_END|[561,20]|Rows:0|Duration:21:30:0.192|DML_BEGIN|[583,42]|Op:Upsert|Type:Case|Rows:01:30:0.193|DML_END|[583,42]|1:30:0.193|SOQL_EXECUTE_BEGIN|[411,42]|Aggregations:0|select TwitterID__c, Twitter_Account__c, Direct_Message__c,type__c from Twitter_Conversation__c where Type__c = :Label.TWITTER_TYPE_REPLIES and Twitter_Account__c in :accounts.keySet() order by TwitterID__c desc limit 11:30:0.201|SOQL_EXECUTE_END|[411,42]|Rows:1|Duration:81:30:0.201|SOQL_EXECUTE_BEGIN|[414,51]|Aggregations:0|select TwitterID__c, Twitter_Account__c, Direct_Message__c,type__c from Twitter_Conversation__c where Type__c = :Label.TWITTER_OUTBOUND_DIRECTMESSAGE and Twitter_Account__c in :accounts.keySet() and Direct_Message__c != null order by TwitterID__c desc limit 11:30:0.205|SOQL_EXECUTE_END|[414,51]|Rows:0|Duration:41:30:0.205|SOQL_EXECUTE_BEGIN|[418,45]|Aggregations:0|select TwitterID__c, Twitter_Account__c, Direct_Message__c,type__c from Twitter_Conversation__c where (Type__c = :Label.TWITTER_TYPE_REGISTERED_ACCOUNT or Type__c = :Label.TWITTER_OUTBOUND_REPLY) and Twitter_Account__c in :accounts.keySet() and Direct_Message__c = null order by TwitterID__c desc limit 11:30:0.211|SOQL_EXECUTE_END|[418,45]|Rows:1|Duration:61:30:0.211|SOQL_EXECUTE_BEGIN|[422,41]|Aggregations:0|select TwitterID__c, Twitter_Account__c, Direct_Message__c,type__c from Twitter_Conversation__c where Type__c = :Label.TWITTER_TYPE_DIRECT_MESSAGE and Twitter_Account__c in :accounts.keySet() order by TwitterID__c desc limit 11:30:0.215|SOQL_EXECUTE_END|[422,41]|Rows:0|Duration:41:30:0.218|DML_BEGIN|[443,3]|Op:Update|Type:sf4twitter__Twitter_Account__c|Rows:11:30:0.238|ENTERING_MANAGED_PKG|sf4twitter1:30:0.238|SOQL_EXECUTE_BEGIN|[5,42]|Aggregations:0|select id, Username__c from Twitter_Account__c where Username__c =: Trigger.new[0].Username__c and ownerId = :UserInfo.getUserId()1:30:0.243|SOQL_EXECUTE_END|[5,42]|Rows:1|Duration:51:30:0.243|CUMULATIVE_LIMIT_USAGE1:30:0.243|CUMULATIVE_LIMIT_USAGE_END1:30:0.256|DML_END|[443,3]|1:30:0.257|METHOD_EXIT|[5,14]|doSearchAccount(Id, Integer)1:30:0.257|METHOD_ENTRY|[6,3]|system.debug(String)1:30:0.258|USER_DEBUG|[6,3]|DEBUG|result: <?xml version="1.0" encoding="UTF-8"?><result><conversations>0</conversations><cases>0</cases><caseComments>0</caseComments><contacts>0</contacts><leads>0</leads><errorCode>null</errorCode><errorMsg>null</errorMsg><pageNumber>0</pageNumber></result>1:30:0.258|METHOD_EXIT|[6,3]|debug(ANY)1:30:0.258|CODE_UNIT_FINISHED1:30:0.258|EXECUTION_FINISHED

 

 The scheduler class that I'm running every 10 minutes

 

global class SynchTwitter Implements Schedulable{ global void Execute(SchedulableContext SC){ sf4twitter__twitter_account__c acc = [select id from sf4twitter__twitter_account__c where name = 'mytwitteraccountname' limit 1]; string s = sf4twitter.automationwrapper.doSearchAccount(acc.id,0); system.debug('result: ' + s); }}

 

 I let this run for an hour, and no results were ever pulled back.  I ran the code inside the execute method on its own via the system log window, and it pulled back the conversations I was expected to be pulled.

 

The documentation for the Spring '10 release does not indicate that HTTP callouts are not supported in Scheduled Apex.  I'm not willing to write a complete class just to confirm whether or not it's supported, and I can't see any issues with the Twitter class debug log (it's a managed package, so I can't see what's being done where). 

 

Please advise. 

 

 

hey guys, i get this error all of the sudden.

"System.VisualforceException: core.apexpages.exceptions.ApexPagesGenericException:

Class.GenerateAttachEmailCertificate_WS.GenerateAttachEmailCertificate: line 10, column 18
Class.GenerateAttachEmailCertificate_WS.testingEmail: line 93, column 14
External entry point".

 

line 9 and 10:

 

PageReference pdf = new PageReference('/apex/CertificatePrintToPdf?id=' + id); Blob pdfBody = pdf.getContent();

 

and line 93 is inside my test method:

 

testSend = GenerateAttachEmailCertificate_WS.GenerateAttachEmailCertificate(testId, testVer, testLoc);

 

im pretty sure it was 100% coverage, but now im in the middle of deploying a new class into production, and i got that error.

 

can anyone help me please?

thanks in advance.

 

 

 

 

 

Hi there,

 

So I think that I kind of understand Maps, in that if you create a map with a SOQL query, such as

 

 

Map<ID,sObject> sObMap = new Map<ID,sObject>([SELECT *fields* FROM sObject WHERE *conditions*]);

 you get the key/value pairing of an sObject ID and the sObject itself. I'm slightly unsure as to the purpose of the *fields* in the SOQL query, but it seems to work where I need it to, namely in specifying an sObject from a list of IDs.

 

Today I was trying to create an <ID,ID> map, so I can take a list of accounts and iterate through them to get a key/value pairing for the IDs of a set of Master-Detail related sObjects (Clent_Form__c). I want to insert a set of a third object (Assessments__c), which has lookups to the Account and the related Client_Form__c. The only way I think I can do this is by putting SOQL in a FOR loop (METHOD 1 below), which I know is bad practice for bulk triggers.

 

Is there a better way of taking a list of Accounts and mapping them to detail sObjects?

 

Here's the working (messy) class as it stands.

 

 

public with sharing class createAssessments { public static void IEF(List<Account> accs){ //Declare owner ID variable for IEF Assessments queue Id ownerId = [Select q.Queue.Id from QueueSobject q where q.Queue.Name = 'Application Screenings' and q.SobjectType = 'Assessment__c'].Queue.Id; //Create a list of assessments to be inserted List<Assessment__c> assessments = new List<Assessment__c> (); //METHOD 1 - works but I've got SOQL in a loop //Create map of Account ID => Client Form ID Map<ID,ID> IEFs = new Map<ID,ID>(); for (Account a:accs){ IEFs.put(a.Id,[SELECT Id FROM Client_Form__c WHERE Account__c = :a.Id].Id); } //METHOD 2 - doesn't work as I'm putting sObject Client_Form__c into an ID field when I create the assessments //Create list of account IDs for object list accs - is this necessary or could I reference the object list directly? //List<ID> refAccs = new List<ID> (); //for (Account z:accs){ //refAccs.add(z.Id); //} //Query client forms for account IDs and put in a map //Map<ID,Client_Form__c> IEFs = new Map<ID,Client_Form__c>([SELECT Id, Account__c FROM Client_Form__c WHERE Account__c IN :refAccs]); //For each account, create two IEF assessments for(Account a:accs){ Assessment__c assess = new Assessment__c(); assess.Client_Form__c = IEFs.get(a.Id); assess.RecordTypeId = '01280000000BR0VAAW'; assess.OwnerId = ownerId; assess.Account__c = a.Id; assessments.add(assess); assessments.add(assess.clone()); } //Insert the assessments insert assessments; } }

Thanks in advance,

 

Joe

 

 

 

I have a new native app on the app exchange and a professional edition customer tried to install it. They got a bunch of errors like this:

 

Missing feature

Apex Classes

Installing this package requires the following feature and its associated permissions: Apex Classes

 

 

My app uses a few custom classes, objects, and a visualforce page. I was told that even a pro edition can install an app that uses custom apex classes. 

 

Does anyone have ideas of how to dig into this further?

 

Thanks!

  • February 20, 2009
  • Like
  • 0