• Ashu3006
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi All,

 

I have the requirment ,

i have one Account with Name "Test " and it has 10 Opportunities for that Account "Test" I need to allow to delete the Account "Test"  record only if the all Opportunites status have closed/own.

And i am not getting how to develop the trigger .

Can u please help me out who toi build the Logic

 

 

Regards

Anu

 

 

 

Hi Everyone,

 

I am getting the following Err "" Compile Error: set must have exactly 1 type argument at line 1 column 1"

 

 

trigger Test123 on Lead(before insert, before update) {
        //Set<Id,Integer> ownerids=new Set<Id,Integer>();
        
        Set<Id> ownerids=new Set<Id>();
    
//reterving the owner id for the lead
for(Lead l : Trigger.new)
{
        Id ownerId=l.OwnerId;
        ownerids.add(ownerId);
    //User theower1=[SELECT Id, Region__c FROM User where Id = :l.OwnerId];
    //User theowner=[SELECT id,region__c FROM USER WHERE id=l.ownerId];u
}   
List<User> theower1=[SELECT Id, Region__c FROM User where Id IN:ownerids];
Map<Id.User> userownerlead=new Map<Id.User>(theower1);

    
    for(Lead l : Trigger.new)
        l.Region__c=theower1.Region__c;
         l.Region__c=userownerlead.get(l.OwnerId).Region__c;
         
}
}

 

Can u please what is going wroing in my code

thanks for help in advance

HI Everyone,

I have created the custom controller and the visual force page ,

But when run the visualforce page i am no able to get the Account.Name and other Contact details below is the

Apex code and visualforce

 

public class sendEmail {
public String subject { get; set; }
public String body { get; set; }
private final Account account;
// Create a constructor that populates the Account object
public sendEmail() {
List<Account> account= [select Name, (SELECT Contact.Name, Contact.Email FROM Account.Contacts)
from Account] where id = :ApexPages.currentPage().getParameters().get('id')];
}
public Account getAccount() {
return Account;
}
public PageReference send() {
// Define the email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String addresses;
if (account.Contacts[0].Email != null)
{
addresses = account.Contacts[0].Email;
// Loop through the whole list of contacts and their emails
for (Integer i = 0; i < account.Contacts.size(); i++)
{
if (account.Contacts[i].Email != null)
{
addresses += ':' + account.Contacts[i].Email;
}
}
}
String[] toAddresses = addresses.split(':', 0);
// Sets the paramaters of the email
email.setSubject( subject );
email.setToAddresses( toAddresses );
email.setPlainTextBody( body );
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
return null;
}
}

/****************VisualForcePage********************************/

<apex:page controller="sendEmail">
<apex:messages />
        <apex:pageBlock title="Send an Email to Your{!account.name} Representatives">
        <p>Fill out the fields below to test how you might send an email to a user.</p>
        <br />
        <apex:dataTable value="{!account.Contacts}" var="contact" border="1">
        <apex:column >
        <apex:facet name="header">Name</apex:facet>
        {!contact.Name}
        </apex:column>
       
        <apex:column >
        <apex:facet name="header">Email</apex:facet>
        {!contact.Email}
        </apex:column>
       </apex:dataTable>

<apex:form >
<br /><br />
<apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
<br /><br />
<apex:outputLabel value="Body" for="Body"/>:<br />
<apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/>
<br /><br /><br />
<apex:commandButton value="SendEmail" action="{!send}" />
</apex:form>
</apex:pageBlock>
</apex:page>

 

Can u pl suggets what going wrong

 

Regard

Ashu

 

Hi Everyone,

 

I am getting the following Err "" Compile Error: set must have exactly 1 type argument at line 1 column 1"

 

 

trigger Test123 on Lead(before insert, before update) {
        //Set<Id,Integer> ownerids=new Set<Id,Integer>();
        
        Set<Id> ownerids=new Set<Id>();
    
//reterving the owner id for the lead
for(Lead l : Trigger.new)
{
        Id ownerId=l.OwnerId;
        ownerids.add(ownerId);
    //User theower1=[SELECT Id, Region__c FROM User where Id = :l.OwnerId];
    //User theowner=[SELECT id,region__c FROM USER WHERE id=l.ownerId];u
}   
List<User> theower1=[SELECT Id, Region__c FROM User where Id IN:ownerids];
Map<Id.User> userownerlead=new Map<Id.User>(theower1);

    
    for(Lead l : Trigger.new)
        l.Region__c=theower1.Region__c;
         l.Region__c=userownerlead.get(l.OwnerId).Region__c;
         
}
}

 

Can u please what is going wroing in my code

thanks for help in advance