• Developer.mikie.Apex.Student
  • SMARTIE
  • 764 Points
  • Member since 2013
  • Destiny

  • Chatter
    Feed
  • 9
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 178
    Questions
  • 552
    Replies
Hi 

We have custom Participant object and custom timezone field(pick list - cetral , eastern arizona and pacific ). for each particiipat , particiipant address (state and zip code) is stored in child object called participantdetail. 
when new participnat is created , how do i populate the time zone  field with thier timezone ( i have  the zip code in address  and is it possible to populate the timezone field using the zip code  ) or any other way.  . 
Hi All,
I am looking to integrate 2 Salesforce Orgs using rest API - I am completely new to coding and apex - I have managed to integrate org 1 and org 2 for the account object but I now want to do the same for opportunity. Below is the code I have used for the account object which works - when creating an account in 1 org it automatically creates in org 2. How do i do the same for Opportunity?

APEX CLASS

public class SendAccount {
private final String clientId = '********';
private final String clientSecret = '****';
private final String username = '***';
private final String password = '*****';
public class deserializeResponse
{
public String id;
public String access_token;
}
public String ReturnAccessToken (SendAccount acount)
{
String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setBody(reqbody);
req.setMethod('POST');
req.setEndpoint('https://*****/services/oauth2/token');
HttpResponse res = h.send(req);
deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
return resp1.access_token;
}
@future(callout=true)
public static void createAccount(String accName, String accPhone, String accWebsite, String accType, String accIndustry, String accSource, String accDescription, String accNotes, String accAddress, String accId)
{
SendAccount acount = new SendAccount();
String accessToken = acount.ReturnAccessToken (acount);
if(accessToken != null)
{
String endPoint = 'https://********/services/data/v32.0/sobjects/Account/';
String jsonstr = '{"Name" : "' + accName + '","Phone" : "' + accPhone + '","Website" : "' + accWebsite + '","Type" : "' + accType + '","Industry" : "' + accIndustry + '","Source__c" : "' + accSource + '","Description__c" : "' + accDescription + '","Notes__c" : "' + accNotes + '","Address__c" : "' + accAddress + '"}';
Http h2 = new Http();
HttpRequest req1 = new HttpRequest();
req1.setHeader('Authorization','Bearer ' + accessToken);
req1.setHeader('Content-Type','application/json');
req1.setHeader('accept','application/json');
req1.setBody(jsonstr);
req1.setMethod('POST');
req1.setEndpoint(endPoint);
HttpResponse res1 = h2.send(req1);
deserializeResponse resp2 = (deserializeResponse)JSON.deserialize(res1.getbody(),deserializeResponse.class);
Account a = [SELECT Phone, Website, Type, Industry, Source__c, Description__c, Notes__c, Address__c, Id FROM Account WHERE Id = :accId];
a.externalid__c = resp2.id;
update a;
}
}
}


APEX TRIGGER

trigger SendAccount on Account (after insert) {
for(Account a:Trigger.new){
SendAccount.createAccount(a.name, a.Phone, a.Website, a.Type, a.Industry, a.Source__c, a.Description__c, a.Notes__c, a.Address__c, a.Id);
}
}
 
Hello All,

I'm new to Salesforce Apex coding and undergoing some training and classes in Apex. I noticed that we cannot give any condition in List FOR loop. For example, lets say I've a list of 1000 Contacts in myContactList. I need to loop myContactList for one particular account instead of running all the records one by one and check inside the loop if the account name is what am expecting. I've seen we can use SOQL for this. But my question is can we not use the local list variable to have filter and loop only the records which I want to?

Something similar to below code for reference:
for (Contacts myContact : myContactList.Where(Account.Name = 'Acme')){

}

Let me know if there are any way I can achieve this using myContactList instead of having SOQL call.

Thanks.

Regards,
Mohan Babu
This is my first Apex Trigger and I realize it will make most of you cringe your teeth!  It is a simple trigger that will update the lead 'status' field to 'contacted' when the following criteria are met:

