• Abhishek Purohit
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 6
    Replies
 Unable to uninstall package
  Problems        
Component Type             Name                     Problem     
VisualForce Page           UserGuide           Component is in use by another component in your organization. Charket_APIs
trigger ShippingBillingAddress on Account (before insert,before update,after insert,after update) {
 if(Trigger.isBefore)
    {
     if(Trigger.isInsert || Trigger.isUpdate)
          {
            ShippingAddress.shipBillAddress(Trigger.New);
          }
     } 

 
  if(Trigger.isAfter)
   {
      if(Trigger.isInsert)
        {
          ShippingAddress.insertRecord(Trigger.New);
        }
      if(Trigger.isUpdate)
        {
           ShippingAddress.updateField(Trigger.New);
          
        
        
        
        }
    
   }
    
}



This is my Helper Class

public class ShippingAddress{
 public static void shipBillAddress(List<Account> accountObject){
 for(Account account:accountObject){
  account.ShippingStreet=account.BillingStreet;
  account.ShippingCountry=account.BillingCountry;
  account.ShippingCity=account.BillingCity;
  account.ShippingState=account.BillingState;
  } 
 }

 public static void updateField(List<Account> accountObject){
 system.debug('Account List'+accountObject);
     Set<Id> setOfAccountIds=new Set<Id>();
       for(Account account:accountObject)
           {
             setOfAccountIds.add(account.id);
           } 
 
     List<Contact> listOfContact=new List<Contact>([Select Id,AccountId FROM Contact WHERE AccountId IN:setOfAccountIds]);
            List<Contact> listOfUpdatedContact=new List<Contact>();
             
             for(Account accountOfObject:accountObject)
             {
              for(Contact contactOfObject:listOfContact)
               {
                contactOfObject.Phone=accountOfObject.Phone;
             
                listOfUpdatedContact.add(contactOfObject);
               }
             } 
       update listOfUpdatedContact;

 }
 
   public static void insertRecord(List<Account> accountObject){
     List<Contact> contactList=new List<Contact>();
    
    for(Account account:accountObject)
     {
         Contact contactObject = new Contact();
         contactObject.accountId=account.Id;
         contactObject.LastName=account.name;
         contactObject.Phone=account.Phone;
         
         contactList.add(contactObject);
     } 
    insert contactList;
       
   }
}


 
trigger ShippingBillingAddress on Account (before insert,before update,after insert,after update) {
 if(Trigger.isBefore)
    {
    for(Account accountList:Trigger.New)
     {
     if(Trigger.isInsert)
     
      {
     
     accountList.ShippingStreet=accountList.BillingStreet;
     accountList.ShippingCountry=accountList.BillingCountry;
     accountList.ShippingCity=accountList.BillingCity;
     accountList.ShippingState=accountList.BillingState;
     }
    
      if(Trigger.isUpdate)
     { 
      accountList.ShippingStreet=accountList.BillingStreet;
     accountList.ShippingCountry=accountList.BillingCountry;
     accountList.ShippingCity=accountList.BillingCity;
     accountList.ShippingState=accountList.BillingState;
      }
      
      
     }
    
      
       
       
       
    } 

 if(Trigger.IsAfter)
   {
   List<Contact> contactCreate=new List<Contact>();
   for(Account accountList2:Trigger.New)
    {
    if(Trigger.IsInsert)
      {
    Contact contactrecordCreate=new Contact();
      contactrecordCreate.accountId=accountList2.Id;
      contactrecordCreate.LastName=accountList2.Name;
      contactrecordCreate.Phone=accountList2.Phone;
      
      contactCreate.add(contactrecordCreate);
     }
     
  insert contactCreate;
  
  }
  }
  

    

}

 
trigger OpportunityCreator on Account (after insert) {
 
 if(Trigger.isInsert)
 {
   List<Opportunity> oCreate=new List<Opportunity>();
   List<Activity_Plan__c> actplanList=new List<Activity_Plan__c>();
   for(Account acc :Trigger.New)
   {
    
    Opportunity op=new Opportunity();
    Activity_Plan__c apobj =new  Activity_Plan__c();
    
   //op.accountId=acc.Id; 
    op.Name=acc.Name;
    op.CloseDate=Date.today();
    op.StageName='Prospecting';
    apobj.name=acc.Name;
    apobj.Object__c=acc.Name;
   
   oCreate.add(op);  
   actplanList.add(apobj);
 } 
 
 insert oCreate;
 insert actplanList;
  
 }
 

}

 
Situation:
In a case object there are 2 record types namely 'case record' and 'problem ticket'.
The problem ticket's record needs to be associated with the case record's record such that one problem ticket record can have multiple case records of the 'case record type'.Also there needs to be the condition that when a problem ticket record's status is closed it must close all the case record's of 'case record type' associated with it using the flow.How can this be done?
Thank you in advance
There are 2 record types namely 'Case' & 'Problem Ticket'
There needs to be an association of problem ticket to case such that 1 problem ticket will have multiple cases.
When I close the problem ticket the associated cases needs to be closed with it
public class OppControl{
    public string name{get;set;}
    public integer amount{get;set;}
    public string stagename{get;set;}
    public date closedDate{get;set;}
 
