• mallikharjunarao gunda
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 11
    Replies
 HI all
 I try to this code no errors, when i insert the caserecord . image will not appear on the richtextarea field
see this code
global class InboundEmailexample implements Messaging.InboundEmailHandler{
global messaging.InboundEmailResult handleinboundemail(Messaging.InboundEmail email,messaging.InboundEnvelope envp){
    
 
    Messaging.InboundEmailResult result=new Messaging.InboundEmailResult();
   
     
            Case c=new Case();
            c.origin='Email';
            c.Priority='Normal';
            c.Status='Open';
            c.subject=email.subject;
              c.texxtimages__c=email.htmlBody;
          insert c;
           
     map<string,attachment> mapattachement=new map<string,attachment>();
    if(email.binaryAttachments!=null){
    for(Messaging.Inboundemail.BinaryAttachment ba : email.binaryAttachments) {
        system.debug(ba);
        for(integer i=0; i<ba.headers.size(); i++){
            string headervalue=ba.headers[i].value;
            system.debug('head'+headervalue);
            system.debug('headername'+headervalue);
          if(headerValue.startsWith('ii') || headerValue.startsWith('< image')) {
      headerValue = headerValue.replaceAll('<', '').replaceAll('>', '');
   mapattachement.put(headerValue, new Attachment(Name = bA.fileName, body = bA.body, 
                  ParentId = c.Id, ContentType = bA.mimeTypeSubType));
                }
        }
        }
    }
    
   
    insert mapattachement.values();
   
for(String headerValue :mapattachement.keySet()) {
    system.debug(headerValue);
    
            //Reference Link
            String refLink = '/servlet/servlet.FileDownload?file=' +mapattachement.get(headerValue).Id;
            c.texxtimages__c = c.texxtimages__c    .replaceAll('cid:' +headerValue, refLink);
        }
      update c;
        
    
        return result;
    
    
    
    }
    

}
content source: URL
{IF(Opportunity.parent__c==null, 
URLFOR($Action.Opportunity.New,null,[clone=1,id=Opportunity.Id,retURL="/"&Opportunity.Id,00N2800000FJLEz= Opportunity.Name ],true), 
Opportunity.parent__c

}
Error: Enter a URL that is valid and well-formed
please helpme
see this code
{IF(Opportunity.parent__c==null, 
URLFOR($Action.Opportunity.New,null,[clone=1,id=Opportunity.Id,retURL="/"&Opportunity.Id,00N2800000FJLEz= Opportunity.Name ],true), 
Opportunity.parent__c

}
Error: Enter a URL that is valid and well-formed

 i tried to this code

{!IF({!Opportunity.parent__c}=null,https://ap2.salesforce.com/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&00N2800000FJLEz="{!Opportunity.Name}",{!Opportunity.parent__c})}
 
hai i tryed to this, it doesn't populate the field values
https://ap2.salesforce.com/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&{!Opportunity.parent__c}="{!Opportunity.Account}"
hai hall  i  wrote a code but it throws an error

public class inlinewrapper {
    public string startdate{set;get;}
    public opportunity  opps{set;get;}
   

}



public class inappps {
    public list<opportunity>apps{set;get;}
    public inlinewrapper linewrapper{set;get;}
    public decimal yeargap{set;get;}
    public inappps(){
        
        apps=[select id, name,CreatedDate ,closedate from opportunity];
         for(opportunity os:apps){
        linewrapper=new inlinewrapper();
        linewrapper.startdate= string.valueof(os.CreatedDate);
        linewrapper.opps=os;
  
             
        }
    
            
        }
       public void caluclation( ){
             linewrapper=new inlinewrapper();
           datetime dt1= datetime.valueof(linewrapper.startdate);
           date convertation=date.newinstance(dT1.year(), dT1.month(), dT1.day());
           date close=linewrapper.opps.closedate;
            yeargap=(convertation.monthsBetween(close));
           
}
}

<apex:page controller="inappps" docType="html-5.0">
    <apex:form >
        <apex:pageblock >
        <apex:pageblockbuttons location="top">
            <apex:commandbutton value="show" action="{!caluclation}"/>
            </apex:pageblockbuttons>
         <apex:pageblocktable value="{!linewrapper}" var="s">
        <apex:column >
          Date: <apex:inputText value="{!s.startdate}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this ,true);" />  
             </apex:column>  
             <apex:column headerValue="closedate">
                 <apex:outputfield value="{!s.opps.closedate}">
                     <apex:inlineeditsupport event="ondblclick"/>
                 </apex:outputfield>
             </apex:column>
            </apex:pageblocktable>
            {!yeargap}
        </apex:pageblock>
    </apex:form>
</apex:page>
 hai hall 
 i need to edit the created date field on the vf page through apex class query
batch apex:
global class BatchApexDemo implements database.batchable<sobject>{
Public string soqlquery;
 Public void setQry(string soqlquery){
    this.soqlquery = 'Select name,status from account limit 1';  
 }
 global database.querylocator start(database.batchableContext bc){
   return database.getquerylocator(soqlquery);
 }
 global void execute(database.batchablecontext bd, list<sObject> sc){
   System.debug('**In Execute Method**');  
 }
 Public void finish(database.batchableContext bc){ 
 }
}
trigger
trigger callbatchapex on Account (after insert) {
 List<account> accList = new List<account>();
 for(account acc : trigger.new){
     if(acc.annualrevenue < 20000)
        accList.add(acc); 
 }
    if(accList.size() > 0)
      database.executebatch(new BatchApexDemo(),200);
}
 
haill all
trigger code:
public class triggerhandler1 {
public static boolean flag=true;
}
trigger recursivetriggers on Account (After update) {
map<id,account>oldmap=trigger.oldmap;
map<id,account>newmap=trigger.newmap;
    set<id>setid=new set<id>();
    if(trigger.isafter && trigger.isupdate){
        if(triggerhandler1.flag==true)
        {
            triggerhandler1.flag=false;
    for(id ids:oldmap.keyset())
    {
        if(oldmap.get(ids).rating=='Hot')
        {
            setid.add(ids);
        }
    }
    }
    }
    list<account>acc=[select id,name,rating,rating1__c from account where id=:setid];
    if(acc.size()>0)
    {
        for(account a:acc)
        {
            a.rating1__c=oldmap.get(a.id).rating;
        }
    }
    update acc;
}
 
hal all
this is my trigger code& test class
getting code coverage 100% but method doesnot pass
trigger Accountactive on Account (after update) {
map<id,account>newmap=trigger.newmap;
map<id,account>oldmap=trigger.oldmap;
    list<id>listid=new list<id>();
for(id ids:oldmap.keyset())
{
    if(oldmap.get(ids).Actives__c=='Yes'&&newmap.get(ids).Actives__c=='No')
    {
        listid.add(ids);
    }

 list<contact>cons=[select id,lastname,phone,accountid from contact where accountid=:listid];
 delete cons;
}

testclass
@istest
public class Accountactivefortestclass {
@istest
    static void testme(){
        Account sc=new Account(name='NNN',Actives__c='Yes');
        insert sc;
        contact cs=new contact(lastname='NMN',Accountid=sc.id);
        insert cs;
        string ratings='No';
        account accs=[select id,name,Actives__c from account where id=:sc.id];
        accs.Actives__c=ratings;
       
        update accs;
          system.assertequals(accs.Actives__c,sc.Actives__c);
       
        //account ac=[select id,name,Actives__c from account where id=:sc.id];
       //system.assertEquals('No',ac.Actives__c);
       
        
    }
}
Hai hall  I am not getting code coverage please helpme
Trigger code
 
trigger Assignannualrevenue on Account (before update)

    if(trigger.isBefore && trigger.isupdate)
{
    for(account a:trigger.new){
        if(a.industry=='Banking')
        a.AnnualRevenue=1000;
         else if(a.industry=='Energy')
        a.AnnualRevenue=5000;
        else
            a.AnnualRevenue=50000;
    }
    }
}

testclass
@istest
public class AssignAnnualrevenue_Test {
@istest
    static void testme(){
       
        Account a1=new account(name='lll',industry='banking',Annualrevenue=null);
        Account a2=new account(name='kkkk',industry='energy' ,Annualrevenue=null);
        Account a3=new account(name='jjj',Annualrevenue=null);
        insert a1;
           insert a2;
           insert a3;
        
        decimal an=1000;
        account ac=[select id,name,industry,Annualrevenue from account where id=:a1.id];
       ac.AnnualRevenue=an;
        system.assertEquals(1000, ac.AnnualRevenue);
        update ac;
          decimal a=5000;
        account ae=[select id,name,industry,Annualrevenue from account where id=:a2.id];
       ae.AnnualRevenue=a;
        system.assertEquals(5000, ae.AnnualRevenue);
        update ae;
        decimal aa=50000;
        account ad=[select id,name,industry,Annualrevenue from account where id=:a3.id];
       ad.AnnualRevenue=aa;
        system.assertEquals(50000, ad.AnnualRevenue);
        update ad;
       
        
        //system.assertEquals(1000, ac.AnnualRevenue);
        //system.assertEquals(5000, ae.AnnualRevenue);
        //system.assertEquals(50000, ad.AnnualRevenue);
     
        
  
    }
}
 
Hai hall
 i got only 88% code only

i wrote my trigger code & testclass below  please help me.
Red mark show only a.name.adderror in code coverage.
trigger code:
trigger validationoncontact on Account (before insert) {
    set<string>setv=new set<string>();
       // soql query to return the no of records.
    list<contact>con=[select id,lastname from contact];
       // if size of the records is more than 0 ,then proceed our logic
     if(con.size()>0)
    { 
        // Return the number of records one by one
       for(contact c:con)
       {
           // add a contact lastname to setv  to comapre the values. 
       setv.add(c.lastname);
        }
        }
    // "trigger.new" which holds the list of new records, whatever trying to insert the records. 
    for(account a:trigger.new){
        
       // it returns a true if the string contains specfied character otherwise it return false.
        
    if(setv.contains(a.name)){
        
            a.name.adderror('Duplicate : Already contact is Existed with this name');
        }
    }
  }

test class 
@istest
public class testclassforvalidationcontact {
@istest
    static void testme(){
     contact c=new contact(lastname='arjun');
        insert c;
        string names='';
        list<contact>cc=[select id,lastname from contact where id=:c.id];
        for(contact c1:cc){
            names=c1.lastname;
        }
        account a1=new account(name='mallik');
        try{
            insert a1;
            system.assertnotEquals(a1.name, names);
        }catch(exception e){
            System.debug('should not be created duplicate record');
        }
    }
}

 
hail see my code it cannot updated
trigger Activestatus on Policy_Holder__c (after insert) {
list<Motor_Insurance__c>motor=new list<Motor_Insurance__c>();
    set<id>setid=new set<id>();
    if(trigger.isafter && trigger.isinsert){
    for(Policy_Holder__c p:trigger.new)
    {
        if(p.status__c==true)
        {
          setid.add(p.Id);  
        }
    }
    }
    list<Motor_Insurance__c> mot=[select id,Premium_Amount__c,No_of_Terms__c,status__c
                            from Motor_Insurance__c  where id=:setid];
    if(mot.size()>0 && mot.size()!=null){
    for(Motor_Insurance__c c:mot)
    {
        if(c.status__c==false){
            c.status__c=true;
        }
    }
    }
    update mot;
}
HAi hallll
I need to  enable  the fields if i select the checkbox ,if i deselect the checkbox  dissable the fields how cani i do that please let me now
hai hall


ihave a two account records with the same name but when i try to diaplay those records on vfpage avoid the duplicate names 
 how we can achieve please helpme
hai hall
i have a customer__c and payment__c objects ,payment__c has lookup to customer__c.
here customer__c object having a one record and payment__c having a ten records out of ten records six records having one user and four records having another user .  all tese records associate to the  customer__C .if i deactive the customer__c record ownerid ,those whose records will be higher in payment__c object that user can be assigned to the customer__c objectrecord

i wrote code something 
trigger userchange on User (after update) {    
    list<customer__c> cust=[select id, first_name__c from customer__c where first_name__c='chanda shekar'];
    list<user> u=[select id from user];
    List<Id>ids=new list<Id>();
    map<Id, list<payment__c>> getRecords=new map<Id, list<payment__C>>();
    Map<Id,Customer__C> customerMap=new Map<Id,Customer__C>([select id,ownerId ,(select id,ownerId from Payments__r) from Customer__c where ownerId in:Trigger.Newmap[0].Id]);
    Map<Id,List<Payment__c> > cusMap=new Map<Id,List<Payment__c>();
    for(Id id:customerMap.keySet()){
        for(Payment__c p:customerMap.get(id).payments__r){
            if(cusMap.keySet().contains(p.ownerId)){
                
            }
        }
    }
    
    }
Error: Enter a URL that is valid and well-formed
please helpme
see this code
{IF(Opportunity.parent__c==null, 
URLFOR($Action.Opportunity.New,null,[clone=1,id=Opportunity.Id,retURL="/"&Opportunity.Id,00N2800000FJLEz= Opportunity.Name ],true), 
Opportunity.parent__c

}
Error: Enter a URL that is valid and well-formed

 i tried to this code

{!IF({!Opportunity.parent__c}=null,https://ap2.salesforce.com/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&00N2800000FJLEz="{!Opportunity.Name}",{!Opportunity.parent__c})}
 
haill all
trigger code:
public class triggerhandler1 {
public static boolean flag=true;
}
trigger recursivetriggers on Account (After update) {
map<id,account>oldmap=trigger.oldmap;
map<id,account>newmap=trigger.newmap;
    set<id>setid=new set<id>();
    if(trigger.isafter && trigger.isupdate){
        if(triggerhandler1.flag==true)
        {
            triggerhandler1.flag=false;
    for(id ids:oldmap.keyset())
    {
        if(oldmap.get(ids).rating=='Hot')
        {
            setid.add(ids);
        }
    }
    }
    }
    list<account>acc=[select id,name,rating,rating1__c from account where id=:setid];
    if(acc.size()>0)
    {
        for(account a:acc)
        {
            a.rating1__c=oldmap.get(a.id).rating;
        }
    }
    update acc;
}
 
Hai hall
 i got only 88% code only

i wrote my trigger code & testclass below  please help me.
Red mark show only a.name.adderror in code coverage.
trigger code:
trigger validationoncontact on Account (before insert) {
    set<string>setv=new set<string>();
       // soql query to return the no of records.
    list<contact>con=[select id,lastname from contact];
       // if size of the records is more than 0 ,then proceed our logic
     if(con.size()>0)
    { 
        // Return the number of records one by one
       for(contact c:con)
       {
           // add a contact lastname to setv  to comapre the values. 
       setv.add(c.lastname);
        }
        }
    // "trigger.new" which holds the list of new records, whatever trying to insert the records. 
    for(account a:trigger.new){
        
       // it returns a true if the string contains specfied character otherwise it return false.
        
    if(setv.contains(a.name)){
        
            a.name.adderror('Duplicate : Already contact is Existed with this name');
        }
    }
  }

test class 
@istest
public class testclassforvalidationcontact {
@istest
    static void testme(){
     contact c=new contact(lastname='arjun');
        insert c;
        string names='';
        list<contact>cc=[select id,lastname from contact where id=:c.id];
        for(contact c1:cc){
            names=c1.lastname;
        }
        account a1=new account(name='mallik');
        try{
            insert a1;
            system.assertnotEquals(a1.name, names);
        }catch(exception e){
            System.debug('should not be created duplicate record');
        }
    }
}

 
hail see my code it cannot updated
trigger Activestatus on Policy_Holder__c (after insert) {
list<Motor_Insurance__c>motor=new list<Motor_Insurance__c>();
    set<id>setid=new set<id>();
    if(trigger.isafter && trigger.isinsert){
    for(Policy_Holder__c p:trigger.new)
    {
        if(p.status__c==true)
        {
          setid.add(p.Id);  
        }
    }
    }
    list<Motor_Insurance__c> mot=[select id,Premium_Amount__c,No_of_Terms__c,status__c
                            from Motor_Insurance__c  where id=:setid];
    if(mot.size()>0 && mot.size()!=null){
    for(Motor_Insurance__c c:mot)
    {
        if(c.status__c==false){
            c.status__c=true;
        }
    }
    }
    update mot;
}
HAi hallll
I need to  enable  the fields if i select the checkbox ,if i deselect the checkbox  dissable the fields how cani i do that please let me now
hai hall
i have a customer__c and payment__c objects ,payment__c has lookup to customer__c.
here customer__c object having a one record and payment__c having a ten records out of ten records six records having one user and four records having another user .  all tese records associate to the  customer__C .if i deactive the customer__c record ownerid ,those whose records will be higher in payment__c object that user can be assigned to the customer__c objectrecord

i wrote code something 
trigger userchange on User (after update) {    
    list<customer__c> cust=[select id, first_name__c from customer__c where first_name__c='chanda shekar'];
    list<user> u=[select id from user];
    List<Id>ids=new list<Id>();
    map<Id, list<payment__c>> getRecords=new map<Id, list<payment__C>>();
    Map<Id,Customer__C> customerMap=new Map<Id,Customer__C>([select id,ownerId ,(select id,ownerId from Payments__r) from Customer__c where ownerId in:Trigger.Newmap[0].Id]);
    Map<Id,List<Payment__c> > cusMap=new Map<Id,List<Payment__c>();
    for(Id id:customerMap.keySet()){
        for(Payment__c p:customerMap.get(id).payments__r){
            if(cusMap.keySet().contains(p.ownerId)){
                
            }
        }
    }
    
    }