• Nirmal9114
  • NEWBIE
  • 25 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 36
    Replies

My Requirement is to Show Description beside the DOCKET picklist value. the description should change as the picklist value changes.The page should dynamically render the description from the selected Docket
Can anyone give me the idea how to do it.

User-added image

Hi,

Please help out. I have i requirement to Display a name if the record is owned by certain group of people.

This Formula is not working. i dont knwo why.

{!IF( ISPICKVAL(Opportunity.GU1__c,'GG' ), 'Global Giving Team', 'US')}

Pleas let me know where i am wroung. OR is there any other way to do it?

Thanks,
 

I have to write a trigger on before insert. i have 2 fields Country__c and GU__c.
my req is to update GU__C accordingly when user inserts Country. The system should automatically assign GU value(s) based on the country value input within a record. An object is created with records containing country__c with its GU__C.
the fields are multi picklist.
Please suggest where i went wrong.

Apex class:

Public class GuUpdate{
   public static void GuUpdation(List<Opportunity> OppList){
        
               //List<Opportunity> opplist1 = [Select id,Project_Location_s__c from Opportunity where Opportunity in :oppList];
        List<GU_Lookup__c> GuList = new List<GU_Lookup__c>();
        
        Set<id> oppid= new Set<id>();
        for(Opportunity opty : OppList){
            if(opty.Impact_Location_GU__c == null){
             oppid.add(opty.Impact_Location_GU__c)
            }
        }
        
        map<id,GU_Lookup__c> mapGuList=new map<id,GU_Lookup__c>([Select Id, Country__c, GU__c from GU_Lookup__c where Id IN: Gulist]);
                              
        for(Opportunity opp: oppid){
            opp = [Select id,Project_Location_s__c, Impact_Location_GU__c from Opportunity where id IN: oppid];
                if(mapGuList.containsKey(opp.Project_Location_s__c)) {
                    GU_Lookup__c Gu = mapGuList.get(opp.Project_Location_s__c); 
                      mapGuList.put(opp.id);
                           
                    if(mapGuList.Country__c == opp.Project_Location_s__c ){
                        opp.Impact_Location_GU__c ==mapGuList.GU__c;
                    }
                } 
          system.debug('opplist'+opplist);      
          update opplist;
         system.debug('opplist'+opplist);
  
        }
    }
}      
        

My requirement is:

Create a button on the Key Staff related list within the Opportunity Record called "Add Key Staff."

When clicked, the button should insert Key Staff records identical to those on the Account, EXCEPT:
- The Account lookup should not be populated
- The Opportunity lookup should be populated with the Opportunity record id:

Please Suggest

My requirement is :
When a Lead is Converted, all Custom Object (Key Staff) records should become associated to the Account, if they are not already (e.g. the Account lookup is unpopulated).

NOTE: The system should not allow duplicate Custom Object(Key Staff members) on an Account during conversion. If a Key Staff record already exists on the Account with the same Contact and Role values, do not update the Key Staff from lead to be associated with the Account

I have written this trigger : PLEASE HELP 


trigger UpdateKeyStaff_Trigger on Lead (after update) {

    for (Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){
            Set<Id> leadIds = new Set<Id>();
            for (Lead lead : Trigger.new) 
                leadIds.add(lead.Id);

            Map<Id, Key_Staff__c> entries = new Map<Id, Key_Staff__c>([select Account__c, Accenture_Resource__c, Board_Member__c, Email__c, Role__c, Lead__c from Key_Staff__c where lead__c in :leadIds]);        
            if(!Trigger.new.isEmpty()) {
                for (Lead lead : Trigger.new)  {
                    for (Key_Staff__c KeyStaff : entries.values()) {
                        if (KeyStaff.Lead__c == lead.Id) {
                            KeyStaff.Accenture_Resource__c = lead.ConvertedContactId;
                            KeyStaff.Grant__c = lead.ConvertedOpportunityId;
                            KeyStaff.Account__c = lead.ConvertedAccountId;
                            update KeyStaff;                            
                        }
                    }
                }
            }
        }
    }

}
My requirement is to update the related list "FGM_Portal__Grantee_Budget_Line_Item__c " Field value from one field to other Only when when opportunity status is LAUNCHED
Please help me in code. i am missing out something.
This is only the class.