    String key;
    List<Opportunity> myop;
    String SearchQuery{get;set;}
    public String getkey(){
    return key;
    }
  public OppControl(){
  myop=[Select Name,Amount,StageName,CloseDate From Opportunity];
  }
    public List<Opportunity> getmyop(){
    return myop;
    }

   public void setkey(String ip){
     key=ip;
   }

   public PageReference search(){
    SearchQuery='Select Name,StageName,Amount,CloseDate From Opportunity where Name like '+'\''+key+'%'+'\''; 
    myop=database.query(SearchQuery);
   return null;
}   
   public PageReference add(){
   return Page.vf4;
   
   
  
  } 
   public PageReference save()
   {
       Opportunity oppObj=new Opportunity();
       oppObj.Name=name;
       oppObj.Amount=amount;
       oppObj.StageName=stagename;
       oppObj.CloseDate=closedDate;

       insert oppObj;
            
       return Page.vf3;
       return null;
   }
   
   public PageReference saveit()
  {
    
  //I want to update the inline function
   return null;
  
  }   
   
   
}

//this is the vf3 page
<apex:page controller="OppControl" sidebar="false" showHeader="false">
 <apex:form >
  <apex:pageBlock mode="inlineEdit" title="Search The Opportunities">
   Name: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<apex:inputText value="{!key}"/>
     <apex:commandButton value="Go" action="{!search}"/>
        <apex:commandButton value="Add Opportunity " action="{!add}"/>
        <apex:commandButton value="Save" action="{!saveit}" />
       <apex:pageBlockTable value="{!myop}" var="my">
       <apex:column ><apex:outputLink value="/{!my.id}">"{!my.Name}"</apex:outputLink></apex:column>
        
         <apex:column value="{!my.StageName}"/>
         <apex:column value="{!my.Amount}"/>
         <apex:column value="{!my.CloseDate}"/>
         
      </apex:pageBlockTable>
  </apex:pageBlock>  
 </apex:form>
</apex:page>


Please help by providing above code with the updation,multiple select and delete operation which will also be effective for the database too!

 
this is vf3 page
<apex:page controller="OppControl">
 <apex:form >
  <apex:pageBlock title="Search The Opportunities">
   Name: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<apex:inputText value="{!key}"/>
     <apex:commandButton value="Go" action="{!search}"/>
        <apex:commandButton value="Add Opportunity " action="{!add}"/>
       <apex:pageBlockTable value="{!myop}" var="my">
       <apex:column ><apex:outputLink value="/{!my.id}">"{!my.Name}"</apex:outputLink></apex:column>
        
         <apex:column value="{!my.StageName}"/>
         <apex:column value="{!my.Amount}"/>
         <apex:column value="{!my.CloseDate}"/>     
      </apex:pageBlockTable>
  </apex:pageBlock>  
 </apex:form>
</apex:page>





This one redirects from the add opportunity button

