• ShawnHepker
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 8
    Replies
Hi All, I had a requirement in which there were two objects ABC and DEF with master detail relation, ABC as master. Both objects hav a checkbox field.Abc has Has_condition__c checkbox whereas Def has Active__c checkbox. NOw I had to write the trigger if anyone of the child record has checkbox=true, then master record must have checkbox true, otherwise false if there is no child record with checkbox=true. I wrote the trigger for this and that is working fine. NOw I have to wite test class for this using fatory data class. Please help me out in this..

trigger hasActiveCheckboxCondition on Def__c (After insert, After update)
{   
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate))
    {
            hasActiveCheckboxDef_Abc t = new hasActiveCheckboxDef_Abc();
            t.insertCondition(trigger.new);
            
    }  
}        
********************************
Apex class:

public class hasActiveCheckboxDef_Abc
{
    public void insertdef(List<def__c> tab1)
    {
        Set<Id> stemp = new Set<Id >();
    for(def__c c : tab1)
    {
        stemp.add(c.abc__c);
    }
    
    //Map<id,List<def__c>> mpDb=new Map<id,List<def__c>>();
    List<abc__c> tabToBeUpdated = new List<abc__c>();
    Map<id, abc__c> mapId = new Map<id,abc__c>();
       
    for(abc__c tab : [select id,Has_Condition__c,(Select id,name,abc__c,Active__c from abcs__r) from abc__c where id IN :stemp])
    {
          
        Boolean flag = false;           
        for(def__c cond : tab.defs__r)
        {
            if(cond.Active__c) {
                flag = true;
                tab.Has_Condition__c = true;
                break;
             }
            
            
        }
        if(flag == false)
        {
          tab.Has_Condition__c = false;  
        }
        mapId.put(tab.id,tab);
           
    }
    if(mapId != null)
    update mapId.values();
    }
}
 
Trigger not getting fired , using an object from managed package.

Trying to update fields in shipper record after insert from the fields of Sales order record.

here is the code, 

trigger UpdateContactInfo on rstk__soship__c (after insert) {
    System.debug('********trigger is called');
    rstk__soship__c[] shipments = Trigger.new;
    rstk__sohdr__c[] orders = null;
    for(rstk__soship__c shipment:shipments){
        orders = [Select    rstk__sohdr_contact__c, rstk__sohdr_conemail__c,rstk__sohdr_conphone__c 
                  from rstk__sohdr__c 
                  where rstk__sohdr_order__c =: shipment.rstk__soship_order__c ];
        
        System.debug('Here in the for loop shipment ordernumber '+shipment.rstk__soship_order__c);
        
        if(orders.size() > 0){
            System.debug('Found the order order name :'+orders[0].rstk__sohdr_contact__c+
                         'email: '+orders[0].rstk__sohdr_conemail__c+
                         'Phone :'+orders[0].rstk__sohdr_conphone__c);
            shipment.rstk__soship_contact__c = orders[0].rstk__sohdr_contact__c;
            shipment.rstk__soship_email__c = orders[0].rstk__sohdr_conemail__c;
            shipment.rstk__soship_phone__c = orders[0].rstk__sohdr_conphone__c;
         }
    }

}

Any suggestion would be very much appreciated. Thanks,
Hi All, I had a requirement in which there were two objects ABC and DEF with master detail relation, ABC as master. Both objects hav a checkbox field.Abc has Has_condition__c checkbox whereas Def has Active__c checkbox. NOw I had to write the trigger if anyone of the child record has checkbox=true, then master record must have checkbox true, otherwise false if there is no child record with checkbox=true. I wrote the trigger for this and that is working fine. NOw I have to wite test class for this using fatory data class. Please help me out in this..

trigger hasActiveCheckboxCondition on Def__c (After insert, After update)
{   
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate))
    {
            hasActiveCheckboxDef_Abc t = new hasActiveCheckboxDef_Abc();
            t.insertCondition(trigger.new);
            
    }  
}        
********************************
Apex class:

