if (customAttachmentResult == null || !customAttachmentResult.isSuccess()) { ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not save attachment.')); return null; } else { // update the custom attachment record with some attachment info AccountTeamMember customAttachment = [select id, AccountID, UserID, TeamMemberRole FROM AccountTeamMember where id = :ApexPages.currentPage().getParameters().get('id')];
these may help you
http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html
http://bobbuzzard.blogspot.com/2011/02/layered-visualforce-lookup.html
Public List<Account> acc {get; set;}
Public List<AccountTeamMember> opp {get; set;}
Public String User1 {get; set;}
Public String TeamRole1 {get; set;}
Public String AccountID1 {get; set;}
public AccountTeamMember VED {get;set;}
private Account Account1 {get;set;}
public q1(ApexPages.StandardController controller) {
this.Account1 = (Account)controller.getRecord();
VED = new AccountTeamMember();
VED.AccountID = this.Account1.Id;
system.debug( VED);
}
Private Database.SaveResult saveCustomAttachment()
{
AccountTeamMember obj = new AccountTeamMember();
obj.id = AccountID1;
obj.UserID = User1;
obj.TeamMemberRole = TeamRole1;
system.debug(obj.id);
system.debug(obj.UserID);
return Database.insert(obj);
}
public PageReference processUpload() {
Database.SaveResult customAttachmentResult = saveCustomAttachment();
if (customAttachmentResult == null || !customAttachmentResult.isSuccess()) {
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,
'Could not save attachment.'));
return null;
} else {
// update the custom attachment record with some attachment info
AccountTeamMember customAttachment = [select id, AccountID, UserID, TeamMemberRole FROM AccountTeamMember where id = :ApexPages.currentPage().getParameters().get('id')];
customAttachment.id = this.AccountID1;
customAttachment.UserID = this.User1;
customAttachment.TeamMemberRole = this.TeamRole1;
system.debug(customAttachment.id);
system.debug(customAttachment.UserID);
update customAttachment;
}
return new PageReference('/');
}
public PageReference back() {
return new PageReference('/'+AccountID1);
}
}
class
Vf Page to update account team members
Class
Public Class q1{
Public List<Account> acc {get; set;}
Public List<AccountTeamMember> opp {get; set;}
public AccountTeamMember VED {get;set;}
private Account Account1 {get;set;}
public q1(ApexPages.StandardController controller) {
this.Account1 = (Account)controller.getRecord();
VED = new AccountTeamMember();
VED.AccountID = this.Account1.Id;
}
Public pagereference Save(){
upsert VED;
PageReference pg= new PageReference('/'+Account1.ID);
pg.setRedirect(true);
return pg;
}
}
---------------
Vf Page
<apex:page standardController="Account" extensions="q1">
<apex:sectionHeader title="{!Account.Name}" subtitle="Add Team Member"/>
<apex:form id="form_Upload">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Back to {!Account.Name}"/>
<apex:commandButton action="{!back}" value="Cancel"/>
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="Add Team Member : {!Account.Name}" columns="1">
<apex:pageBlockSectionItem >
User: <apex:inputField id="VED" value="{!VED.UserID}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
Team Role: <apex:inputField id="VED" value="{!VED.TeamMemberRole}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
Case Access Level: <apex:inputField id="VED" value="{!VED.CaseAccessLevel}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
Opportunity Access Level: <apex:inputField id="VED" value="{!VED.OpportunityAccessLevel}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>