1- its 'lead rating' is either D1,D2,D3, or D4
2- the current lead 'status' is "open"
3- the lead has a related task containing "Message Sent:" in the subject 

Can anyone please help me bulkify this?  




trigger dleadstatus on Lead (before insert, before update) {



    for (Lead l : Trigger.new) {
    if((l.Eloqua_Lead_Rating__c =='D1' || l.Eloqua_Lead_Rating__c =='D2'|| l.Eloqua_Lead_Rating__c =='D3'|| l.Eloqua_Lead_Rating__c =='D4')&& l.Status =='Open') {
    List<Task> sentemails = [SELECT Id FROM Task WHERE Subject LIKE '%Message Sent:%'];
    
    if(sentemails.size() > 0) {
    l.Status = 'Contacted';}
    else {l.Status = 'Open';}}}

}
I've read the documentation, but I wasn't entirely clear on a few things with "Sharing Sets" in Communities

1) Do they only apply to High Volume Portal Users, or all Communities users with the right Profile
2) If somebody is granted access to a record via a Sharing Set and then go to a VF Page with a "With Sharing" controller, will that Sharing Set be taken into account?

It seems like a major difference between Community and Community Plus licences in the documentation is that plus licences respect Sharing. However, Sharing Sets seem to then someway negate that advantage, if you can use them with standard Community licences and apex "with sharing".

Does anybody happen to know the details on this? Thanks!

Hi Guys,

I cant figure out how to pass my integration class. Please help, any help would be much appreciated.

 

public class Integration {

    // The ExternalOrder class holds a string and integer
    // received from the external fulfillment system.

    public class ExternalOrder {
        public String id {
            get;
            set;
        }
        public String result {
            get;
            set;
        }
    }

    //  Functionally, the method 1) prepares
    // JSON-formatted data to send to the remote service, 2) makes an HTTP call
    // to send the prepared data to the remote service, and then 3) processes
    // any JSON-formatted data returned by the remote service to update the
    // local Invoices with the corresponding external IDs in the remote system.

