• babloo123
  • NEWBIE
  • 70 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 57
    Questions
  • 37
    Replies
I am using few merge fields of custom Object on a email template those work fine if I use test and send verify button with merge field values poping for the record of custom object but when condition is met and the template is fired the email template fires but now the merge fields not  appear. Checked the owds and Security as well. Can any one guide stuck on this from many days.
I am trying to mark a date when picklist value is changed to a certain value to that date.

IF(ISPICKVAL(Application_Status__c , "Accept"), TODAY(), NULL)

but issue is since the formula is evaluating to true daily it is changing this date field to today that is if I change to Accept today the date is today tomorrow it is changing to 18th and day after it is changing back to 19th instead I want it to be 17th. Can some one guide me. 

we dont have ISchanged function in formulas
I have a Approval Process that changes a custom field value to x

Workflow rule criteria that custom field =x and another custom field y on it I have a time base email alert which is not firing. Can some one help. It fires if I manually change but not firing when changed through approval process.
Need some guidance on Test Class as the code coverage not happening properly.

Trigger and Class below.

Trigger

----------------------------------------------
trigger SendEmailtoMRO on COI_Expertise__c (after update) {
    string text1='Unclear if COI Exists';
for(COI_Expertise__c ci:trigger.new){
         
  if (ci.Conflict_of_Interest__c.equals(text1)){
 SendEmailHandler.sendEmail(ci.test__c);
  }
      }
        }  Here test__c is ID as we are using the template using ID
--------------------------------------------------------------------------------------------------------------
Class

public class SendEmailHandler {
    
    public static void sendEmail(id targetid){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
 mail.setTargetObjectId(targetid);
  mail.setSenderDisplayName('PCORI');
  mail.setUseSignature(false);
  mail.setBccSender(false);
  mail.setSaveAsActivity(false);
    //checking condition
 
 
   //Template to select from the list of email templates available
          EmailTemplate et=[Select id from EmailTemplate where DeveloperName=:'Unclear_if_COI_Exists'];
     system.debug('The ETID is' + et);
          mail.setTemplateId(et.id);
          Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});   
     system.debug(r);
        
    }

}

---------------------------------------------------------------------------------------------

I get a error saying target is empty

Can someone help in writing a test case for this.
 
I have a trigger on custom objectA that updates custom Object B but I have another trigger on Custom Object B on update Event but when I run trigger 1 the trigger 2 is being automatically called due to the object B being same. Can some one guide how to prevent this.
When I try to dataload I am getting the below error but line 20 whwn checked in query editor works fine. Can some one help where is the mistake.

ERROR: ResearchApplicationTriggers: execution of AfterInsertcaused by: System.QueryException: List has no rows for assignment to SObjectClass.ResearchApplicationTriggerClass.createCOIautomatically: line 20, column 1Trigger.ResearchApplicationTriggers: line 7, column 1

Trigger Handler 

----------------------------------------
//This Trigger is used to automatically create COI and update TechnicalAbstract from RAObject to COI
trigger ResearchApplicationTriggers on Research_Application__c (after insert, after update) {
     ResearchApplicationTriggerClass handler = new ResearchApplicationTriggerClass();
    for(Research_Application__c rap:trigger.new){
     if(Trigger.isInsert && Trigger.isAfter){
         system.debug(rap);
     handler.CreateCOIautomatically(rap); 
         //handler.UpdateCOItechnicalabstract(rap);
    }
     if(Trigger.isUpdate && Trigger.isAfter)
    {
        handler.UpdateCOItechnicalabstract(rap);
    }
}
}

----------------------------------------------------------------------
Trigger Handler Class

//This is a TriggerHandler Class that handles the triggers on ResearchApplication Object
public class ResearchApplicationTriggerClass {
public ResearchApplicationTriggerClass(){}
        //This method creates the COI automatically for all reviewers in the panel assignment for that particular panel.
    public void createCOIautomatically(Research_Application__c rap)
    {
      //Below Soql query gets the list of Reviewers assigned in the pane assignments for that particular Panel  
        list<panel_assignment__c> lp=[select Reviewer_Name__c from panel_assignment__C where panel__C in (select id from panel__c where id =: rap.panel__C )];
system.debug('The Reviewers are' + lp);
        
        for (integer i=0;i<lp.size();i++)
    {
  system.debug(lp[i].Reviewer_Name__c);
   COI_Expertise__c  c=new COI_Expertise__c();
        //Initialize and assign the the COI object with the fields we require
        c.Research_Application__c= rap.Id;
        system.Debug(c.Research_Application__c);
         c.Reviewer_Name__c = lp[i].Reviewer_Name__c;
      system.debug(lp[i].Reviewer_Name__c);
        user u=[select id,firstname,lastname from user where contactID=:lp[i].Reviewer_Name__c];
      Id  usrid=string.valueof(u.id);
        system.debug('USer ID:' + u.id + 'Reviewer ID' + lp[i].Reviewer_Name__c);
        //Assign the owner of the COI to be the same as Reviewer Name
          c.Ownerid = usrid;
       insert(c);
             } 
        
        
            
    }
    
    //This method copies the technical abstract on Research Application to the COI associated to it.
        public void updateCOItechnicalabstract(Research_Application__c rap)
    {
        //Below is the soql query to get the technical abstract from that particular research application
        Research_Application__c fa=[select id,technical_abstract__c from Research_Application__c where id=:rap.Id limit 1];
    system.debug(fa);

    //Below is the soql query to get the COI records from that particular research application
 list<COI_Expertise__c> c=[select id,technical_abstract__c from COI_Expertise__c where Research_Application__r.Id=:fa.Id];
  //Assign the technical abstract from RA to respective COI's
    for(COI_Expertise__c ci:c)
    {
   ci.Technical_Abstract__c=fa.Technical_Abstract__c;
     update(c);   
    }
    
        }
}
I have a situation where I have writtena code where trigger works if we use trigger.new[0] but I want to standardise for multiple records and to try that I removed trigger.new[0] and made just trigger.new which throws a error can some one guide me how to use trigger.new without error
Need to create a visual force email template on a custom Object to view fields (merge fields on that object) can some one guide how?