APEX CLASS :

public class UpdateOriginalBudget{
List<Id> oppIdlist = [Select id from opportunity where StageName = 'Launched'];
//opplist = [Select id, Name, StageName from opportunity where StageName = 'Launched'];

List<FGM_Portal__Grantee_Budget_Line_Item__c> GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c IN : oppIdlist  ] ;
//GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c : oppList[0].Name ] ;

public void UpdateOriginalBudgetMethod(){

                 if(GbList.size>0)
                 {
                 
                 for(FGM_Portal__Grantee_Budget_Line_Item__c gb : GbList ){
                  gb.Original_Budget__c= gb.FGM_Portal__Amount__c ;
                  }
                 }                           


}
Please Tell me..where is my mistake I not able to attach a file and display it.

VF PAGE :

<apex:page controller="AttachmentUploadController" sidebar="False">  
  <apex:sectionHeader title="Notes And Attachment" subtitle="Attach a File"/>

  <apex:form >
    <apex:pageMessages />
    <apex:pageBlock title="Upload an Attachment">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

       <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!attachment.description}" id="description"/>
        </apex:pageBlockSectionItem>
      </apex:pageBlockSection>

    </apex:pageBlock>
    
    <apex:pageBlock >
    <apex:pageBlockTable value="{!lstAttach}" var="att" >
    
        <apex:column HeaderValue="Name" >
                 <apex:outputField value="{!att.name}" />
        </apex:column>
        
        <apex:column HeaderValue="Description" >
                 <apex:outputField value="{!att.Description}" />
        </apex:column>
        
        <apex:column HeaderValue="Last Modified Date" >
                <apex:outputField value="{!att.LastModifiedDate }" />
       </apex:column>

    </apex:pageBlockTable>
        </apex:pageBlock>
    
  </apex:form>
</apex:page>

CONTROLLER :

public class AttachmentUploadController {

    public String rightObject { get; set; }

    public String listatt { get; set; }

    public String item { get; set; }
    public String AccountTable { get; set; }
    String parentId;
 
    public list<Attachment> lstAttach{ get; set;}
      public Attachment attachment{ get; set;}
      
    public String getAttachmentUploadController() {
        return null;
    }
 
    public AttachmentUploadController() {
    attachment = new Attachment();
    
        User UserId = [Select Id, contactid, contact.accountId from user where id =: UserInfo.getUserId() limit 1];
        Id AccId=UserId.contact.accountId;
        lstAttach = [Select name,description,LastModifiedDate from attachment where OwnerId =: UserInfo.getUserId() and ParentId = : AccId];
    
      }
      
 
    public PageReference upload() {
   Attachment attachment = new Attachment();
   attachment.OwnerId = UserInfo.getUserId();
   attachment.ParentId = parentId; // Account- George P. Artner record id
   attachment.IsPrivate = true;
     try {
      insert attachment;
     
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }

}
My requirement is to Show Portal user their Notes and Attachment only.
How should i do it for the current logged in user.?

My VF PAGE  

<apex:page standardController="Account" extensions="AttachmentUploadController">  
  <apex:sectionHeader title="Visualforce Example" subtitle="Attachment Upload Example"/>

  <apex:form enctype="multipart/form-data">
    <apex:pageMessages />
    <apex:pageBlock title="Upload a Attachment">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

       <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!attachment.description}" id="description"/>
        </apex:pageBlockSectionItem>
      </apex:pageBlockSection>

    </apex:pageBlock>
  </apex:form>
</apex:page>


MY CONTROLLER :

public class AttachmentUploadController {

    public AttachmentUploadController(ApexPages.StandardController controller) {

    }


  public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }
  


  public PageReference upload() {
    
    
   attachment.OwnerId = UserInfo.getUserId();
   attachment.ParentId = '3D0011700000Jns3g'; // Account record id
   attachment.IsPrivate = true;

    try {
      insert attachment;
     
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }

}
i requirement is to clone account with related list.
i am not able to clone related list in this trigger. CAN YOU PLEASE HELP

javascript url :
window.location.href = '/{!Account.Id}/e?clone=1&00N17000000oxkw_ileinner={!Account.Id}';

trigger:

trigger AccountCloning on Account (after insert) {
  
     static Id cloneAccount(Id acctId) 
    { 
       List<Contact> cont = new List<Contact>();
       List<Opportunity> opp = new List<Opportunity>();

       Account acc = [SELECT ID, Name, Organization_Legal_Name__c, FGM_Base__EIN__c, Phone, ShippingAddress, Website, BillingAddress FROM Account WHERE Id = : acctId];
       Account accCopy = acc.clone(false,true);
       accCopy.Name = acc.Name +'-'+system.today();
       insert accCopy;
       
       //cloning Related contact Records
       
       for(Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : acc.Id]){
         Contact conCopy = c.clone(false,true);
         conCopy.AccountId = accCopy.Id;
         cont.add(conCopy);
        }
       insert cont; 
       return accCopy.Id;
   
   
   }
   }
my requirement is to clone an existing account with all the fields as well as related list.
it should open in an edit mode so that user selects to save it or not. (edit mode so that if they want to make any changes)

my trigger :

trigger TestClone on Account (after insert) {
   Account [] accToSave = new Account[]{};
   
   if(checkRecursive.runOnce()){

        // query accounts and store by there name to lookup it up quickly
        Map<Id,Account> accountMap = new Map<Id,Account>([  Select  Id, Name, Description, Phone, Fax  
                                                        From Account 
                                                        Where Id IN: trigger.new]);

        // clone
        for (Account acc : trigger.new){   
            Account Clone = new Account();  
            Clone.Name =  acc.Name;
            Clone.Type =  acc.Type;
            Clone.Phone = acc.Phone;
            Clone.Fax =  acc.Fax;
            Clone.Description =  acc.Description;

            accToSave.add(Clone);
        }

        insert accToSave;

    }
}

class:
public Class checkRecursive{
    private static boolean run = true;
    public static boolean runOnce(){
        if(run){
            run=false;
            return true;
        }else{
            return run;
        }
    }
}

i may be wrong somewhere PLEASE HELP.

thanks
I am having this error "Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.adapters.ApexObjectValueELAdapter "

PLEASE HELP

my controller code is:

global with sharing class AccountClone_Controller {
    private final Id recordId;
    private final Account record;
    private final ApexPages.StandardController controller;

    public AccountClone_Controller(ApexPages.StandardController controller) {
        this.controller = controller;
        this.record = (Account) (this.controller.getRecord());
        this.recordId = this.controller.getId();
    }

    public PageReference cloneAcc() 
    {
        Account newAccount = this.record.clone(false, true, true, false);
        insert newAccount;
  
       // cloning related list contacts
       
       List<Contact> clonedContacts = new List<Contact>();
        for(Contact contact : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : this.recordId])
         {
            Contact clonedContact  = Contact.clone(false, true, true, false);
            clonedContact.AccountId = newAccount.Id;
            clonedContacts.add(clonedContact);
        }

        insert clonedContacts;

        return new ApexPages.StandardController(newAccount).view();
    }
}

VF PAGE :

<apex:page standardController="Account" extensions="AccountClone_Controller" action="{!clone}">
</apex:page>


 
I am facing the error saying "A problem with the OnClick JavaScript for this button or link was encountered''

CLASS:
global class customClone
{
    webservice static void cloneAccount(Id acctId) // you can pass parameters
    { 
       List<Contact> cont = new List<Contact>();
       Account acc = [SELECT ID, Name FROM Account WHERE Id = : acctId];
       Account accCopy = acc.clone(false,true);
       accCopy.Name = acc.Name +'-'+system.today();
       insert accCopy;
       
       //cloning Related contact Records
       
       for(Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : acc.Id]){
         Contact conCopy = c.clone(false,true);
         conCopy.AccountId = accCopy.Id;
         cont.add(conCopy);
        }
       insert cont; 
    }
}

