Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String fName { get;set; }
- public String lName { get;set; }
- public String email { get;set; }
- public String accName { get;set; }
- public Id AccId { get;set;}
- public List<Account> accList { get;set;}
- Public Opportunity currentRecordId { get; set; }
- public addApprenticeDetails_CX(ApexPages.StandardController controller){
- currentRecordId = (Opportunity)controller.getRecord();
- }
- public PageReference callLookup(){
- accList = [Select id,Name from Account];
- PageReference pr = new
- PageReference('/apex/addApprenticeDetailsAccountLookup');
- pr.setRedirect(false);
- return pr;
- }
- public PageReference goBack(){
- accName = ApexPages.currentPage().getParameters().get('AccName');
- AccId = ApexPages.currentPage().getParameters().get('AccId');
- PageReference pr = new PageReference('/apex/addApprenticeDetails');
- pr.setRedirect(false);
- return pr;
- }
- public PageReference save(){
- if(lName == null || lName == ''){
- ApexPages.addmessage(new
- ApexPages.message(ApexPages.severity.WARNING,
- 'Last Name is Required!'));
- return null;
- }
- if(email == null || email == ''){
- ApexPages.addmessage(new
- ApexPages.message(ApexPages.severity.WARNING,
- 'Email is Required!'));
- return null;
- }
- else{
- Contact con = new Contact();
- con.FirstName = fName;
- con.LastName = lName;
- con.Email = email;
- con.AccountId = AccId;
- con.RecordTypeId =
- Schema.SObjectType.Contact.getRecordTypeInfosByName().
- get('Corporate Contact').getRecordTypeId();
- con.Third_Party_Opportunity__c =
- ApexPages.currentPage().getParameters().get('Id');
- insert con;
- PageReference pr = new PageReference('/apex/addApprenticeDetails');
- pr.setRedirect(true);
- return pr;
- }
- }
- public list<Account> accs { get; set; }
- public String searchString { get; set; }
- public addApprenticeDetails_CX(){
- }
- public void search(){
- string searchQuery = 'select name, id from account where name like
- '%'+searchString+'%'Limit 20';
- accs = Database.query(searchQuery);
- }
- public void remove(){
- accs.clear();
- }
- }
- <apex:page standardController="Opportunity"
- extensions="addApprenticeDetails_CX">
- <apex:form >
- <apex:actionFunction name="callAction" action="{!callLookup}"/>
- <apex:pageBlock >
- <apex:pageBlockSection columns="1">
- <apex:pageMessages />
- <apex:inputText label="First Name" value="{!fName}"/>
- <apex:inputText label="Last Name" value="{!lName}"/>
- <apex:inputText label="Email" value="{!email}"/>
- <apex:inputText label="Lookup Account" style="float:left;" value="
- {!accName}">
- <apex:image
- value="https://api.icons8.com/download/
- 19343120d27c16dd3e9d21ad3aa637f94fd4d5fa/Android_L/PNG/256/
- Very_Basic/search-256.png" height="20" onclick="callAction()"/>
- </apex:inputText>
- </apex:pageBlockSection>
- <center>
- <apex:commandButton value="Save" action="{!save}"/>
- </center>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
- <apex:page standardController="Opportunity"
- extensions="addApprenticeDetails_CX" tabStyle="Contact">
- <apex:form >
- <apex:inputText value="{!searchString}" label="Input"/>
- <apex:commandButton value="Search Accounts" action="{!search}"/>
- <apex:commandButton value="Clear Accounts" action="{!remove}"/>
- <apex:pageBlock title="Search Results">
- <apex:pageBlockSection columns="1">
- <apex:repeat value="{!accs}" var="acc">
- <apex:commandLink value="{!acc.Name}" action="{!goBack}">
- <apex:param value="{!acc.Name}" name="AccName"/>
- <apex:param value="{!acc.Id}" name="AccId"/>
- </apex:commandLink>
- </apex:repeat>
- </apex:pageBlockSection>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
Add Comment
Please, Sign In to add comment