    @future(callout = true) // indicates that this is an asynchronous call
    public static void postOrder(List < Id > AccountIds, boolean isScheduleExpiry) {

        //Call Accounts associated to Id List
        List < Account > Accounts = [SELECT Id, DestinyLive_Email_Username__c, Support_Expiration__c, Receiving_Support__c, DestinyLive_Premium_Membership_Expiry__c FROM Account WHERE Id IN: AccountIds];
        
        // Create a JSON generator object
        JSONGenerator gen = JSON.createGenerator(true);
        // open the JSON generator
        gen.writeStartArray();
        // iterate through the list of invoices passed in to the call
        // writing each Account ID to the array
        for (Account Acc: Accounts) {
        Datetime ExpiryDate = Acc.DestinyLive_Premium_Membership_Expiry__c;
        String myDatetimeStr = ExpiryDate.format('dd/MM/YYYY');
            gen.writeStartObject();
            gen.writeStringField('id', Acc.Id);
            if(Acc.DestinyLive_Email_Username__c != null && Acc.DestinyLive_Email_Username__c != ''){
            gen.writeStringField('DestinyLive_UserName', Acc.DestinyLive_Email_Username__c);
            }else{
            gen.writeStringField('DestinyLive_UserName', 'NA');
            }
            
            //Set Destiny Client to false as isScheduleExpiry == true because the class is scheduled to run 15 minutes before expiry
            if(isScheduleExpiry == true){
            gen.writeBooleanField('DestinyClient', false);
            }else{
            gen.writeBooleanField('DestinyClient', Acc.Receiving_Support__c);
            }
            gen.writeStringField('Expiry', myDatetimeStr);
            gen.writeEndObject();
        }
        // close the JSON generator
        gen.writeEndArray();
        // create a string from the JSON generator
        String jsonOrders = gen.getAsString();
        // debugging call, which you can check in debug logs
        System.debug('jsonOrders: ' + jsonOrders);

        // create an HTTPrequest object    
        HttpRequest req = new HttpRequest();
        // set up the HTTP request with a method, endpoint, header, and body
        req.setMethod('POST');
        // DON'T FORGET TO UPDATE THE FOLLOWING LINE WITH YOUR APP NAME
        req.setEndpoint('http://requestb.in/1n6j75u1');
        req.setHeader('Content-Type', 'application/json');
        req.setBody(jsonOrders);
        // create a new HTTP object
        Http http = new Http();
        // create a new HTTP response for receiving the remote response
        // then use it to send the configured HTTPrequest
        HTTPResponse res = http.send(req);
        // debugging call, which you can check in debug logs
        System.debug('Fulfillment service returned ' + res.getBody());

        // 3) see above

        // Examine the status code from the HTTPResponse
        // If status code != 200, write debugging information, done
        if (res.getStatusCode() != 200) {
            System.debug('Error from ' + req.getEndpoint() + ' : ' + res.getStatusCode() + ' ' + res.getStatus());
        }
        // If status code = 200, update each Account
        // with the external ID returned by the fulfillment service.
        else {

            // Create a list of external orders by deserializing the
            // JSON data returned by the fulfillment service.
            List < ExternalOrder > orders = (List < ExternalOrder > ) JSON.deserialize(res.getBody(),
            List < ExternalOrder > .class);
            // Create a map of Invoice IDs from the retrieved
            Map < Id, Account > AccMap = new Map < Id, Account > (Accounts);
            // Update the order numbers in the invoices
            for (ExternalOrder order: orders) {
            
            if(order.result == 'Success'){
                Account Acc = AccMap.get(order.id);
                Acc.DestinyLive_Premium_Membership__c= False;
                Acc.DestinyLive_Integration_Status__c = 'Completed - Success';
            }else if(order.result == 'NA'){
                
                Account Acc = AccMap.get(order.id);
                Acc.DestinyLive_Premium_Membership__c= true;
                Acc.DestinyLive_Integration_Status__c = 'Completed - User Not Found';
            }else if(order.result == 'Failure'){
                Account Acc = AccMap.get(order.id);
                Acc.DestinyLive_Premium_Membership__c= true;
                Acc.DestinyLive_Integration_Status__c = 'Completed - Failure';
           }
            }

            update Accounts;
        }
    }
}

current test 
 
@isTest 
private class Integration_Test{
    static testMethod void IntegrationTest() {
    
  List<Id> AccountIds = new List<Id>();           

  List<Account> AccountList = new List<Account>{};
for(Integer i = 0; i < 200; i++){
        Account Accs = new Account( Name = 'Test' + i, DestinyLive_Premium_Membership_Expiry__c = date.today().adddays(40), DestinyLive_Email_Username__c = 'Success22@knmfld.fdfdf', Receiving_Support__c = true, Support_Expiration__c = date.today().adddays(40), Support_Start__c = date.today().adddays(-40));
        AccountList.add(Accs);
    }
    
   insert AccountList;
    
    
    for ( Account Acc : AccountList) {
    AccountIds.add(Acc.Id);
    }
  
    Test.startTest();
     If(!Test.isRunningTest()){
    Integration.postOrder(AccountIds, True);
    }
    Test.stopTest();


}

}

 
I am attempting to center the contents of an outputfield which I am placing into a datatable's column. I can't find an attribute for the datatable which can do this. The closest I can find is an attribute which will center the datatable itself, but I don't want that. 

Here is an example of the code : 
 
<apex:dataTable value="{!Vendor_Product_Review__c}" var="pitem" border="4"  align="left" cellpadding="10" rowClasses="rowWithBorder"> 
                          
                            
                      <apex:column headerValue="" >
                                 <apex:outputLabel >Credit   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Liquidity   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Transaction   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Foreign Exchange   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Interest Rate   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Reputation   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Operational   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Price   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Compliance   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Strategic   </apex:outputLabel><br></br>
                                 <apex:outputLabel >Financial  </apex:outputLabel><br></br>
                                 <apex:outputLabel >Other   </apex:outputLabel><br></br>
                             </apex:column>
                         
                             <apex:column headerValue="Probability" >
                                 <apex:outputfield value="{!pitem.CreditRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.LiquidityRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.TransactionRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.ForeignExchangeRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.InterestRateRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.ReputationRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.OperationalRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.PriceRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.ComplianceRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.StrategicRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.FinancialRiskProbability__c}"/><br></br>
                                 <apex:outputfield value="{!pitem.OtherRiskProbability__c}"/><br></br>
                             </apex:column>