MY JAVASCRIPT CODE for the custom button

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
sforce.apex.execute("customClone","cloneAccount",{acctId:{!Account.Id}}"});




 

I have this requirement. please jus guide me the way to do it.

Create a notification rule for the Account object that notifies the Primary contact of the Account when the Account is unaltered for a years time. 

APEX CLASS

public class  ViewContacts 
{
    public List<contact> acc{get;set;}
    
    public ViewContacts (){
    searchresult();
    }
   
Public void searchresult(){
           SYSTEM.DEBUG('Number of records '); 
    acc = [SELECT Name,lastName,phone,id FROM Contact WHERE name != null LIMIT 999 ];
}


}



VF PAGE

<apex:page standardController="Account" >
<apex:form >
   <apex:pageBlock title="Hello {!$User.FirstName}!">
      You are viewing the account.
   </apex:pageBlock>
   <apex:pageBlock title="Contacts">
      
      <apex:pageBlockTable value="{!acc}" var="con">
              
      <apex:column value="{!con.Name}" />
         <apex:column value="{!con.Email}"/>
         <apex:column value="{!con.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
   </apex:form>
</apex:page>
@isTest
private class NBNAddUserToContact_test {
   
   
    private static testmethod void testUpdate() {
    
        NBNServiceSettings__c cs = new NBNServiceSettings__c();
        cs.name ='CreateUser';
        cs.Value__c ='Y';
        insert cs;
        
         NBNServiceSettings__c cs1 = new NBNServiceSettings__c();
        cs1.name ='CommunityUserEmail';
        cs1.Value__c ='testdummy@nbnco.com.au';
        insert cs1;
        
        user us = new user();
        us.LastName = 'tesst';
        us.FirstName = 'test272';
        us.LocaleSidKey = 'en_AU';
        us.TimeZoneSidKey = 'Australia/Sydney';
        us.ProfileID = '00e1a000000o1Vl';
        us.LanguageLocaleKey = 'en_US';
        us.EmailEncodingKey = 'ISO-8859-1';
        us.Email = 'nbn@nbnco.co.ac';
        us.Username = 'test22@gmail.com.nbndev01';
        us.WD_EmployeeNumber__c = '1232356223';
        us.Alias = 'tyre';
        us.CommunityNickname = 'test uuu';
        insert us;
        
        us.LastName = 'tess0t';
        update us;

    }
  private static testmethod void testInsert() {
        
     
        
       
        
        NBNServiceSettings__c cs21 = new NBNServiceSettings__c();
        cs21.name ='CreateUser';
        cs21.Value__c ='Y';
        insert cs21;
        
          NBNServiceSettings__c cs11 = new NBNServiceSettings__c();
        cs11.name ='CommunityUserEmail';
        cs11.Value__c ='testdummy@nbnco.com.au';
        insert cs11;
        
        account acct1 = new account(Name = 'NBNInc');
        
        contact con = new contact ();
        con.Contact_Source__c = 'WDSFDCIntegration';
        con.LastName = 'test';
        con.FirstName = 'test22';
        con.Accountid = acct1.id;
        con.email = 'nbn@nbnco.co.ac';
        con.Username__c = 'test@gmail.com';
        con.WDEmployeeNumber__c = '123232356223';
        con.WD_Employee_Type__c = 'Employee';
        con.Worker_Status__c = True;
        con.Nickname__c = 'test test22 tyre';
        con.Phone = '98959895';
        insert con;
              
    }
    
       private static testmethod void testInsertInactiveUser() {
        
       
        NBNServiceSettings__c cs3 = new NBNServiceSettings__c();
        cs3.name ='CreateUser';
        cs3.Value__c ='Y';
        insert cs3;
        
        NBNServiceSettings__c cs31 = new NBNServiceSettings__c();
        cs31.name ='CommunityUserEmail';
        cs31.Value__c ='testdummy@nbnco.com.au';
        insert cs31;
        account acctn = new account(Name = 'NBNInc');
        
        contact conInactive = new contact ();
        conInactive.Contact_Source__c = 'WDSFDCIntegration';
        conInactive.LastName = 'test';
        conInactive.FirstName = 'test22';
        conInactive.Accountid = acctn.id;
        conInactive.email = 'nbn@nbnco.co.ac';
        conInactive.Username__c = 'test@gmail.com';
        conInactive.WDEmployeeNumber__c = '1232356223';
        conInactive.WD_Employee_Type__c = 'Employee';
        conInactive.Worker_Status__c = False;
        conInactive.Nickname__c = 'test test22';
        conInactive.Phone = '98959895';
        insert conInactive;
   
    }

      
}

My Requirement is to Show Description beside the DOCKET picklist value. the description should change as the picklist value changes.The page should dynamically render the description from the selected Docket
Can anyone give me the idea how to do it.

User-added image

Hi,

Please help out. I have i requirement to Display a name if the record is owned by certain group of people.

This Formula is not working. i dont knwo why.

{!IF( ISPICKVAL(Opportunity.GU1__c,'GG' ), 'Global Giving Team', 'US')}

Pleas let me know where i am wroung. OR is there any other way to do it?

Thanks,
 

My requirement is:

Create a button on the Key Staff related list within the Opportunity Record called "Add Key Staff."

When clicked, the button should insert Key Staff records identical to those on the Account, EXCEPT:
- The Account lookup should not be populated
- The Opportunity lookup should be populated with the Opportunity record id:

Please Suggest

My requirement is to update the related list "FGM_Portal__Grantee_Budget_Line_Item__c " Field value from one field to other Only when when opportunity status is LAUNCHED
Please help me in code. i am missing out something.
This is only the class.

APEX CLASS :

public class UpdateOriginalBudget{
List<Id> oppIdlist = [Select id from opportunity where StageName = 'Launched'];
//opplist = [Select id, Name, StageName from opportunity where StageName = 'Launched'];

List<FGM_Portal__Grantee_Budget_Line_Item__c> GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c IN : oppIdlist  ] ;
//GbList = [Select Id,Original_Budget__c,FGM_Portal__Amount__c,FGM_Portal__Opportunity__c from FGM_Portal__Grantee_Budget_Line_Item__c where FGM_Portal__Opportunity__c : oppList[0].Name ] ;

public void UpdateOriginalBudgetMethod(){

                 if(GbList.size>0)
                 {
                 
                 for(FGM_Portal__Grantee_Budget_Line_Item__c gb : GbList ){
                  gb.Original_Budget__c= gb.FGM_Portal__Amount__c ;
                  }
                 }                           


}
Please Tell me..where is my mistake I not able to attach a file and display it.

VF PAGE :

<apex:page controller="AttachmentUploadController" sidebar="False">  
  <apex:sectionHeader title="Notes And Attachment" subtitle="Attach a File"/>

  <apex:form >
    <apex:pageMessages />
    <apex:pageBlock title="Upload an Attachment">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

       <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!attachment.description}" id="description"/>
        </apex:pageBlockSectionItem>
      </apex:pageBlockSection>

    </apex:pageBlock>
    
    <apex:pageBlock >
    <apex:pageBlockTable value="{!lstAttach}" var="att" >
    
        <apex:column HeaderValue="Name" >
                 <apex:outputField value="{!att.name}" />
        </apex:column>
        
        <apex:column HeaderValue="Description" >
                 <apex:outputField value="{!att.Description}" />
        </apex:column>
        
        <apex:column HeaderValue="Last Modified Date" >
                <apex:outputField value="{!att.LastModifiedDate }" />
       </apex:column>

    </apex:pageBlockTable>
        </apex:pageBlock>
    
  </apex:form>
