• LloydC
  • NEWBIE
  • 10 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies
Hi,
I am writing a before insert trigger that updates a field on the account whenever an attachment is added but only if the person adding the attachment is not the owner.  I try to select the owner of the associated account based on the attachment.parentid but it doesn't return any rows.  I tried to hardcode the parentid and it still doesn't return any rows.  The row is definitely there because I can query it and it does return a row.  Why does it not return the row.  Below are the trigger definition and the test class.  Thank you.
trigger AttachmentTrigger on Attachment (before insert) {
	List<Account> accountList = new List<Account>();

   Set<Id> accIds = new Set<Id>(); 
     for(Attachment att : trigger.New){
         //Check if added attachment is related to Account or not
         if(att.ParentId.getSobjectType() == Account.SobjectType){
      	Account a	= [select id,OwnerId from account where id = '001M000000Y2Rbx']; // :att.ParentId];
      	if (a.OwnerId != att.OwnerId)
              accIds.add(att.ParentId);}

    }
    accountList = [select id, has_Attachment__c from Account where id in :accIds];
    if(accountList!=null && accountList.size()>0){
        for(Account acc : accountList){
            acc.has_Attachment__c = true; 
        }
        update accountList;
    }         
	

}
private class TestAttachmentTrigger {

    static testMethod void myUnitTest() {
//    	Account[] a = [Select Id,name from account where Id = '001M000000Y2Rbx'];
    	User u2 = [select id from User where alias='administrator']; 
    	system.runAs(u2){
    	Blob body;
    	body = Blob.valueOf('test');
    	Attachment Attach = new Attachment();
    	Attach.ParentId = '001MxyzbwY2Rbx';  //id of an existing account
    	Attach.OwnerId = u2.Id;
    	Attach.Name = 'newattach';
    	Attach.Body = body;
    	insert Attach;
    	}

    }
}



 
  • February 09, 2015
  • Like
  • 0

Is it possible to change the Salesforce logo at the top of a printable view to a custom logo and if so, how does one go about it?

Hi,

When using the dataloader to do an extract,  updating the spreadsheet and then updating the data again, you receive an entity is deleted; however, when you look there are no deleted records.

In this case it was the assets object but I have seen it in other objects also.

 

Has anyone else seen this or know what the issue may be?

 

Thanks,

Lloyd

  • April 16, 2009
  • Like
  • 0

Hi,

I am creating a wizard to create a case with some particular requirements.  After selecting the account, the user selects an existing contact on the account.  If the contact doesn't exist the user should be allowed to create a new contact for that account.  Does anyone know how to: with a button click, send the user to the new contact page with the selected account, return to the calling page and update the contacts in a select list?

 

 

I do have a controller extension for the wizard but don't know how to go about calling a standard page, new contact, and returning.  Mostly I have tried to use the UrlFor function but can't get all the functionality implemented.

 

Thanks for any help.

 

Lloyd

 

  • April 13, 2009
  • Like
  • 0

Hi,

 I am trying to create a wizard that will create a case based on user input to the pages. 

On the first page the user selects the account from a lookup.  On the second screen, I only want to allow the user to pick a contact that is associated with the account selected on the first screen.  I implemented a lookup but it shows all contacts.  Is there a way to show only the contacts on the account selected; or, if not, how can I implement a select list with only the associated contacts?

 

Thanks,

Lloyd

  • April 09, 2009
  • Like
  • 0

Hi,

Can someone tell me why

FIND {0018000000ONcI3AAL} IN ALL FIELDS RETURNING Account (BillingCity)

doesn't return any results when 0018000000ONcI3AAL is a valid ID?

It doesn't work in Apex Explorer or in VB Code.

 

 

Thanks,

  • March 17, 2009
  • Like
  • 0

I have loaded the enterprise wsdl into the VB project but for queryresult, qr.records(i), "Any" is not available.  I did note that it is available in the C# ApexExplorer project.  Does anyone know why it isn't available and how to make it available?

Thanks

Message Edited by LloydC on 03-15-2009 04:50 PM
  • March 15, 2009
  • Like
  • 0

Is it possible to change the Salesforce logo at the top of a printable view to a custom logo and if so, how does one go about it?

Hi,

I am creating a wizard to create a case with some particular requirements.  After selecting the account, the user selects an existing contact on the account.  If the contact doesn't exist the user should be allowed to create a new contact for that account.  Does anyone know how to: with a button click, send the user to the new contact page with the selected account, return to the calling page and update the contacts in a select list?

 

 

I do have a controller extension for the wizard but don't know how to go about calling a standard page, new contact, and returning.  Mostly I have tried to use the UrlFor function but can't get all the functionality implemented.

 

Thanks for any help.

 

Lloyd

 

  • April 13, 2009
  • Like
  • 0

Hi,

 I am trying to create a wizard that will create a case based on user input to the pages. 

On the first page the user selects the account from a lookup.  On the second screen, I only want to allow the user to pick a contact that is associated with the account selected on the first screen.  I implemented a lookup but it shows all contacts.  Is there a way to show only the contacts on the account selected; or, if not, how can I implement a select list with only the associated contacts?

 

Thanks,

Lloyd

  • April 09, 2009
  • Like
  • 0
Hi there. I have the following code that leverages a custom object called "Test__c", that has
1 field, which is a lookup to Accounts.

Code:
<apex:page standardController="Test__c" tabStyle="Test__c">
    <apex:sectionHeader title="{!$ObjectType.Test__c.label} Edit" subtitle="New Test"/>
    <apex:form>
    <apex:pageBlock title="Test">
        <apex:pageBlockButtons>
            <apex:commandButton value="Save" action="{!save}" />
            <apex:commandButton value="Cancel" action="{!cancel}" />
        </apex:pageBlockButtons>
    <apex:actionRegion>
        <apex:pageBlockSection title="Information">
            <apex:inputField value="{!Test__c.Account__c}">
                <apex:actionSupport event="onselect" rerender="otherPanel" />
            </apex:inputField>
        </apex:pageBlockSection> 
    </apex:actionRegion>  
    
    <apex:pageBlockSection title="test" id="otherPanel" rendered="true">
        <apex:outputField value="{!Test__c.Account__c}" />
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Now, when I type a value into the lookup box and I select a value from the autocomplete, the value in the "test" pageBlockSection will update in an Ajax fashion like so:
 

But when I use the lookup dialog to select an account, the field will not update:


Any ideas??
Thanks
  • December 10, 2008
  • Like
  • 1