I would like the outputlabels to be centered within their column as well. 

Anybody got an idea on this ? 

Thank you.
 
Hi there,

I have a wrapper class and I am trying to test it. I need 100% as my other code coverage isa  bit lacking, but only have 73%. I am not sure if I have even set this out properly and I dont know how to test for the wrapper parts of my controller. E.G. FinLoanWrapper, any help would be muich appreciated.

Test
@isTest 
private class FinanceNew_Test{
    static testMethod void FinanceCommissionNew() {
    
     PageReference pageRef = Page.DestinyFinanceNew4;
        Test.setCurrentPage(pageRef);
    
    Office__c Office = new Office__c(Name = 'Test Pro Account');
insert Office;
Account Acc = new Account(Name = 'Test Account', office__c = Office.id);
insert Acc;
Finance__c Fin = new Finance__c(Finance_Office__c = office.id, Account__c = Acc.id);
insert Fin;
List<Finance_Loan_Security__c> FLSEC = new List<Finance_Loan_Security__c>{};
for(Integer i = 0; i < 10; i++){
        Finance_Loan_Security__c FLSE = new Finance_Loan_Security__c(Office__c = Office.id, Account__c = acc.id, No_Street__c = 'Test' + i, Finance__c = Fin.id);
        FLSEC.add(FLSE);
    }
List<Finance_Loan_Split__c> FLSPL = new List<Finance_Loan_Split__c>{};
for(Integer i = 0; i < 10; i++){
        Finance_Loan_Split__c FLS = new Finance_Loan_Split__c(Office__c = Office.id, Account__c = acc.id, Account_Number__c = 'Test' + i, Finance__c = Fin.id);
        FLSPL.add(FLS);
    }
    insert FLSPL;
    Insert FLSEC;
    
    ApexPages.currentPage().getParameters().put('FinId', Fin.id);
     ApexPages.currentPage().getParameters().put('OffId', Office.id);
      ApexPages.currentPage().getParameters().put('AccId', Acc.id);


       //this call tests the constructor:
       FinanceNew controller = new FinanceNew();
       
      
       //test building was complete
        System.assert(controller.wrappers.size()==10);
         System.assert(controller.wrappers2.size()==10);
        
        
        //call the pageReference in the class.
        controller.FinLoanCalculate();
        controller.FinSecCalculate();
        System.assert(Fin.Aggregate_Borrowings__c ==0.00);
        
        controller.addRows();
        controller.delWrapper();
        controller.addRows2();
        controller.delWrapper2();
        
        controller.saveStandard();
        controller.Cancel();



    }
}



Class
public class FinanceNew{
    
    public Finance__c Fin { get; set; }
    public Finance_Loan_Security__c LoanSecurity { get; set; }
    public Finance_Loan_Split__c LoanSplit { get; set; }
    
    
    //Wrapper multi add try to implement
     public List<FinLoanSplitWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
 
 //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 1
       public List<FinLoanSecurityWrapper> wrappers2 {get; set;}
 public static Integer toDelIdent2 {get; set;}
 public static Integer addCount2 {get; set;}
 private Integer nextIdent2=0;
 