</apex:page>

CONTROLLER :

public class AttachmentUploadController {

    public String rightObject { get; set; }

    public String listatt { get; set; }

    public String item { get; set; }
    public String AccountTable { get; set; }
    String parentId;
 
    public list<Attachment> lstAttach{ get; set;}
      public Attachment attachment{ get; set;}
      
    public String getAttachmentUploadController() {
        return null;
    }
 
    public AttachmentUploadController() {
    attachment = new Attachment();
    
        User UserId = [Select Id, contactid, contact.accountId from user where id =: UserInfo.getUserId() limit 1];
        Id AccId=UserId.contact.accountId;
        lstAttach = [Select name,description,LastModifiedDate from attachment where OwnerId =: UserInfo.getUserId() and ParentId = : AccId];
    
      }
      
 
    public PageReference upload() {
   Attachment attachment = new Attachment();
   attachment.OwnerId = UserInfo.getUserId();
   attachment.ParentId = parentId; // Account- George P. Artner record id
   attachment.IsPrivate = true;
     try {
      insert attachment;
     
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }

}
My requirement is to Show Portal user their Notes and Attachment only.
How should i do it for the current logged in user.?

My VF PAGE  

<apex:page standardController="Account" extensions="AttachmentUploadController">  
  <apex:sectionHeader title="Visualforce Example" subtitle="Attachment Upload Example"/>