<apex:page controller="OppControl">
  <apex:form >
  
  <apex:pageBlock title="The New Opportunity">
    <apex:pageBlockSection title="Section One"> 
     <apex:outputText value="Enter The Name"></apex:outputText>
     <apex:inputText />
    </apex:pageBlockSection>
    
    
  <apex:pageBlockSection title="Section Two"> 
     <apex:outputText value="Enter The Amount"></apex:outputText>
     <apex:inputText />
    </apex:pageBlockSection>
  
  <apex:pageBlockSection title="Section Three"> 
     <apex:outputText value="Enter The Stage Name"></apex:outputText>
     <apex:inputText />
    </apex:pageBlockSection>
  
  <apex:pageBlockSection title="Section Four"> 
     <apex:outputText value="Enter The Closed Date"></apex:outputText>
    <apex:inputText />
    
    <apex:commandButton value="Save it" action="{!save}"/>
    </apex:pageBlockSection>
  </apex:pageblock>
  </apex:form>
</apex:page>




This is my Custom Controller

public class OppControl{

    

    String key;
    List<Opportunity> myop;
    String SearchQuery{get;set;}
    public String getkey(){
    return key;
    }
  public OppControl(){
  myop=[Select Name,Amount,StageName,CloseDate From Opportunity];
  }
    public List<Opportunity> getmyop(){
    return myop;
    }

   public void setkey(String ip){
     key=ip;
   }

   public PageReference search(){
    SearchQuery='Select Name,StageName,Amount,CloseDate From Opportunity where Name like '+'\''+key+'%'+'\''; 
    myop=database.query(SearchQuery);
   return null;
}   
   public PageReference add(){
   return Page.vf4;
   
   
  
  } 
   public PageReference save(){
   return Page.vf3;
   }
   
}


Now I want to add the record like for real in the database using this controller and also after it has been saved on that vf4 page should be able to show the name stagename closedate amount on the vf3 page

 
trigger ShippingBillingAddress on Account (before insert,before update,after insert,after update) {
 if(Trigger.isBefore)
    {
    for(Account accountList:Trigger.New)
     {
     if(Trigger.isInsert)
     
      {
     
     accountList.ShippingStreet=accountList.BillingStreet;
     accountList.ShippingCountry=accountList.BillingCountry;
     accountList.ShippingCity=accountList.BillingCity;
     accountList.ShippingState=accountList.BillingState;
     }
    
      if(Trigger.isUpdate)
     { 
      accountList.ShippingStreet=accountList.BillingStreet;
     accountList.ShippingCountry=accountList.BillingCountry;
     accountList.ShippingCity=accountList.BillingCity;
     accountList.ShippingState=accountList.BillingState;
      }
      
      
     }
    
      
       
       
       
    } 

 if(Trigger.IsAfter)
   {
   List<Contact> contactCreate=new List<Contact>();
   for(Account accountList2:Trigger.New)
    {
    if(Trigger.IsInsert)
      {
    Contact contactrecordCreate=new Contact();
      contactrecordCreate.accountId=accountList2.Id;
      contactrecordCreate.LastName=accountList2.Name;
      contactrecordCreate.Phone=accountList2.Phone;
      
      contactCreate.add(contactrecordCreate);
     }
     
  insert contactCreate;
  
  }
  }
  

    

}

 
trigger OpportunityCreator on Account (after insert) {
 
 if(Trigger.isInsert)
 {
   List<Opportunity> oCreate=new List<Opportunity>();
   List<Activity_Plan__c> actplanList=new List<Activity_Plan__c>();
   for(Account acc :Trigger.New)
   {
    
    Opportunity op=new Opportunity();
    Activity_Plan__c apobj =new  Activity_Plan__c();
    
   //op.accountId=acc.Id; 
    op.Name=acc.Name;
    op.CloseDate=Date.today();
    op.StageName='Prospecting';
    apobj.name=acc.Name;
    apobj.Object__c=acc.Name;
   
   oCreate.add(op);  
   actplanList.add(apobj);
 } 
 
 insert oCreate;
 insert actplanList;
  
 }
 

}

 
this is vf3 page
<apex:page controller="OppControl">
 <apex:form >
  <apex:pageBlock title="Search The Opportunities">
   Name: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<apex:inputText value="{!key}"/>
     <apex:commandButton value="Go" action="{!search}"/>
        <apex:commandButton value="Add Opportunity " action="{!add}"/>
       <apex:pageBlockTable value="{!myop}" var="my">
       <apex:column ><apex:outputLink value="/{!my.id}">"{!my.Name}"</apex:outputLink></apex:column>
        
         <apex:column value="{!my.StageName}"/>
         <apex:column value="{!my.Amount}"/>
         <apex:column value="{!my.CloseDate}"/>     
      </apex:pageBlockTable>
  </apex:pageBlock>  
 </apex:form>