 //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Wrapper 2 identical - 1
  Id FinId = ApexPages.currentPage().getParameters().get('FinId');
   public string delId {get;set;}
 ////////////////test
 

 
 public void FinLoanCalculate()
{
nextIdent=-1;
Integer NoSplits = 0;
Decimal AggBorrowing = 0.00;
  for (FinLoanSplitWrapper wrap : wrappers)
  {
  if(wrap.FinLoanS.Loan_Amount__c == null){
  wrap.FinLoanS.Loan_Amount__c = 0.00;
  }
  AggBorrowing = AggBorrowing + wrap.FinLoanS.Loan_Amount__c;
  NoSplits = NoSplits + 1;
  nextIdent = nextIdent + 1;
  wrap.ident = nextIdent;
  }
  Fin.Number_of_Splits__c = NoSplits;
  Fin.Aggregate_Borrowings__c = AggBorrowing;


}

 public void FinSecCalculate()
{
nextIdent2=-1;
Integer NoSecurities = 0;
Decimal ValTotal = 0.00;
  for (FinLoanSecurityWrapper wrap : wrappers2)
  {
  if(wrap.FinSecS.Actual_Value__c== null){
  wrap.FinSecS.Actual_Value__c= 0.00;
  }
  ValTotal = ValTotal  + wrap.FinSecS.Actual_Value__c;
  NoSecurities = NoSecurities + 1;
  nextIdent2 = nextIdent2 + 1;
  wrap.ident2 = nextIdent2;
  }
  Fin.Number_of_Securities__c = NoSecurities;
   Fin.total_security_Value__c= ValTotal;
}



 ////////////////test









////////////////////Delete Rows
//Delete Rows 1 
public void delWrapper()
 {
  Integer toDelPos=-1;
  boolean IsInsertedRow = False;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
    if (wrappers[idx].IsInserted==true){
    IsInsertedRow = true;
    }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
  if(delId != null && IsInsertedRow == True){
  
  Finance_Loan_Split__c[] FLS = [select id from Finance_Loan_Split__c where id =: delId ];
    if(FLS.size() > 0){
  
  delete FLS[0];
  
  }
  }
  delId = null;
  IsInsertedRow = false;
  
 }



//Delete Rows 2
  public void delWrapper2()
 {
  boolean IsInsertedRow = False;
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers2.size(); idx++)
  {
   if (wrappers2[idx].ident2==toDelIdent2)
   {
    toDelPos=idx;
   }
    if (wrappers2[idx].IsInserted==true){
    IsInsertedRow = true;
    }
  }
   
  if (-1!=toDelPos)
  {
   wrappers2.remove(toDelPos);
  }
  if(delId != null && IsInsertedRow == True){
   Finance_Loan_Security__c[] FLSE = [select id from Finance_Loan_Security__c where id =: delId ];
         if(FLSE.size() > 0){
  
  delete FLSE[0];
  
  }
  }
 }







 //////////////////////////Add Rows
 //Add Rows 1
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new FinLoanSplitWrapper(integer.valueof(Fin.Number_of_Splits__c), null));
  }
 }
