• Nallapati
  • NEWBIE
  • 108 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies

Now that I've created a couple of record types for a custom object, how do change which record type is the default now that they are created?

Hi!

 

I have problems with writing an email template for event-object. I have a trigger which should be fired after insert. It should send an email to the customer(account).

 

I am getting the following error msg when saving the event.

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger sendEmailTemplate caused an unexpected exception, contact your administrator: sendEmailTemplate: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only Users, Contact or Lead allowed for targetObjectId : 00UT00000024Rod.: []: Trigger.sendEmailTemplate: line 26, column 12

 

The trigger follows here:

 

trigger sendEmailTemplate on Event (after insert) {
 list<event> list_evt = new List<event>();
 List<id> list_id = new List<Id>();
    for (event e : Trigger.new) {   
        list_evt.add(e);
        list_id.add(e.whoid);
    }

       
    List<Contact> conList = [select Id,Name,Email from Contact where Id in :list_id];

        if (list_evt.get(0).Subject =='1.gang' ){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
            //Contact con = list_evt.get(0).Who   
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId(list_evt.get(0).id);
            mail.setWhatId(trigger.new[0].id);
            mail.setTemplateId('00XA0000000a6IP');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }

}

 

The VF template is as following(It's not finished, it's just a start for see that things works

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Event" subject="Møtebekreftelse norKapital">
<messaging:htmlEmailBody >
<html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 11px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
         <font face="arial" size="2">
                
              Til {!recipient.Name}

              Velkommen til møte hos oss den {!relatedTo.StartDateTime}.
 
    
         </font>
        </body>
</html>

</messaging:htmlEmailBody>

<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

 

 

I hope someone can help me.

Hi all,

 

I need to add the Orders__c.ID value to every Ordered_SKU__c.Order__c field on save.  I can't figure out how to get it in there... Any suggestions?

 

 

public class orderInsert {

Orders__c orders;
List<Ordered_SKU__c> skus {get; set;}

public Orders__c getOrders(){
if(orders == null){
orders = new Orders__c();
}
return orders;
}

public orderInsert(){
skus = new List<Ordered_SKU__c>();
skus.add(New Ordered_SKU__c()); // I've tried (New Ordered_SKU__c(Order__c = orders.id)); but obviously that returns a null value.
}

public void addrow(){
skus.add(new Ordered_SKU__c());
}

public PageReference save() {
try{
insert orders;
insert skus;
}
catch(DmlException ex){
ApexPages.addMessages(ex);
}
PageReference pr = new PageReference('/'+orders.id);
pr.setRedirect(true);
return pr;
}
}

 

 

  • June 29, 2010
  • Like
  • 0

I want to deploy "name" field of a custom object from one sandbox to other sandbox. The object is already in both sandboxes. I tried using ANT tool.

 

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>COB__c.Name</members>
 <name>CustomField</name>
</types>
<version>24.0</version>
</Package>

 

I got the below error : 

 

Error: package.xml(COB__c.Name):An object 'COB__c.Name' of type CustomField was named in package.xml, but was not found in zipped directory

 

 

I have tried extracting the complete object but ANT is not extracting the "Name" filed.

<types>
<members>COB__C.Name</members>
 <name>CustomObject</name>
</types>

 

 

Please suggest how to do this

Hi I have a VF page included on Account page layout.

 

(I dont want to create seperate Pagelayouts because the render citeria may change )

 

I want to hide or show this VFpage based on Running users profile. I tried using "Rendered" BUT when i hide the page using "Rendered= false".

A BIG whitespage is shown in place of the VF page.

 

I tried using Javascript. window.resizeTo(800,200). But this is only working for IE6.

Please help 

 

I have a Scheduled a job which calls a future method of a class. but i have received the following error Apex script unhandled exception by user/organization: ---xxxxxxxxx----/---xxxxxxxxx-- Failed to invoke future method 'public static void FunctionOne()' on class 'SchClass' for job id '---xxxxxx---'. What is setCommitAllowed() method? Thanks

Now that I've created a couple of record types for a custom object, how do change which record type is the default now that they are created?

Hi!

 

I have problems with writing an email template for event-object. I have a trigger which should be fired after insert. It should send an email to the customer(account).

 

I am getting the following error msg when saving the event.

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger sendEmailTemplate caused an unexpected exception, contact your administrator: sendEmailTemplate: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only Users, Contact or Lead allowed for targetObjectId : 00UT00000024Rod.: []: Trigger.sendEmailTemplate: line 26, column 12

 

The trigger follows here:

 

trigger sendEmailTemplate on Event (after insert) {
 list<event> list_evt = new List<event>();
 List<id> list_id = new List<Id>();
    for (event e : Trigger.new) {   
        list_evt.add(e);
        list_id.add(e.whoid);
    }

       
    List<Contact> conList = [select Id,Name,Email from Contact where Id in :list_id];

        if (list_evt.get(0).Subject =='1.gang' ){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
            //Contact con = list_evt.get(0).Who   
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId(list_evt.get(0).id);
            mail.setWhatId(trigger.new[0].id);
            mail.setTemplateId('00XA0000000a6IP');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }

}

 

The VF template is as following(It's not finished, it's just a start for see that things works

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Event" subject="Møtebekreftelse norKapital">
<messaging:htmlEmailBody >
<html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 11px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
         <font face="arial" size="2">
                
              Til {!recipient.Name}

              Velkommen til møte hos oss den {!relatedTo.StartDateTime}.
 
    
         </font>
        </body>
</html>

</messaging:htmlEmailBody>

<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

 

 

I hope someone can help me.

I have a Scheduled a job which calls a future method of a class. but i have received the following error Apex script unhandled exception by user/organization: ---xxxxxxxxx----/---xxxxxxxxx-- Failed to invoke future method 'public static void FunctionOne()' on class 'SchClass' for job id '---xxxxxx---'. What is setCommitAllowed() method? Thanks

Hi all,

 

I need to add the Orders__c.ID value to every Ordered_SKU__c.Order__c field on save.  I can't figure out how to get it in there... Any suggestions?

 

 

public class orderInsert {

Orders__c orders;
List<Ordered_SKU__c> skus {get; set;}

public Orders__c getOrders(){
if(orders == null){
orders = new Orders__c();
}
return orders;
}

public orderInsert(){
skus = new List<Ordered_SKU__c>();
skus.add(New Ordered_SKU__c()); // I've tried (New Ordered_SKU__c(Order__c = orders.id)); but obviously that returns a null value.
}

public void addrow(){
skus.add(new Ordered_SKU__c());
}

public PageReference save() {
try{
insert orders;
insert skus;
}
catch(DmlException ex){
ApexPages.addMessages(ex);
}
PageReference pr = new PageReference('/'+orders.id);
pr.setRedirect(true);
return pr;
}
}

 

 

  • June 29, 2010
  • Like
  • 0

I have a Custom Object Called Services_Selection which is a Master/Detail to an Account.

 

When a certain field in Account is updated or changed (for instance a field called "Base Fee"), I want to update a field in all the related Services_Selection records.  

 

Since I am not aware on how to write this code I will explain it out:

 

When Account.BaseFee is changed/updated,

 

Set Services_Selection.Field1 = Services_Selection.Field2

 

Loop this until all child records are updated.  

 

If you have any questions, I will be glad to answer. Thanks in advance

 

Thank you,

 

 

 

  • April 27, 2010
  • Like
  • 0