public class hasActiveCheckboxDef_Abc
{
    public void insertdef(List<def__c> tab1)
    {
        Set<Id> stemp = new Set<Id >();
    for(def__c c : tab1)
    {
        stemp.add(c.abc__c);
    }
    
    //Map<id,List<def__c>> mpDb=new Map<id,List<def__c>>();
    List<abc__c> tabToBeUpdated = new List<abc__c>();
    Map<id, abc__c> mapId = new Map<id,abc__c>();
       
    for(abc__c tab : [select id,Has_Condition__c,(Select id,name,abc__c,Active__c from abcs__r) from abc__c where id IN :stemp])
    {
          
        Boolean flag = false;           
        for(def__c cond : tab.defs__r)
        {
            if(cond.Active__c) {
                flag = true;
                tab.Has_Condition__c = true;
                break;
             }
            
            
        }
        if(flag == false)
        {
          tab.Has_Condition__c = false;  
        }
        mapId.put(tab.id,tab);
           
    }
    if(mapId != null)
    update mapId.values();
    }
}
 
Hello all,

I have a checkbox field and I want to add a new field derived of date when the checkbox is "marked". 

Thank you for your help.
I have a custom object Review__c and it has MD relationship to contact.
I have checkbox and text field in Review__c object.

Now from VF page I am trying to insert data into custom object fields.

I am having difficulty writing controller class.
 
VF Page:

Have there been any significant changes
<br></br>
<apex:pageblocksection >

            <apex:inputcheckbox value="{!chkBx}" label="Yes"  id="Y" onchange="return confirmDisbaled(this.checked, '{!$Component.N}','{!$Component.cntry}');"> 
                <apex:actionSupport event="onchange" rerender="thePanel" action="{!click}"/>    
            </apex:inputcheckbox> 
           <apex:inputCheckbox label="No" id="N" onchange="return confirmDisbaled(this.checked, '{!$Component.Y}','{!$Component.cntry}');"/>  
            </apex:pageblocksection>

If yes, 
<br></br>
<apex:pageblocksection >
<apex:outputPanel id="thePanel">    
              <apex:pageBlockSectionItem rendered="{!displayInputputText}">
                    <apex:outputLabel value="Input Text" />
                    <apex:inputText value="{!input}"/>  
                </apex:pageBlockSectionItem>
            </apex:outputPanel>
</apex:pageblocksection>




public with sharing class VFTestController { 
     public VFTestController() {

     }  
      
     public Review__c r{get; set;}
     public Review__c setr(Review__c view){
     this.r=view;
     return r;
     }
     public VFTestController(ApexPages.StandardController controller) {
     
     }
     public Id viewid{get;set;}
     Id id = apexpages.currentpage().getparameters().get('id');
 

     public pagereference save(){
     Review__c re  = new Review__c();
     re.Would_you_like_to_receive_a_complimentar__c=r.Would_you_like_to_receive_a_complimentar__c;

     insert re;
     Pagereference pg = new Pagereference('/' + re.id);
     pg.setredirect(true);
     return pg;
     }

    public Boolean displayInputputText{get;set;}
    public Boolean chkBx{get;set;}
    public String input{get;set;}       
    public PageReference click(){    
         if(chkBx){
             displayInputputText = true;
         }
         else {
             displayInputputText = false;
         }
         return null;   
    }

 
public void Save()
    {        
       insert pat;            
        for(wrapperservay wl : wrp)
        {                                                                                    
            Answer__c ua = new Answer__c();       //From here code is not covered.      
            ua.Name = wl.Name;
             ua.Questionn__c = wl.QuestionId;                  
            useranswers.add(ua);
           insert ua;                       
            pat=new Answer__c();                                              
        }


Please help guys from this problem


Thanks in Advance,

Sandeep

APEX Noob here :)

So I found out that I can not use a field of TEXT format when using an EMAIL ALERT. What I did was created a field called "Email" and gave it an EMAIL format. I would like to update this field with the email address based on the name in another field.

Layout:
Case Object: I have a field named: Wealth Planner (This is a lookup field linked on the EMPLOYEES custom object)
Case Object: I have a field named: Email (I would like this field to populate the EMAIL address for Wealth Planner (above) on the EMPLOYEES object)

I just dont know enough APEX to do this yet. Any help????

I hope this make sense.....