//Add Rows 2
 public void addRows2()
 {
  for (Integer idx=0; idx<addCount2; idx++)
  {
   wrappers2.add(new FinLoanSecurityWrapper(integer.valueof(Fin.Number_of_Securities__c),null));
  }
 }
  //////////////////////////Add Rows
 
 

 
 
 ////////////////Wrappers
 public class FinLoanSplitWrapper
 {
  public Finance_Loan_Split__c FinLoanS {get; private set;}
  public Integer ident {get; private set;}
  public boolean IsInserted  {get; set;}
   
  public FinLoanSplitWrapper(Integer inIdent , Finance_Loan_Split__c LoanSplit)
  {
  ident=inident;
 if(LoanSplit != null){
   FinLoans = LoanSplit; 
   IsInserted = true;    
   }else{
   FinLoanS=new Finance_Loan_Split__c(Loan_Split_Number__c=ident);
   IsInserted = false;
   }
  }
 }
  
 public class FinLoanSecurityWrapper
 {
  public Finance_Loan_Security__c FinSecS {get; private set;}
  public Integer ident2 {get; private set;}
  public boolean IsInserted  {get; set;}
   
  public FinLoanSecurityWrapper(Integer inIdent, Finance_Loan_Security__c LoanSecurity )
  {
   ident2=inIdent;
 if(LoanSecurity != null){
     FinSecS = LoanSecurity;
     IsInserted = true;  
     }else{
   FinSecS=new Finance_Loan_Security__c(Loan_Security_Number__c=ident2);
   IsInserted = false;
   }
   
   
  }
 }
  

 public FinanceNew() {
     
     Id FinId = ApexPages.currentPage().getParameters().get('FinId');
     if(FinId != null){
     Fin = [SELECT Id, Application_End_Reason__c, Financier__c, Financier_Reference__c, Application_LVR__c ,
     Total_Security_Value__c, Loan_Information__c , Account__c , Finance_Office__c, Settlement_Due__c, Finance_Clause__c, Number_of_Securities__c,Number_of_Splits__c ,
     Aggregate_Borrowings__c, Total_New_Loans__c, Application_Completed__c ,Application_Submitted__c,Conditional_Approval__c,Valuation_Completed__c,
     Unconditional_Approval__c ,Finance_Documents_Issued__c,Finance_Documents_Executed__c ,Finance_Documents_Submitted__c ,Finance_Certified__c , Finance_Settlement__c ,
     Application_End__c,Upfront_Commission_Paid__c       FROM Finance__c
                   WHERE Id = :ApexPages.currentPage().getParameters().get('FinId') ];
                
 if(wrappers == null) { 
     
      wrappers=new List<FinLoanSplitWrapper>();
      for(Finance_Loan_Split__c LoanSplit:[SELECT Id, Account__c ,Office__c, Loan_Split_Number__c, Loan_Amount__c ,Loan_Type__c,Payment_Type__c,
      Loan_Purpose__c,Comment__c, finance__c, Secondary_Purpose__c, Account_Number__c  FROM Finance_Loan_Split__c
                   WHERE finance__c  = :FinId order by Loan_Split_Number__c asc]){
                   
                   nextIdent = Integer.valueof(LoanSplit.Loan_Split_Number__c);
                   
                 wrappers.add(new FinLoanSplitWrapper(nextIdent,LoanSplit));
                   }
                   }
                  
 if(wrappers2 == null) { 
     
      wrappers2=new List<FinLoanSecurityWrapper>();
      for(Finance_Loan_Security__c LoanSecurity :[SELECT Id, Account__c ,Office__c,Loan_Security_Number__c,New_Existing__c,Estimated_Value__c,No_Street__c,
      Suburb__c,State__c ,Postcode__c ,Actual_Value__c,Valuation_Date__c , Rental_Yield__c,Finance__c,Loan_Priority__c,Title_Owner__c   FROM Finance_Loan_Security__c
                   WHERE finance__c  = :FinId order by Loan_Security_Number__c asc]){
                   
                   nextIdent2 = Integer.valueof(LoanSecurity.Loan_Security_Number__c);
                   
                 wrappers2.add(new FinLoanSecurityWrapper(nextIdent2,LoanSecurity));
                   }
                   }
                
    
     
     }else{
     Fin = new Finance__c (Number_of_Splits__c = 1,Number_of_Securities__c = 1,Aggregate_Borrowings__c = 0.00, Total_New_Loans__c = 0.00, Total_Security_Value__c = 0.00);
     Fin.Finance_Office__c = ApexPages.currentPage().getParameters().get('OffId');
     Fin.Account__c = ApexPages.currentPage().getParameters().get('AccId');
      
      
    //LoanSecurity = new Finance_Loan_Security__c ();
      wrappers=new List<FinLoanSplitWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers.add(new FinLoanSplitWrapper(nextIdent++, null));
  }
      wrappers2=new List<FinLoanSecurityWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers2.add(new FinLoanSecurityWrapper(nextIdent2++,null));
  }

}  
      
    }
    
