• frank2anil
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 10
    Replies

Hi 

 how to iterate over a map of values and check for the related opportunity and send a email.

trigger salestreenotification on Opportunity (after update) {

 


owner_relmailids.put(op.ownerid,new set<string>());


List<string>s =new List<String>();
for(Integer d=0;d<owner_relmailids.size();d++){ 
}

System.debug('**************************>>'+s);

messaging.Singleemailmessage mail=new messaging.Singleemailmessage();
mail.setToAddresses(s);
mail.setSenderDisplayName('Hult');
mail.setSubject('Opportunity Stage changed to:'+stgName);
mail.setPlainTextBody('The Application record '+Appname+'stage name was been changed to:'+StgName);
try{
messaging.sendEmail(new messaging.Singleemailmessage[]{mail});
}
catch(DMLException e){
system.debug('ERROR SENDING EMAIL:'+e);
}
}

 

I need to compare the opportunity id which i kept in stnmap with the ids in owner_relmailids.

owner_relmailids is contains opportunity owner id and related emails.

and then if both are same then need to send email to the related emails.

i was getting error incompatiable type in iteration so i made the for loop empty.

Could  any one help me.

 

Hi,

 

Please help me in writing the method instead of writing 3 soql statements.

i will pass the owner id it should return all the reporting to ids from salestree upto three levels.

 

trigger salesnotice on Opportunity (after update) {


map<string,string> stnmap=new map<string,string>();
map<Id,String>Reporting2Ids =new map<ID,String>();

for(Opportunity op:trigger.new) { 

if(Trigger.IsUpdate && op.Stagename!=Trigger.oldMap.get(op.Id).Stagename &&(op.StageName=='Confirmed' || op.StageName==' Application' || op.StageName==' Endorsed Confirmed')){
stnmap.put(op.ownerid,op.id);

}
}
salestree(stnmap);
public static void salestree(map<String,String> x){

list<Sales__c> lstst= [select id,Subordinate__c,Subordinate__r.Email,Repo__c,Repo__r.Email from Sales__c where Subordinate__c IN : x.keyset()];
if(!lstst.isempty()){
for(Sales__c s:lstst){
Reporting2Ids.put(s.repo__c,s.Repo__r.Email);
}
}
list <Sales__c> lstst1= [select id,Repo__c,Repo__r.Email from Sales__c where Subordinate__c IN :Reporting2Ids.keyset()];
if(!lstst1.isempty()){
for(Sales__c s:lstst1){
Reporting2Ids.put(s.repo__c,s.Repo__r.Email);
}
}
list <Sales__c> lstst2= [select id,Repo__c,Repo__r.Email from Sales__c where Subordinate__c IN :Reporting2Ids.keyset()];
if(!lstst2.isempty()){
for(Sales__c s:lstst2){
Reporting2Ids.put(s.repo__c,s.Repo__r.Email);
}
}

}
List<string>s =new List<String>();
s=Reporting2Ids.values();

System.debug('**************************>>'+s);

}

 

Thanks In advance.

 

Hi

There is a vf page where it contains 2 record type records .
1.sales
2.service

I have a field called Dontcall__c in both record types.
I have a validation rule where a record type :-service  and Dontcall__c :- true and profile :- service it should through an error .
 the validation rule is working fine .

the issue occurs when i edit the VF page and save if there are any already existing records with Dontcall__c true which are checked by other profiles then its giving error on save for service profiles also then i need all the check boxes false and need to save it but those check boxes are not checked by me the are checked by some other profiles.

how to over come this issue in vf on edit and  saving the record.

 

iam using <apex: page messages/> in vf page to show the standard validation error.

Thanks in Advance

Hi

 

I want to check the email field and display the error message if the email already exists in my system.

i used the salesforce code but its giving me this error:-

Review all error messages below to correct your data.
Apex trigger Lead_Emailduplicate_preventonLead caused an unexpected exception, contact your administrator: Lead_Emailduplicate_preventonLead: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times):-

 

trigger leadDuplicatePreventer on Lead
                               (before insert, before update) {

    Map<String, Lead> leadMap = new Map<String, Lead>();
    for (Lead lead : System.Trigger.new) {
        
        // Make sure we don't treat an email address that  
    
        // isn't changing during an update as a duplicate.  
    
        if ((lead.Email != null) &&
                (System.Trigger.isInsert ||
                (lead.Email !=
                    System.Trigger.oldMap.get(lead.Id).Email))) {
        
            // Make sure another new lead isn't also a duplicate  
    
            if (leadMap.containsKey(lead.Email)) {
                lead.Email.addError('Another new lead has the '
                                    + 'same email address.');
            } else {
                leadMap.put(lead.Email, lead);
            }
       }
    }
    
    // Using a single database query, find all the leads in  
    
    // the database that have the same email address as any  
    
    // of the leads being inserted or updated.  
    
    for (Lead lead : [SELECT Email FROM Lead
                      WHERE Email IN :leadMap.KeySet()]) {
        Lead newLead = leadMap.get(lead.Email);
        newLead.Email.addError('A lead with this email '
                               + 'address already exists.');
    }
}

 

 

 

hi guys,

 

I have a relatd list called feed back on accounts and contacts.

My requirement is when ever a feedback is created it should display in the relatd opportunity also.

if a feedback is created from oppty it should visible in contact also.

please help me with a triigger.

 

Thanks in advance.

 

Thanks

Frank

Hi guys,

 

can anyone help me how to make this trigger as bulk trigger.

 