if any example some one has?
We have used attachment in VF page and we are able to download it. But when opened the downloaded attachment it shows a unknown file type can some one guide me how to open as pdf or any visible format.
Can some one guide me where I can find Communities logout page assignment.
I have a scenario where my custom object record standard page when edited and saved moves back to home page instead of staying back on detail page. Can some one guide how to solve this issue.
I am trying to use a VF Email template but when I use below I am getting the error as
 Error: Unknown property 'core.email.template.EmailTemplateComponentController.COI_Expertise__c'  Can some one guide me where I am wrong
<messaging:emailTemplate subject="xyz" recipientType="Contact" relatedToType="COI_Expertise__c">
<messaging:plainTextEmailBody >
Reviewer Name : {!COI_Expertise__c.Reviewer_Name__c}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Can some one guide me how to prevent users from going back and entering details on VF page after clicking submit as submit function locks the page to edit further. But id he clicks back again the page opens need some guidance on this if any one has come across this issue?
Hi All I am looking to get the contact that is associated with the user who logged in and redirect to the detail page. But it is not throwing any error but I am not able to redirect properly can some one help where the code is wrong?

public class MyContact {

    public PageReference redirect() {
    
   User u=[Select contactid from User where id=:UserInfo.getUserId()];
        system.debug(u);
    
system.debug(u.contactid);
PageReference pageRef = new PageReference('/' + 'u.contactid');
pageref.setredirect(True);
        return pageref;
    }


public MyContact(){}




}
I have a scenario where I need to get my contact record page opened when I click a link. Can some one help me with the code.Do we use Java script for it?
I have a scenario where I am using a VF page on Object and based on Profile I need to assign the page layout.
Profile one needs to see VF page
Rest all profiles can see standard layout

but particular profile(Profile one should not have object view at all but see the VF page )

Can some one please help on this
I have a scenario where I need to create a custom link when clicked on that link I need my contact record to open up. Can some one guide me how to get this done
We want to backup our data and metadata using SVN tortoise but dont know how to do it. Can you please guide me how to do it?
how to add a component on VF page that accepts only numbers 
My requirement is to have phone number entered when I use apex:inputtext then it also allows characters.How to avoid this? Can someone please help?
I have 3 triggers on a object all working seperately well but when I try to run by activating all three together I am getting error. I came to know I need to use Trigger Handler methods can some one give idea how to use this in example not understanding in the link which shows the details?
I am using few merge fields of custom Object on a email template those work fine if I use test and send verify button with merge field values poping for the record of custom object but when condition is met and the template is fired the email template fires but now the merge fields not  appear. Checked the owds and Security as well. Can any one guide stuck on this from many days.
I have a trigger on custom objectA that updates custom Object B but I have another trigger on Custom Object B on update Event but when I run trigger 1 the trigger 2 is being automatically called due to the object B being same. Can some one guide how to prevent this.
Need to create a visual force email template on a custom Object to view fields (merge fields on that object) can some one guide how?

if any example some one has?
I have a scenario where my custom object record standard page when edited and saved moves back to home page instead of staying back on detail page. Can some one guide how to solve this issue.
Can some one guide me how to prevent users from going back and entering details on VF page after clicking submit as submit function locks the page to edit further. But id he clicks back again the page opens need some guidance on this if any one has come across this issue?
I have a scenario where I need to create a custom link when clicked on that link I need my contact record to open up. Can some one guide me how to get this done
Hi I have a scenario where the contact has a checkbox called IS user active which has to be updated as and when user becomes inactive to false.

I wrote a trigger to do it showed me a mixed DML error and wrote the below code using future method as well now I am getting another error. Need some help on this

Trigger.

trigger Checkuseractive on User (after update) {

    user u=[select id,Isactive,contactid from user where id=:trigger.new[0].id];
    Id cid=u.ContactId;
if(trigger.new[0].IsActive=='false') 
{
    contactactivecheckboxclass.updatecnt(cid);
}
    
}

Future Method

public class contactactivecheckboxclass {
@future
    public static void Updatecnt(id x)
    contact c=[select Is_user_Active__c from Contact where id=:x];
    c.Is_User_Active__c=false;
    update c;
}

Error : Unexpected token :Contact on class line 4
Instead of using salesforce standardpage I have been using my custom VFpage to save a record. My requirement is to get the VF page back with the selections I have chosen on the page when I click Edit button can someone help on this stuck on this from longtime.
I want to display my VF page with the values I selected on clicking edit can someone guide me how?
I am getting a issue when I am trying to update by Email id on Contact which inturns updates the username on userobject and email on UserObject.Please can some one guide how to overcome this I need to change the ProfileID as well using the trigger.

trigger Trigger12 on Contact (before update) {
    
    System.debug(trigger.new[0].ID);
    
      Contact cnt=[select email from Contact where id=:trigger.new[0].Id];
    system.debug(cnt);
    String emailid=string.valueof(cnt.Email);
    system.debug('The Email id is:' + emailid);
    
    User usr=[select Email,Username from User where ContactId=:trigger.new[0].Id];
    system.debug(usr);
    
    if(trigger.new[0].Email!=cnt.Email)
    {
        usr.Email=trigger.new[0].Email;
    usr.username=trigger.new[0].Email; 
    }
    update usr;
    }