• Guyver118
  • NEWBIE
  • 130 Points
  • Member since 2008

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 49
    Questions
  • 64
    Replies

Here's the scenario: I have a custom object ('project') that is created via apex when an Opportunity is closed. I am trying to establish a 1:1 relationship (at least from the user's perspective), so I want the newly created project to be passed back to a lookup on the Opportunity.

Basically, I'm seeking to populate the Opportunity Project lookup with the id of the newly created project record so that they are linked both ways (instead of just linking one way, the project back to the opportunity).

I assume this can be done in an afterinsert trigger on the project object. But, I have been unable to update a related object via my trigger.

Something like this: thisOpp.Parent_Opportunity__r.Project_Profile__c = Project_Profile__c.Id;

I'm offering $65 via paypal to the first person that can provide me a working answer (this would include an apex trigger and the basic structure of a test class or an alternative solution).

Contact me with questions. (I will be working over the weekend.)

Message Edited by J Baze on 09-04-2009 05:21 PM

Hi.  We're trying to bulkify a trigger that uses 2 fields of the inserted object to query and update fields on a Contact and Case.  All of the examples that I've seen are very different and we don't understand how this would be done in a bulk manner. 

 

Here is the non-bulk example of what we're trying to accomplish, but are getting the too many SOQL query errors when we test.

 

Any ideas?


 