//////////////////////////Save and Cancel\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\    
    public PageReference saveStandard() {
    
    List<Finance_Loan_Split__c> FLS =new List<Finance_Loan_Split__c>();
 Integer SetFLS = -1;
  for (FinLoanSplitWrapper wrap : wrappers)
  {
  SetFLS = SetFLS + 1;
   wrap.FinLoanS.Loan_Split_Number__c = SetFLS;
   FLS.add(wrap.FinLoanS);
  }
  Fin.Number_of_Splits__c = SetFLS+1;

 List<Finance_Loan_Security__c> LoanSecurity =new List<Finance_Loan_Security__c>();
 Integer SetFLSE = -1;
  for (FinLoanSecurityWrapper wrap : wrappers2)
  {
   SetFLSE = SetFLSE + 1;
   wrap.FinSecS.Loan_Security_Number__c = SetFLSE;
   LoanSecurity.add(wrap.FinSecS);
  }
  Fin.Number_of_Securities__c= SetFLSE+1;
    
     try {  
      upsert Fin;
        
        } catch (Exception e) {     
      
             ApexPages.addMessages(e);         
        }
        

  
  for (Finance_Loan_Split__c FinLoanSplit: FLS)
  {
  If(FinLoanSplit.Finance__c == null){
    FinLoanSplit.Finance__c = Fin.id;
    }
  If(FinLoanSplit.Account__c == null){
   FinLoanSplit.Account__c = Fin.Account__c;
   }
   If(FinLoanSplit.Office__c == null){
   FinLoanSplit.Office__c = Fin.Finance_Office__c;
   }
  }
  
    for (Finance_Loan_Security__c LoanSec: LoanSecurity)
  {
   If(LoanSec.Finance__c == null){
    LoanSec.Finance__c = Fin.id;
    }
    If(LoanSec.Account__c == null){
   LoanSec.Account__c = Fin.Account__c;
   }
   If(LoanSec.Office__c == null){
   LoanSec.Office__c = Fin.Finance_Office__c;
   }
  }            
        
        try { 
        
        upsert FLS;
        upsert LoanSecurity;
       
       
        PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+fin.Account__c+'&Sfdc.override=1');
        return pageRef;
        } catch (Exception e) {     
      
             ApexPages.addMessages(e);         
        }
        
        
        
        return null;
    
    }
    
      
    public PageReference Cancel() {
   
        PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+Fin.account__c+'&Sfdc.override=1');
        return pageRef;
     
    }
//////////////////////////Save and Cancel\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\    
//////////////////////Old Code to keep for Reference - Delete Later\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\   


  /* Remove for now, as it has been made redunant. keep for reference incase soemthing goes wrong
 public PageReference save()
 {
  List<Finance_Loan_Split__c> FLS =new List<Finance_Loan_Split__c>();
  for (FinLoanSplitWrapper wrap : wrappers)
  {
   FLS.add(wrap.FinLoanS);
  }
   
  insert FLS;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('Finance_Loan_Split__c').getDescribe().getKeyPrefix() + '/o');
 }
 */

//////////////////////Old Code to keep for Reference - Delete Later\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\    
 
    
}

 

Hey there,

 

I am not even sure this is possible, but I need some advice. Basically, I have a tabbed VF page for my account and all of its related lists and child objects have their own tab. These tabs are lists of all the records associated with that account and should the user click on one of the links, the bottom half of that tab will re-render with the information. Essentially, it is all the information on one page.

 

This all works perfectly, except what i need to do is to make it so that should the user wish to create a new record, upon saving they will be re-directed to the tab of the object they had jsut created the record in. I have searched and searched and searched for a solution, many people have theories on how to do this...maybe some people have even done this (by searching for a reference for each tab or naming each tab in the code), however it is a bit beyond my coding skill.

 

My question is...Would it be possible to have a link which will re-render the bottom half of the tab..into a create new record VF page...which upon saving will once again re-render to the record... What are your thoughts people?

 

Mikie 

I have a client who is experiencing the following error on a custom controller and we can't find any solutions. 

 

It's just a selectList with a value tied to a String.

 

"j_id0:theForm:j_id2:j_id13:j_id14:j_id16:mySolutionOption: Validation Error: Value is not valid"

 

Any ideas?

 

Thanks,

Jon