</apex:page>





This one redirects from the add opportunity button

<apex:page controller="OppControl">
  <apex:form >
  
  <apex:pageBlock title="The New Opportunity">
    <apex:pageBlockSection title="Section One"> 
     <apex:outputText value="Enter The Name"></apex:outputText>
     <apex:inputText />
    </apex:pageBlockSection>
    
    
  <apex:pageBlockSection title="Section Two"> 
     <apex:outputText value="Enter The Amount"></apex:outputText>
     <apex:inputText />
    </apex:pageBlockSection>
  
  <apex:pageBlockSection title="Section Three"> 
     <apex:outputText value="Enter The Stage Name"></apex:outputText>
     <apex:inputText />
    </apex:pageBlockSection>
  
  <apex:pageBlockSection title="Section Four"> 
     <apex:outputText value="Enter The Closed Date"></apex:outputText>
    <apex:inputText />
    
    <apex:commandButton value="Save it" action="{!save}"/>
    </apex:pageBlockSection>
  </apex:pageblock>
  </apex:form>
</apex:page>




This is my Custom Controller

public class OppControl{

    

    String key;
    List<Opportunity> myop;
    String SearchQuery{get;set;}
    public String getkey(){
    return key;
    }
  public OppControl(){
  myop=[Select Name,Amount,StageName,CloseDate From Opportunity];
  }
    public List<Opportunity> getmyop(){
    return myop;
    }

   public void setkey(String ip){
     key=ip;
   }

   public PageReference search(){
    SearchQuery='Select Name,StageName,Amount,CloseDate From Opportunity where Name like '+'\''+key+'%'+'\''; 
    myop=database.query(SearchQuery);
   return null;
}   
   public PageReference add(){
   return Page.vf4;
   
   
  
  } 
   public PageReference save(){
   return Page.vf3;
   }
   
}


Now I want to add the record like for real in the database using this controller and also after it has been saved on that vf4 page should be able to show the name stagename closedate amount on the vf3 page

 

Hello,

 

I am still very new to APEX.  I am trying to develop a simple visualforce page that lists all the accounts the active user owns.  Ideally, the user should be able to edit and save the records.  When the user clicks save, the record in the database should update.  Currently, the edit and save buttons do not work but I can make changes when double clicking but they do not save.  Any help is greatly appreciated.

 

My code so far:

 

*********************Visualforce page************************

 

<apex:page controller="MyController" >
     
      <apex:form >
     
        <apex:pageBlock title="My Accounts">
       
           
                <apex:pageblocktable value="{!myaccounts}" var="acct">
                    <apex:column value="{! acct.name}"/>
                    <apex:column value="{! acct.Preferred_Mode_S__c}"/>
                    <apex:column value="{! acct.type}"/>
                     <apex:inlineEditSupport event="ondblclick"/>
                  
                </apex:pageblocktable>
                <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandbutton value="Edit" action="{!edit}"/>
        </apex:pageblock>
  </apex:form>
</apex:page>

 

 

*****************************Controller*****************************

 

public class MyController {

         public List<Account> getMyAccounts(){        

List<Account> a = new List<Account>();        

a = [select Id,name,type,preferred_mode_s__c,macro_industry__c,micro_industry__c from Account WHERE (owner.id =: userinfo.getuserid())];            

return a;           

}   

 

public PageReference edit() {        

return null;    

}

    public PageReference save() {        

return null;    

}

}