  <apex:form enctype="multipart/form-data">
    <apex:pageMessages />
    <apex:pageBlock title="Upload a Attachment">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

       <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!attachment.description}" id="description"/>
        </apex:pageBlockSectionItem>
      </apex:pageBlockSection>

    </apex:pageBlock>
  </apex:form>
</apex:page>


MY CONTROLLER :

public class AttachmentUploadController {

    public AttachmentUploadController(ApexPages.StandardController controller) {

    }


  public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }
  


  public PageReference upload() {
    
    
   attachment.OwnerId = UserInfo.getUserId();
   attachment.ParentId = '3D0011700000Jns3g'; // Account record id
   attachment.IsPrivate = true;

    try {
      insert attachment;
     
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }

}
i requirement is to clone account with related list.
i am not able to clone related list in this trigger. CAN YOU PLEASE HELP

javascript url :
window.location.href = '/{!Account.Id}/e?clone=1&00N17000000oxkw_ileinner={!Account.Id}';

trigger:

trigger AccountCloning on Account (after insert) {
  
     static Id cloneAccount(Id acctId) 
    { 
       List<Contact> cont = new List<Contact>();
       List<Opportunity> opp = new List<Opportunity>();

       Account acc = [SELECT ID, Name, Organization_Legal_Name__c, FGM_Base__EIN__c, Phone, ShippingAddress, Website, BillingAddress FROM Account WHERE Id = : acctId];
       Account accCopy = acc.clone(false,true);
       accCopy.Name = acc.Name +'-'+system.today();
       insert accCopy;
       
       //cloning Related contact Records
       
       for(Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : acc.Id]){
         Contact conCopy = c.clone(false,true);
         conCopy.AccountId = accCopy.Id;
         cont.add(conCopy);
        }
       insert cont; 
       return accCopy.Id;
   
   
   }
   }
I am having this error "Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.adapters.ApexObjectValueELAdapter "

PLEASE HELP

my controller code is:

global with sharing class AccountClone_Controller {
    private final Id recordId;
    private final Account record;
    private final ApexPages.StandardController controller;

    public AccountClone_Controller(ApexPages.StandardController controller) {
        this.controller = controller;
        this.record = (Account) (this.controller.getRecord());
        this.recordId = this.controller.getId();
    }

    public PageReference cloneAcc() 
    {
        Account newAccount = this.record.clone(false, true, true, false);
        insert newAccount;
  
       // cloning related list contacts
       
       List<Contact> clonedContacts = new List<Contact>();
        for(Contact contact : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : this.recordId])
         {
            Contact clonedContact  = Contact.clone(false, true, true, false);
            clonedContact.AccountId = newAccount.Id;
            clonedContacts.add(clonedContact);
        }

        insert clonedContacts;

        return new ApexPages.StandardController(newAccount).view();
    }
}

VF PAGE :

<apex:page standardController="Account" extensions="AccountClone_Controller" action="{!clone}">
</apex:page>


 
I am facing the error saying "A problem with the OnClick JavaScript for this button or link was encountered''

CLASS:
global class customClone
{
    webservice static void cloneAccount(Id acctId) // you can pass parameters
    { 
       List<Contact> cont = new List<Contact>();
       Account acc = [SELECT ID, Name FROM Account WHERE Id = : acctId];
       Account accCopy = acc.clone(false,true);
       accCopy.Name = acc.Name +'-'+system.today();
       insert accCopy;
       
       //cloning Related contact Records
       
       for(Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : acc.Id]){
         Contact conCopy = c.clone(false,true);
         conCopy.AccountId = accCopy.Id;
         cont.add(conCopy);
        }
       insert cont; 
    }
}

MY JAVASCRIPT CODE for the custom button

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
sforce.apex.execute("customClone","cloneAccount",{acctId:{!Account.Id}}"});




 

I am new to development of visualforce page so I copied and paste the code from salesforce site but it showing an error when I am trying to create a tab:panel

Error: <apex:page> is required and must be the outermost tag in the markup at line 1 column.