trigger OrderLineTrigger on Order_Line_Item__c (after insert) { Case[] c; List<Case> casesToUpdate = new List<Case>(); for(Order_Line_Item__c orderLine : Trigger.new) { // Get contact info c = [Select Id, ContactId From Case Where Item_Id__c = :orderLine.Item_Id__c and User_Id__c = :[Select User_Id__c From Contact Where Id = :orderLine.Contact__c LIMIT 1].User_Id__c LIMIT 200]; if(c!=null && c.size()>0) { for(Integer j=0; j<c.size(); j++) { c[j].Related_To_Order__c = orderLine.Order__c; // Order lookup value c[j].Related_To_Order_Line__c = orderLine.Id; // Order Line lookup value c[j].SKU__c = orderLine.Product_Code__c; c[j].ContactId = orderLine.Infopia__Contact__c; // Contact Lookup value casesToUpdate.add(c[j]); } update casesToUpdate; } } }

 

Thanks,

Jon

 

Hi,

 

I'm in trouble, anyone guide me...... my problem is to display the value(in drop down box) of Sales Process in VF page listed under Setup>AppSetup>Opportunity>Sales Processes. I'm unable to fetch this value through eclipse.

 

 

  • July 03, 2009
  • Like
  • 0

Hello,  I have read that the reason I get this error is due to my SOQL query being in the FOR loop of the below trigger.  Could someone take a look at it and let me know how I could go about bulk safing this trigger.

 

trigger SetAccountField on Domains__c (before insert) {
    for (Domains__c domain : Trigger.new) {
        String cid = domain.Contact__c;
       
        List<Contact> contacts = [SELECT AccountId,
                                    MailingStreet,
                                    MailingState,
                                    MailingCity,
                                    MailingPostalCode,
                                    Company__c
                                    FROM Contact WHERE Id = :cid];
       
        if(contacts.size() > 0){
            domain.Account__c = contacts.get(0).AccountId;
            domain.Company__c = contacts.get(0).Company__c;
            if(contacts.get(0).MailingStreet != null){
                domain.House_Number__c = contacts.get(0).MailingStreet.substring(0,contacts.get(0).MailingStreet.indexOf(' '));
                    domain.Bill_To__c = contacts.get(0).MailingStreet.substring(contacts.get(0).MailingStreet.indexOf(' '));
            }       
            domain.City__c = contacts.get(0).MailingCity;
            domain.State_Province__c = contacts.get(0).MailingState;
            domain.Zipcode__c = contacts.get(0).MailingPostalCode;
        }
    }
 }

 

 

Any help is greatly appreciated.

 

Thanks,

Marc

 

 

Hi,

 

i want to get all the product name related with an Opportuntiy.

 

i want to write one trigger for that.

 

Does any body know the SQL (how do i query to salesforce) or any Idea.

 

 

Regards,

Deepak 

If creating batch apex scripts will i run into governor limits if i do some complex processing i.e. for accounts get a list of opportunities and contacts, aggregate something on each account and update the accounts, opportunities and contacts etc..

I have a table in which the user can edit and delete records but if one quickly clicks for say delete on multiple records on the table it will cancel the one before and do the new one?

 

Is there anyway to say if someone clicks on delete do that action but block any others until complete?

I was wondering if i only want a trigger to only happen on the interface i.e. as don't want this to happen in a bulk upate in data loader can i just always just manipulate the first record on the trigger list

 

//Some trigger on account which should only happen in user interface

 

Account acc = trigger.new.get(0);

 

//do some stuff with acc?

I have trigger that basically updates the account owner to the corresponding user.

 

//trigger trigger AccountBeforeUpdateEvents on Account (before update) { AccountOpeningUtils_v1.InitUserList(); AccountOpeningUtils_v1.UpdateAccountOfficer(trigger.new); } public class AccountOpeningUtils_v1 { public static void InitUserList() { Boolean inLock = (OpportunityHelper_v1.IsUpdatingAccount() == true || CaseHelper_v1.IsUpdatingAccount() == true); if(!inLock)UserTriggerUtils_v1.InitUserList(); } public static void UpdateAccountOfficer(List<Account> accList) { for(Account a : accList) { if(!UserTriggerUtils_v1.GetUserList().isEmpty() && !UserTriggerUtils_v1.ValueIsNull(a.Account_Officer__c) && a.Account_Officer__c.length() >= 3) { String oCode = a.Account_Officer__c.substring(0, 3).trim(); User officer = UserTriggerUtils_v1.FindAccountOfficer(oCode); if(!UserTriggerUtils_v1.SObjectIsNull(officer))a.OwnerId = officer.Id; } } } } global class UserTriggerUtils_v1 { private static List<User> userList = new List<User>(); private static Map<String, Schema.SObjectField> userFields = Schema.sObjectType.User.fields.getMap(); public static void InitUserList() { String sQuery = 'Select '; Integer i = 0; for(String f : userFields.keySet()) { i ++; sQuery += (i == userFields.keySet().size() ? f : f + ', '); } sQuery += ' FROM User WHERE IsActive = TRUE'; System.debug('### QUERY ###: ' + sQuery); try { userList = Database.query(sQuery); System.debug('### USER LIST ###: ' + userList); } catch(System.QueryException e) { System.debug('### Exception found in userList for' + ' InitUserList() ###:' + e.getMessage()); } } }

when i use data loader i get too many script statements

{fields:null, message:'A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it.', statusCode:'CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY', }

 

i have a button in a standard page that converts something to an account, opportunity etc and i get the above error?

How can i log an activity if a visualforce email template is sent via a workflow rule, is it the only way is to create a task separately?
Hi what should be the date format when using the data loader to upload records from a csv file converted by excel?
Hi i have setup an opportunity trigger that automatically adds a opportunity to a campaign only if there is is an active campaign and is determined from the opp lead source. Now what i want to do is to update the campaign member which i can only see a contact relationship any pointers?
Hi i have a couple of pdfs to attach but i want to have one template and depending on a criteria can i have these attached?

Hi i have created a visualforce email template, now for the preview it renders the image but when i get an email it does not render the image. I get the red cross and i have tried clicking on display all images but no luck :(

 

 

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Applicant__c" subject="Thank you for your Application!"> <messaging:htmlEmailBody > <html> <head> <style type="text/css"> body { font-family: Verdana; font-size:12px; } table { border-width: 1px; border-spacing: 0px; border-style: solid; border-color: #000000; font-family: Verdana; font-size:12px; } td { border-width: 1px; border-spacing: 0px; border-style: solid; border-color: #000000; } </style> </head> <body> <apex:image url="{!URLFOR($Resource.Online_Application_Resource, 'Online_Application/Images/BOC_Logo.jpg')}"/><br/><br/> <p> Dear {!relatedTo.Applicant_Title__c} {!relatedTo.Applicant_Forename_s__c} {!relatedTo.Applicant_Surname__c} </p> <p> Thank you for applying for the {!relatedTo.Online_Application__r.Term__c}. Your Application is now being processed. </p> <p> Your unique application reference is {!relatedTo.Online_Application__r.Application_Reference_Number__c}. Please always quote this reference when you contact us. </p> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Cheque', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Cheque</b>, you will need to send us the cheque which is dated and made payable to yourself. Please make sure that you quote your name and the above reference number on the back of your cheque. </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Electronic Transfer', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Electronic Transfer</b> via your Bank's internet banking service, you <br/>will need to quote the following details<br/> Sort code: *********<br/> Account number: *********<br/> Reference: <b>{!relatedTo.Online_Application__r.Application_Reference_Number__c}</b> </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Bank of Cyprus UK Account', 'true', 'false')}">--> <p> As you have chosen to pay through your existing <b>Bank of Cyprus UK Account</b>, we will collect <br/>funds from your existing account with us. </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Direct Debit', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Direct Debit</b>, we will make a one off Direct Debit claim for the <br/>Bond deposit amount from the account number you have specified in your application after five <br/>working days from the date of this confirmation.<br/> Having accepted your Direct Debit details, we would like you to confirm that they are correct.<br/> Please can you check the details below.<br/><br/> <table width="60%"> <tr> <td><b>Bond amount</b></td> <td>{!relatedTo.Online_Application__r.Amount_to_be_Deposited__c}</td> </tr> <tr> <td><b>Branch sort code</b></td> <td>{!relatedTo.Online_Application__r.Direct_Debit_Sort_Code__c}</td> </tr> <tr> <td><b>Bank/Building society <br/>account number</b></td> <td>****{!RIGHT(relatedTo.Online_Application__r.Direct_Debit_Account_Number__c,4)}</td> </tr> <tr> <td><b>Account name</b></td> <td>{!relatedTo.Online_Application__r.Direct_Debit_Account_Name__c}</td> </tr> <tr> <td><b>Reference</b></td> <td>{!relatedTo.Online_Application__r.Application_Reference_Number__c}</td> </tr> </table> </p> <p> If any of the above details are incorrect, please contact Customer Service as soon as possible <br/>on 0845 850 5555* (+44 20 8267 7343 if calling from abroad) </p> <p> If your details are correct, you need to do nothing and your Direct Debit will be processed as normal. You have the right to cancel the Direct Debit at any time before it is processed. <br/>A copy of the Direct Debit Guarantee is set out below.<br/><br/> <apex:image url="{!URLFOR($Resource.BocBranding, 'DirectDebitLogo.gif')}"/><br/><br/> The Direct Debit Guarantee<br/> <ul> <li>This Guarantee is offered by all banks and building societies that accept instructions <br/>Direct Debits</li> <li>If there are any changes to the amount, date or frequency of your Direct Debit Bank of <br/>Cyprus UK will notify you 10 working days in advance of your account being debited or <br/>as otherwise agreed.</li> <li>If you request Bank of Cyprus UK to collect a payment, confirmation of the amount and <br/>date will be given to you at the time of the request.</li> <li>If an error is made in the payment of your Direct Debit, by Bank of Cyprus UK or your bank <br/>or building society, you are entitled to a full and immediate refund of the amount paid <br/>from your bank or building society <ul> <li>If you receive a refund you are not entitled to, you must pay it back when <br/>Bank of Cyprus asks you to.</li> </ul> </li> <li> You can cancel a Direct Debit at any time by simply contacing you bank of Building Society. <br/>Written confirmation may be required.Please also notify us. </li> </ul> </p> <!--</apex:outputPanel> --> <p><b> If you are eligible to receive interest wihtout tax taken off, please return the R85/R105 <br/>forms, quoting {!relatedTo.Online_Application__r.Application_Reference_Number__c} to the address below for processing. </b></p> <p> Customer Service<br/> Bank Of Cyprus UK<br/> PO Box 17484<br/> London<br/> N14 5WH<br/> </p> <p> If you have any queries relating to your application please contact Customer Service on <br/>0845 850 555 (+44 20 8267 7343 if calling from abroad). </p> <p> Your sincerely </p> <p> Bank of Cyprus UK </p> </body> </html> </messaging:htmlEmailBody> <!-- <messaging:plainTextEmailBody > Congratulations! This is your new Visualforce Email Template. </messaging:plainTextEmailBody> --> </messaging:emailTemplate>

 

 

 

Does anyone know what the task status url id is so i can set the status automatically from a url?

Hi i have this relationship master/detail:-

 

Online Application:Parent

Applicant: Child

 

Now what i want to do is basically whenever an applicant is created is send an email using a visualforce email template i need to do some dynamic stuff :0

 

now the problem is how do i access the online applicaton fields from the applicant i.e. 

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Applicant__c"
 subject="Thank you for your Application!">

 

 

how do i access the applicant's online application details

also as this will be sent via a workflow to the applicant's email what do i put in  recipientType?

How can i do Encryption/Decryption on some text i am going to pass to some custom web service?


Hi i have master detail relationship where address manager is the master and addresses is the detail relationship now when creating new addresses in manager is there a way to redirect the user to the manager page and not the address view state i.e. i have been doing this with a new button

 

 

 

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} window.parent.location.href = "{!URLFOR($Action.Address_Exclusion__c.New, null, [CF00NR0000000XT3n=Address_Exclusion__c.Address_Manager__c, CF00NR0000000XT3n_lkid=Address_Exclusion__c.Address_ManagerId__c, retURL=URLFOR( $Action.Address_Manager__c.View, Address_Exclusion__c.Address_ManagerId__c)], true)}";

 but with no luck it still just redirects the user once the new record address is entered???

 

 

Hi i am not sure if this trigger on the account will cause problems for bulk operations i just really want this to happen once for each current account on the interface when some user updates or inserts an account.

What the trigger does it checks a list of blocked account in another table and compares this with the current account address.

 

 

public class AddressManager_v1 { private static List<Address_Exclusion__c> exclusionList = new List<Address_Exclusion__c>(); private static Address_Manager__c exclusionManager; private static Map<String, Schema.SObjectField> conFields = Schema.sObjectType.Address_Exclusion__c.fields.getMap(); public static void SetAddressManager_v1() { exclusionManager = [ Select Id, Name, Description__c, Active__c, Valid_Objects__c From Address_Manager__c Where Name = 'Address Exclusion Manager' AND Active__c = TRUE Limit 1 ]; String sQuery = 'Select '; Integer i = 0; for(String f : conFields.keySet()) { i ++; if(i == conFields.keySet().size()) { sQuery += f; } else { sQuery += f + ', '; } } sQuery += ' FROM Address_Exclusion__c WHERE Address_Manager__c'; sQuery += ' = ' + '\'' + exclusionManager.Id + '\'' + ' And Active__c = TRUE'; exclusionList = Database.query(sQuery); } public static void CheckValidAccountAddress(List<Account> accList) { SetAddressManager_v1(); if(!exclusionList.isEmpty()) { for(Account a : accList) { List<String> billingStreet = a.BillingStreet.split('\n'); List<String> cleanedBillingStreet = new List<String>(); String billingCity = a.BillingCity.toLowerCase().trim(); String BillingPostalCode = a.BillingPostalCode.toLowerCase().trim(); String BillingCountry = a.BillingCountry.toLowerCase().trim(); for(String street : billingStreet) { cleanedBillingStreet.add(street.toLowerCase().trim()); } System.debug('### SPLIT STREET ADDRESS ###: ' + cleanedBillingStreet); System.debug('### EXCLUSION LIST ###: ' + exclusionList); for(Address_Exclusion__c exclusions : exclusionList) { List<String> streetLine = exclusions.Street__c.split('\n'); List<String> cleanedExclusionStreet = new List<String>(); String city = exclusions.City__c.toLowerCase().trim(); String postalCode = exclusions.Postal_Code__c.toLowerCase().trim(); String country = exclusions.Country__c.toLowerCase().trim(); for(String street : streetLine) { cleanedExclusionStreet.add(street.toLowerCase().trim()); } //In this case it goes through each street line and if any line matches //then this address is blocked. Does this need changing? //Also what other addresses can be checked on account i.e. shipping address etc.. for(String street1 : cleanedBillingStreet) { for(String street2 : cleanedExclusionStreet) { if(//Match street first split by new line (street1.equals(street2) //Match postal code next && billingPostalCode.equals(postalCode) //Match city next && billingCity.equals(city) //Finally match country && billingCountry.equals(country))) { a.addError('This Address has been blocked. Please contact the' + '\n system administrator'); } } } } } } } }

 

 

 

Why is this happening i have the account id and made sure it works in the url

 

0012000000***** MrJonathanFhal     33609694382   Director0122000000****L

 

example data?

Consider this scenario i have AccountUtil class that gets certain objects like a list of contacts related to the account, now i call this in my account trigger and have spearate classes that can get this list.

 

In my case trigger i need to get all contacts related to the account attached, now i was thinking to get the contacts from my AccountUtil but in my case trigger i am aslo updating the account and as i have already got a trigger on my account trigger that gets the list i don't want that method to get the list to happen again :8.

 

 

How come i get the inline help description but not the field descirption from the DescribeFieldResult object?
I am trying to send an email to someone which has an attachment with one of the reports that is in SF. Can anyone explain how can i get a list of all the reports in SF? And how can i attach this?

Hi i have a data table that shows the avaiable list with other descriptions like length, byte etc..

 

 

now in column label name i have  added a command link if the field is a picklist value

now how can i set a variable in my controller to the name of this field that the user clicked on?

 

so far i done this:

 

 

<apex:actionSupport event="onclick"> <apex:actionFunction> <apex:param name="objectName" assignTo="{!pickListField}" value="{!object.name}" /> </apex:actionFunction> <apex:commandLink action="{!ShowPickListPage}" value="{!object.label}"

id="pickListLink" rendered="{!IF(object.type = 'picklist', 'true', 'false')}"/> </apex:actionsupport>

 

 

 

I have the requirement to send the emails to account owners after every 6 months on change of a flag on account.

As i can not add time dependent work flow actions for a workflow if i choose evaluation criteria as "Every time a record is created or edited".

Is there any other way to do the same ?

Hello All,

 

For this case I have found many post but still problem was not fully solved. So here I am starting new fresh

thread for discussion.

 

As so many developers are working to convert Scontrol to VF, facing common problem for sforce.connection.remoteFunction. Following code is working fine in scontrol for all browsers, but not for VF. Only FF works for VF.

 

 

 

I have found solution acceptance on forum to add code but it is not working in my case?

 

sforce.connection.sessionId = "";

 

 

sforce.connection.remoteFunction({
url : "http://domainname/page",
mimeType: "text/plain",
requestHeaders:{"Content-Type":"application/x-www-form-urlencoded" },
method:"POST",
requestData:"checkvalue="+escape(checkvalue)+"&query="+escape(query)+"&strtodisplay="+escape(strtodisplay)+"&user_name="+escape(username),
async:"true",
onFailure:function(response) { alert(response); },
onSuccess:function(response) { alert(response)}
});

 

 What is the reason?

 

 Google chrome giving error "401 Unauthorized"  error.

 

 Reference link: http://www.christopherstoll.org/2009/04/firefox-beats-chrome-in-enterprise.html

 

 What is the soltuion to code work for all browsers?

 

 

 

 Thanks,

I have trigger that basically updates the account owner to the corresponding user.

 

//trigger trigger AccountBeforeUpdateEvents on Account (before update) { AccountOpeningUtils_v1.InitUserList(); AccountOpeningUtils_v1.UpdateAccountOfficer(trigger.new); } public class AccountOpeningUtils_v1 { public static void InitUserList() { Boolean inLock = (OpportunityHelper_v1.IsUpdatingAccount() == true || CaseHelper_v1.IsUpdatingAccount() == true); if(!inLock)UserTriggerUtils_v1.InitUserList(); } public static void UpdateAccountOfficer(List<Account> accList) { for(Account a : accList) { if(!UserTriggerUtils_v1.GetUserList().isEmpty() && !UserTriggerUtils_v1.ValueIsNull(a.Account_Officer__c) && a.Account_Officer__c.length() >= 3) { String oCode = a.Account_Officer__c.substring(0, 3).trim(); User officer = UserTriggerUtils_v1.FindAccountOfficer(oCode); if(!UserTriggerUtils_v1.SObjectIsNull(officer))a.OwnerId = officer.Id; } } } } global class UserTriggerUtils_v1 { private static List<User> userList = new List<User>(); private static Map<String, Schema.SObjectField> userFields = Schema.sObjectType.User.fields.getMap(); public static void InitUserList() { String sQuery = 'Select '; Integer i = 0; for(String f : userFields.keySet()) { i ++; sQuery += (i == userFields.keySet().size() ? f : f + ', '); } sQuery += ' FROM User WHERE IsActive = TRUE'; System.debug('### QUERY ###: ' + sQuery); try { userList = Database.query(sQuery); System.debug('### USER LIST ###: ' + userList); } catch(System.QueryException e) { System.debug('### Exception found in userList for' + ' InitUserList() ###:' + e.getMessage()); } } }

when i use data loader i get too many script statements

Here's the scenario: I have a custom object ('project') that is created via apex when an Opportunity is closed. I am trying to establish a 1:1 relationship (at least from the user's perspective), so I want the newly created project to be passed back to a lookup on the Opportunity.

Basically, I'm seeking to populate the Opportunity Project lookup with the id of the newly created project record so that they are linked both ways (instead of just linking one way, the project back to the opportunity).

I assume this can be done in an afterinsert trigger on the project object. But, I have been unable to update a related object via my trigger.

Something like this: thisOpp.Parent_Opportunity__r.Project_Profile__c = Project_Profile__c.Id;

I'm offering $65 via paypal to the first person that can provide me a working answer (this would include an apex trigger and the basic structure of a test class or an alternative solution).

Contact me with questions. (I will be working over the weekend.)

Message Edited by J Baze on 09-04-2009 05:21 PM
Hi i have a couple of pdfs to attach but i want to have one template and depending on a criteria can i have these attached?

Hi i have created a visualforce email template, now for the preview it renders the image but when i get an email it does not render the image. I get the red cross and i have tried clicking on display all images but no luck :(

 

 

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Applicant__c" subject="Thank you for your Application!"> <messaging:htmlEmailBody > <html> <head> <style type="text/css"> body { font-family: Verdana; font-size:12px; } table { border-width: 1px; border-spacing: 0px; border-style: solid; border-color: #000000; font-family: Verdana; font-size:12px; } td { border-width: 1px; border-spacing: 0px; border-style: solid; border-color: #000000; } </style> </head> <body> <apex:image url="{!URLFOR($Resource.Online_Application_Resource, 'Online_Application/Images/BOC_Logo.jpg')}"/><br/><br/> <p> Dear {!relatedTo.Applicant_Title__c} {!relatedTo.Applicant_Forename_s__c} {!relatedTo.Applicant_Surname__c} </p> <p> Thank you for applying for the {!relatedTo.Online_Application__r.Term__c}. Your Application is now being processed. </p> <p> Your unique application reference is {!relatedTo.Online_Application__r.Application_Reference_Number__c}. Please always quote this reference when you contact us. </p> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Cheque', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Cheque</b>, you will need to send us the cheque which is dated and made payable to yourself. Please make sure that you quote your name and the above reference number on the back of your cheque. </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Electronic Transfer', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Electronic Transfer</b> via your Bank's internet banking service, you <br/>will need to quote the following details<br/> Sort code: *********<br/> Account number: *********<br/> Reference: <b>{!relatedTo.Online_Application__r.Application_Reference_Number__c}</b> </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Bank of Cyprus UK Account', 'true', 'false')}">--> <p> As you have chosen to pay through your existing <b>Bank of Cyprus UK Account</b>, we will collect <br/>funds from your existing account with us. </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Direct Debit', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Direct Debit</b>, we will make a one off Direct Debit claim for the <br/>Bond deposit amount from the account number you have specified in your application after five <br/>working days from the date of this confirmation.<br/> Having accepted your Direct Debit details, we would like you to confirm that they are correct.<br/> Please can you check the details below.<br/><br/> <table width="60%"> <tr> <td><b>Bond amount</b></td> <td>{!relatedTo.Online_Application__r.Amount_to_be_Deposited__c}</td> </tr> <tr> <td><b>Branch sort code</b></td> <td>{!relatedTo.Online_Application__r.Direct_Debit_Sort_Code__c}</td> </tr> <tr> <td><b>Bank/Building society <br/>account number</b></td> <td>****{!RIGHT(relatedTo.Online_Application__r.Direct_Debit_Account_Number__c,4)}</td> </tr> <tr> <td><b>Account name</b></td> <td>{!relatedTo.Online_Application__r.Direct_Debit_Account_Name__c}</td> </tr> <tr> <td><b>Reference</b></td> <td>{!relatedTo.Online_Application__r.Application_Reference_Number__c}</td> </tr> </table> </p> <p> If any of the above details are incorrect, please contact Customer Service as soon as possible <br/>on 0845 850 5555* (+44 20 8267 7343 if calling from abroad) </p> <p> If your details are correct, you need to do nothing and your Direct Debit will be processed as normal. You have the right to cancel the Direct Debit at any time before it is processed. <br/>A copy of the Direct Debit Guarantee is set out below.<br/><br/> <apex:image url="{!URLFOR($Resource.BocBranding, 'DirectDebitLogo.gif')}"/><br/><br/> The Direct Debit Guarantee<br/> <ul> <li>This Guarantee is offered by all banks and building societies that accept instructions <br/>Direct Debits</li> <li>If there are any changes to the amount, date or frequency of your Direct Debit Bank of <br/>Cyprus UK will notify you 10 working days in advance of your account being debited or <br/>as otherwise agreed.</li> <li>If you request Bank of Cyprus UK to collect a payment, confirmation of the amount and <br/>date will be given to you at the time of the request.</li> <li>If an error is made in the payment of your Direct Debit, by Bank of Cyprus UK or your bank <br/>or building society, you are entitled to a full and immediate refund of the amount paid <br/>from your bank or building society <ul> <li>If you receive a refund you are not entitled to, you must pay it back when <br/>Bank of Cyprus asks you to.</li> </ul> </li> <li> You can cancel a Direct Debit at any time by simply contacing you bank of Building Society. <br/>Written confirmation may be required.Please also notify us. </li> </ul> </p> <!--</apex:outputPanel> --> <p><b> If you are eligible to receive interest wihtout tax taken off, please return the R85/R105 <br/>forms, quoting {!relatedTo.Online_Application__r.Application_Reference_Number__c} to the address below for processing. </b></p> <p> Customer Service<br/> Bank Of Cyprus UK<br/> PO Box 17484<br/> London<br/> N14 5WH<br/> </p> <p> If you have any queries relating to your application please contact Customer Service on <br/>0845 850 555 (+44 20 8267 7343 if calling from abroad). </p> <p> Your sincerely </p> <p> Bank of Cyprus UK </p> </body> </html> </messaging:htmlEmailBody> <!-- <messaging:plainTextEmailBody > Congratulations! This is your new Visualforce Email Template. </messaging:plainTextEmailBody> --> </messaging:emailTemplate>

 

 

 

Hi i have this relationship master/detail:-

 

Online Application:Parent

Applicant: Child

 

Now what i want to do is basically whenever an applicant is created is send an email using a visualforce email template i need to do some dynamic stuff :0

 

now the problem is how do i access the online applicaton fields from the applicant i.e. 

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Applicant__c"
 subject="Thank you for your Application!">

 

 

how do i access the applicant's online application details

also as this will be sent via a workflow to the applicant's email what do i put in  recipientType?

Hi.  We're trying to bulkify a trigger that uses 2 fields of the inserted object to query and update fields on a Contact and Case.  All of the examples that I've seen are very different and we don't understand how this would be done in a bulk manner. 

 

Here is the non-bulk example of what we're trying to accomplish, but are getting the too many SOQL query errors when we test.

 

Any ideas?


 

trigger OrderLineTrigger on Order_Line_Item__c (after insert) { Case[] c; List<Case> casesToUpdate = new List<Case>(); for(Order_Line_Item__c orderLine : Trigger.new) { // Get contact info c = [Select Id, ContactId From Case Where Item_Id__c = :orderLine.Item_Id__c and User_Id__c = :[Select User_Id__c From Contact Where Id = :orderLine.Contact__c LIMIT 1].User_Id__c LIMIT 200]; if(c!=null && c.size()>0) { for(Integer j=0; j<c.size(); j++) { c[j].Related_To_Order__c = orderLine.Order__c; // Order lookup value c[j].Related_To_Order_Line__c = orderLine.Id; // Order Line lookup value c[j].SKU__c = orderLine.Product_Code__c; c[j].ContactId = orderLine.Infopia__Contact__c; // Contact Lookup value casesToUpdate.add(c[j]); } update casesToUpdate; } } }

 

Thanks,

Jon

 

In my developer environment, I've added two custom fields to the Product standard object:

 

Account: Lookup (Account)

Annual Revenue: Formula (Currency) 

 

The formula for Product2.Annual_Revenue is:

 

 Annual_Revenue = Estimated_Monthly_Sales_Volume__c * Total_CO2_Footprint__c *0.0024

 

 

 

I'm trying to create a trigger so that when a Product is added or modified, the AnnualRevenue field in Accounts will automatically reflect the total value of all Products which lookup that account.

 

This is the trigger I've created:

 

trigger UpdateAccountAnnualRevenue 

on Product2 (after delete, after insert, after undelete, after update) 

{

for (Product2 productModified: Trigger.new)

{

List <Product2> accountProduct =

[

select Annual_Revenue__c

from Product2

where ID = :productModified.Account__r.id

];

double Total_Revenue = 0.00;

for (Product2 AP: accountProduct)

{

Total_Revenue += AP.Annual_Revenue__c;

}

for (Account productAccount: 

[

select AnnualRevenue

from Account

where ID = :productModified.Account__r.id

)

{

productAccount.AnnualRevenue = Total_Revenue;

update productAccount;

}

}

 

}

 

 

However, there seems to be a problem with this code.

 

For example, GenWatt Diesel 200kW has an Annual Revenue of $18.67.

 

However, the account Burlington Textiles Corp of America, which has no other assigned products, has an Annual Revenue of $350,000,000

 

 

 

What am I doing wrong and how do I fix it?  

Message Edited by nil_von_9wo on 07-09-2009 07:04 AM