• LoxMyth Bourne
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 10
    Replies
Has anyone used the inbound email service? I tried an example close to what's in online help & nothing happens when I send mail to the generated address. And, where does system.debug write out to?
 
 

hi,

 

please help me identify what's wrong with this code:

 

    <apex:includeScript value="{!$Resource.jquery}"/>

 

    <apex:form onsubmit="shout(event);">

        <apex:inputTextarea id="myTxtArea" value="{!myControllerVariable}"/>

    </apex:form>

 

    <script>

        jQuery.noConflict();


        function shout(event) {
        alert(jQuery("#myTxtArea").val()); ---> this alerts an 'undefined' value!
            if(jQuery("#myTxtArea").val("")) { ---> but would still execute the codes in this condition.. T_T
                jQuery("#errorMsg").text("Please enter a shoutout");
                jQuery("#errorMsg").show();
                event.returnValue = false;
                event.preventDefault();
            }
        }
    </script>

 

jQuery seemed can't reference the <apex:inputTextarea> id in this case.. is this really the case in the salesforce platform?

 

any help would be much appreciated..

I have a simple Batch Apex class called from a trigger on the User object that updates a field on the Accounts owned by the User if a corresponding field is updated on the User.

 

All's working well as regards functionality, but the test method does not seem to be calling the Execute.

 

The trigger:

 

trigger au_User on User (after update) {

List<id> usersToUpdate = new List<id>();

//Loop through the trigger set for (integer iterator=0; iterator<trigger.new.size(); iterator++){

//Add the Users to collection where the values of the given fields have changed

if(trigger.new[iterator].Super_Sector_Region__c <> trigger.old[iterator].Super_Sector_Region__c){

usersToUpdate.add(trigger.new[iterator].id);

}

}

AccountUpdaterBatch batch = new AccountUpdaterBatch();

batch.usersToUpdate = usersToUpdate;

Database.executeBatch(batch, 20);

}

 

 The batch apex class:

 

 

global class AccountUpdaterBatch implements Database.Batchable<SObject>, Database.Stateful{

public List<id> usersToUpdate = new List<id>();

global Database.QueryLocator start(Database.BatchableContext BC){

String query='select a.id, a.Sector_Region__c, a.Owner.Super_Sector_Region__c'

+' from Account a where a.OwnerId IN :usersToUpdate';

return Database.getQueryLocator(query);

}

global void execute(Database.BatchableContext BC, List<sObject> scope){

List<Account> accns = new List<Account>();

for(sobject s : scope){

Account a = (Account)s;

if(a.Sector_Region__c != a.Owner.Super_Sector_Region__c)

a.Sector_Region__c = a.Owner.Super_Sector_Region__c;

accns.add(a);

}

update accns;

system.debug('####### Number of accounts updated'+accns.size());

}

global void finish(Database.BatchableContext BC){ //Do nothing }

 

}

 

The test method:

 

 

static testMethod void testUserTrigger(){

User currentUser = [Select u.Super_Sector_Region__c, u.Id From User u Where u.Id =: UserInfo.getUserID()];

List<Account> testAccs = new List<Account>();

for(integer i=0;i<90;i++){

Account testAccount = new Account(Name = 'TestAccount'+i, OwnerId = currentUser.Id);

testAccs.add(testAccount);

}

insert testAccs;

Test.starttest();

currentUser.Sector_Sales_Team__c = 'Test1';

update currentUser;

AccountUpdaterBatch testBatch = new AccountUpdaterBatch();

testBatch.usersToUpdate = new List<id>{currentUser.Id};

Database.executeBatch(testBatch, 20);

test.stoptest();

}

 

 

 

 Finally, the dump from the test log that shows that the start method was called, but the execute wasn't:

 

 

20100110162747.501:External entry point: returning Database.QueryLocator from method global Database.QueryLocator

start(Database.BatchableContext) in 0 ms

20100110162747.501:Class.AccountUpdaterBatch.start: line 35, column 10: SOQL locator query with 93 rows finished in 122 ms

Cumulative resource usage:

..

..

..

..

 

20100110162738.641:Class.TestAccountTrigger.testUserTrigger: line 123, column 3: returning from end of method global static void stopTest() in 5760 ms

 

20100110162738.641:External entry point: returning from end of method static testMethod void testUserTrigger() in 9065 ms

 

 Can someone please guide me as to what I'm missing or doing wrong?

 

Thanks,

 

-Manu 

Message Edited by md1 on 10-01-2010 04:36 PM
  • January 10, 2010
  • Like
  • 0
OK guys, which one of you is going to be the first one to create a Salesforce-Google Wave integration App?

hi,

 

what is the simplest way to integrate salesforce.com with liferay.com  (www.liferay.com) ?

 

I want in the first step publish sf objects in list and detail view. What is the best technology to done this ?

 

norbert

Hi. I tried to 'disable' the default Attachment function of SFDC with the following trigger:
 
Code:
trigger AttachmentDisabler on Attachment (before insert) {
 List<Attachment> atts = Trigger.new;
 for(Attachment a:atts) {
  a.addError('Please use the "Attach(FTP)" button on top of the detail page to attach a file.'); 
 }
}

 
But this does not seem to work. Did I do something wrong or is it impossible this way? Even the debug did not show anything, the trigger does not seem to do anything. Any other ways to disable the normal Attach function of SFDC without removing the entire related list? (want to keep notes function)