trigger upcom on Finance__c (after insert,after update) {
    
    Finance__c f;
    
    for(Finance__c fs:trigger.new){
    f=fs;
    }
    if(f.Opportunity__c!=null){
   // opportunity op=[select id,name from opportunity where id=:
    for(Comments__c cm:[select id,opportunity__c,Finance__c from Comments__c where Opportunity__c=:f.opportunity__c limit 1]){
    cm.finance__c=f.id;
    update cm;
    }
    }

}

 

Thanks

Frank

Hi guys,

 

my problem is there are two strings with some value i need to remove the zeros before the number and add both the strings .

 

Ex:-

String S=000578;

String j=080554321;

String k=s+j    ( not addition);

k                                 =  s    +     j;

57880554321        =   578+ 80554321;

 

it means it shoul remove all the zeros before the number.

Some times s=0578;

                        j=00080554321;

 

then also the out put should be same as above "k"

 

 

 

Thanks

frank

 

 

Hi guys,

 

I am new to salesforce .i am facing a problem can any body help me out.

 

Problem:-

 

I had a lookup filed called broker onto( contact) in opportunity.

And another lookup filed in a custom object (loan)with the same name broker on to (contact).

my requirement is if i update the  broker in loan it should update the opportunity broker field.

if i update with latest value in opportunity broker then it should update the same value in loan object broker filed.

 

please help me in these in writing the trigger.

 

Thanks in Advance.

Hi,

 

Please help me in writing the method instead of writing 3 soql statements.

i will pass the owner id it should return all the reporting to ids from salestree upto three levels.

 

trigger salesnotice on Opportunity (after update) {


map<string,string> stnmap=new map<string,string>();
map<Id,String>Reporting2Ids =new map<ID,String>();

for(Opportunity op:trigger.new) { 

if(Trigger.IsUpdate && op.Stagename!=Trigger.oldMap.get(op.Id).Stagename &&(op.StageName=='Confirmed' || op.StageName==' Application' || op.StageName==' Endorsed Confirmed')){
stnmap.put(op.ownerid,op.id);

}
}
salestree(stnmap);
public static void salestree(map<String,String> x){

list<Sales__c> lstst= [select id,Subordinate__c,Subordinate__r.Email,Repo__c,Repo__r.Email from Sales__c where Subordinate__c IN : x.keyset()];
if(!lstst.isempty()){
for(Sales__c s:lstst){
Reporting2Ids.put(s.repo__c,s.Repo__r.Email);
}
}
list <Sales__c> lstst1= [select id,Repo__c,Repo__r.Email from Sales__c where Subordinate__c IN :Reporting2Ids.keyset()];
if(!lstst1.isempty()){
for(Sales__c s:lstst1){
Reporting2Ids.put(s.repo__c,s.Repo__r.Email);
}
}
list <Sales__c> lstst2= [select id,Repo__c,Repo__r.Email from Sales__c where Subordinate__c IN :Reporting2Ids.keyset()];
if(!lstst2.isempty()){
for(Sales__c s:lstst2){
Reporting2Ids.put(s.repo__c,s.Repo__r.Email);
}
}

}
List<string>s =new List<String>();
s=Reporting2Ids.values();

System.debug('**************************>>'+s);

}

 

Thanks In advance.

 

Hi

There is a vf page where it contains 2 record type records .
1.sales
2.service

I have a field called Dontcall__c in both record types.
I have a validation rule where a record type :-service  and Dontcall__c :- true and profile :- service it should through an error .
 the validation rule is working fine .

the issue occurs when i edit the VF page and save if there are any already existing records with Dontcall__c true which are checked by other profiles then its giving error on save for service profiles also then i need all the check boxes false and need to save it but those check boxes are not checked by me the are checked by some other profiles.

how to over come this issue in vf on edit and  saving the record.

 

iam using <apex: page messages/> in vf page to show the standard validation error.

Thanks in Advance

hi guys,

 

I have a relatd list called feed back on accounts and contacts.

My requirement is when ever a feedback is created it should display in the relatd opportunity also.

if a feedback is created from oppty it should visible in contact also.

please help me with a triigger.

 

Thanks in advance.

 

Thanks

Frank

Hi guys,

 

can anyone help me how to make this trigger as bulk trigger.

 

trigger upcom on Finance__c (after insert,after update) {
    
    Finance__c f;
    
    for(Finance__c fs:trigger.new){
    f=fs;
    }
    if(f.Opportunity__c!=null){
   // opportunity op=[select id,name from opportunity where id=:
    for(Comments__c cm:[select id,opportunity__c,Finance__c from Comments__c where Opportunity__c=:f.opportunity__c limit 1]){
    cm.finance__c=f.id;
    update cm;
    }
    }

}

 

Thanks

Frank

Hi guys,

 

my problem is there are two strings with some value i need to remove the zeros before the number and add both the strings .

 

Ex:-

String S=000578;

String j=080554321;

String k=s+j    ( not addition);

k                                 =  s    +     j;

57880554321        =   578+ 80554321;

 

it means it shoul remove all the zeros before the number.

Some times s=0578;

                        j=00080554321;

 

then also the out put should be same as above "k"

 

 

 

Thanks

frank

 

 

Hi guys,

 

I am new to salesforce .i am facing a problem can any body help me out.

 

Problem:-

 

I had a lookup filed called broker onto( contact) in opportunity.

And another lookup filed in a custom object (loan)with the same name broker on to (contact).

my requirement is if i update the  broker in loan it should update the opportunity broker field.

if i update with latest value in opportunity broker then it should update the same value in loan object broker filed.

 

please help me in these in writing the trigger.

 

Thanks in Advance.