• SForceBeWithYou
  • NEWBIE
  • 65 Points
  • Member since 2012
  • Principal Technical Architect
  • May The SForce Be With You, Inc.


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 3
    Questions
  • 56
    Replies
Hi,

I am using a Map<Boolean, Idea> . I am trying to adding up values in the map in a for loop. But only the last added values only saved in the map. I can't able to identify it. 
 
listofIdeas = new Map<Boolean, Idea>();
        ideaList = [ SELECT Title,Body,Id,VoteScore,VoteTotal FROM Idea Order By CreatedDate desc ];
        for(Idea ids: ideaList)
        {
            ideaIds.add(ids.Id);
        }
        List<Vote> userVote = [SELECT CreatedById, ParentId FROM Vote WHERE CreatedById = :Userinfo.getUserId() AND ParentId = :ideaIds];
        System.debug('Hi' +userVote);
        for(Idea ideas : ideaList)
        {
            for(Vote votes: userVote)
            {
                if(votes.ParentId == ideas.Id)
                {    
                    isVoted = true;              
                }
                else
                {
                    notVoted = true; 
                }                
            }
            System.debug('Voted'+ ideas.Title + isVoted); 
            if(isVoted == true)
            {
                listofIdeas.put(true,ideas);
            }
            else if(notVoted == true)
            {
                listofIdeas.put(false,ideas);
            }  
        }
        System.debug('Ideas List' + listofIdeas);
I want to compare if the user already voted on particular idea. I am facing problems on comparing it and send it to VF page and based on that I should the promote and demote button.

Thanks,
Vetri
 
Hey dev peeps,

So, I'm writing two custom Lightning components:
1) A navigation menu that fire Application level events when nav items are clicked
2) A form component that listens for navigation events, and dynamically loads different form pages
 
({
    initialLoad : function(component, event) {
        console.log("Entering CustomerApplicationNavigationController.initialLoad");
        var initialDivId = "YourInfo",
            formName = "CreditApp_" + initialDivId;
        this.changeActiveNavItem(component, event, initialDivId);
        console.log(formName);
        console.log("Running CustomerApplicationNavigationHelper.fireNavEvent...");
        this.fireNavEvent(component, event, formName);
    },
    fireNavEvent : function(component, event, formCmpName) {
        console.log("Entering CustomerApplicationNavigationHelper.fireNavEvent...");
        console.log("formCmpName: " + formCmpName);
        //console.log($A);
        var navEvent = $A.get("e.c:CustomerApplicationNavEvent");
        console.log(navEvent);
        navEvent.setParams({"pageToLoad" : formCmpName});
        console.log("navEvent: " + navEvent);
        navEvent.fire();
        console.log("navEvent fired...");
    },
    registerClickHandlers : function(component, event) {
        var navItems = document.getElementById("navItems");
        for (var idxNavItem = 0; idxNavItem < navItems.children.length; idxNavItem++) {
            navItems.children[idxNavItem].addEventListener("click", function (clickEvent) {
                var formName = "CreditApp_" + clickEvent.target.id;
                //console.log(formName);
                console.log("Entering CustomerApplicationNavigationHelper.fireNavEvent...");
                console.log("formName: " + formName);
                //console.log($A);
                var navEvent = $A.get("e.c:CustomerApplicationNavEvent");
                console.log("navEvent: " + navEvent);
                navEvent.setParams({"pageToLoad" : formName});
                console.log("navEvent: " + navEvent);
                navEvent.fire();
                console.log("navEvent fired...");
            });
        }
    },
    changeActiveNavItem : function(component, event, navItemId) {
        console.log("Entering CustomerApplicationNavigationController.changeActiveNavItem");
        console.log(navItemId);
        var navItems = document.getElementById("navItems"),
            activeNavComponent = document.getElementById(navItemId);
        console.log(activeNavComponent);
        console.log(JSON.stringify(navItems.children));
        for (var idxNavItem = 0; idxNavItem < navItems.children.length; idxNavItem++) {
            navItems.children[idxNavItem].classList.add("inactive");
        }
        activeNavComponent.classList.add("active");
    }
})

After running the initial "fireNavEvent" on doInit of the nav component, var navEvent = $A.get("e.c:CustomerApplicationNavEvent"); works fine and loads an event into navEvent:
console.log("navEvent: " + navEvent);

returns:
navEvent: SecureAuraEvent: [object Object]{ key: {"namespace":"c"} }

However, when the "registerClickHandlers" version of this runs, I get this:
console.log("navEvent: " + navEvent);
returns:
navEvent: undefined

Is this a scoping problem?  I'm not including any libraries like jQuery that would mess with the "$" variable.  console.log($A) gives me the JavaScript API object in each context, just not returning an event with $A.get.  How can I even start to debug this?


Thanks,

Nathan

I'm making a call to an external RESTful web service from Apex code via Http, HttpRequest, and HttpResponse classes.

 

Here is my response:

{"response":{"error_id":"SYSTEM","error":"SFDC_STACK_DEPTH is not a valid HTTP header name","error_description":null,"error_code":null,"service":"auth","method":"POST","dbg_info":{"instance":"11.hbapi.sand-08.nym1","slave_hit":false,"db":"master","awesomesauce_cache_used":false,"warnings":[],"time":18.586874008179,"start_microtime":1359518018.7667,"version":"1.13.12.3"}}}

 

It's obvious that it's not liking the request header:

SFDC_STACK_DEPTH: 1

 

 

Any way I can not include this in the request?  Can I change the HTTP version (1.1 instead?)

 

Thanks,

 

Nathan

So, I'm dealing with the largest org instance I've ever come across, and apparently when I do a Schema.getGlobalDescribe() and try to put the key set into a Set<String>, I get "Collection size 1,629 exceeds maximum size of 1,000".

Now, I'm no stranger to getting arounds limits... I've obviously ran into data limi problems in this org, and metadata limits on the Eclipse side, but I'm not quite sure how to get around this one, since the Schema.getGlobalDescribe() method is not a SOQL query... It's a method that returns a Map<String,Schema.SObjectType> , and the limit for a map is 1,000. I know with a large query, you can do something akin to this for an org with 30,000 accounts:
for(List<Account> lstAccts : [SELECT Id, Name FROM Account]){
for(Account a : lstAccts){
a.Name = a.Name + ' some change';
}
update lstAccts;
}

... but the method Scena.getGlobalDescribe() is not a query, it's a method call that returns a Map<String,Schema.SObjectType>. How can I populate a full set (or list of sets) of API names of SObjects in my org if there's more than 1,000?

Here's what I have so far:

Controller:
public class CustomObjectsViewController{
public Map<String,Schema.SObjectType> mapGDescribe{get; set;}
public Set<String> setObjNames{get; set;}

public CustomObjectsViewController(){
this.mapGDescribe = Schema.getGlobalDescribe();
this.setObjNames = mapGDescribe.keySet();
}
}

VisualForce Page:
<apex:page controller="CustomObjectsViewController">
<apex:pageBlock >
<apex:pageBlockTable value="{!setObjNames}" var="objName">
<apex:column value="{!objName}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Error when loading VFpage:
Collection size 1,629 exceeds maximum size of 1,000

Note:
At the end of the day... I'm really trying to implement a List View of custom objects.
All I want is a list view "Unmanaged Custom Objects" like I have for classes, triggers, components, and VFpages.
Is there an idea like that I can vote for?

Any help is GREATLY appreciated.


Thanks,

Nathan Pepper
SalesForce.com Developer
YouTube: www.youtube.com/MayTheSForceBWithYou
Twitter: @SForceBeWithYou
I was working through the 'Lightning Web Components Basics' trailhead unit and was successfully able to push the E-bikes demo app and components to my organization. As per the trailhead instructions, I was using the salesforce CLI command:
sfdx force:source:deploy -p force-app -u <username>

This worked initially, but after making the prescribed changes to some web components for the unit, the deploy command now fails with the error: 
The component must implement at least one of lightning__AppPage interface.
Even if I checkout the e-bike demo app code clean from GitHub, it still fails with the same error.
Is there something wrong with my CLI configuration? Or organization configuration?
 
Hi, 
I just can't seem to get pass stage 10, as I keep getting, the below error:
"The View Lightning Campaign Influence Report link on the Campaign object must use a relative URL and dynamic filter values."
I have tried with different trail orgs and same issue persists.  Has anyone tried this challenge recently and do you have this issue?

The link in the button I have is "/one/one.app#/sObject/00O0N000004ti60/view?fv0={!Campaign.Id}" - the ID of the report is correct and when clicked from campaign it filters correctly.
Screenshot:
Campaign report link

 
I'm getting this error:
User-added image
And I don't have a clue why, any insights/help?  The xml is below with everything it says to check being, to my knowledge, correct.  The review does work, if I enter one and press the submit button it does save and change the tab.
 
    <aura:attribute name="review" type="BoatReview__c" access="private" />
    <aura:attribute name="boatReview" type="BoatReview__c" access="private" />
    <aura:attribute name="recordError" type="String" access="private" />
    
    <force:recordData aura:id="service"
                      layoutType="FULL"
                      fields="Id,Name,Comment__c,Boat__c"
                      mode="EDIT"
                      targetRecord="{!v.review}"
                      targetFields="{!v.boatReview}"
                      targetError="{!v.recordError}" />
    
    <lightning:layout verticalAlign="start" multipleRows="true">
        <Lightning:layoutItem flexibility="auto" padding="around-small">

            <lightning:input name="reviewtitle" label="Title" value="{!v.boatReview.Name}" />

        </Lightning:layoutItem>
        <Lightning:layoutItem flexibility="auto" padding="around-small">
            <label>Description</label>
            <lightning:inputRichText aura:id="reviewcomment" value="{!v.boatReview.Comment__c}" />
        </Lightning:layoutItem>
        <Lightning:layoutItem flexibility="auto" padding="around-small">
            &nbsp;rating&nbsp;
        </Lightning:layoutItem>
        <Lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:button iconName="utility:save" onclick="{!c.onSave}" label="Submit"/>
        </Lightning:layoutItem>
    </lightning:layout>



 

Hi all, I am so close to finishing this process automation badge but am stuck in one area in Step 7.

I've built out my process builder as follows

User-added image
User-added image
User-added image

And my date formula as follows
 

Case(MOD(Date__c-DATE(1900,1,7),7),0,"Sunday",1,"Monday",2,"Tuesday",3,"Wednesday",4,"Thursday",5, "Friday",6,"Saturday", "")
 



Challenge Not yet complete... here's what's wrong:  The Robot Setup Day of the Week formula does not seem to be working properly. The Day of the Week should not fall on Saturday or Sunday. 

It works nicely but doesn't seem to pass, what could be up.
 

I have a hybrid local app running with Mobile SDK 5.1.  Authentication works fine.  Selecting data works fine.  But when I try to update a record with force.update (using the new syntax with the Id in the object, not as a parameter), I'm getting a very generic 400 error.  All the obvious things look fine -- security, JSON format, etc.  I'm not so much looking for suggestions about the root cause, but could use some advice about how to get more information on the error.  JSON.stringify(error) only returns the URL constructed from the path and fields, and "error 400".  Any ideas about how to dig deeper?
Hi all,

I have 2 objects: Claim__c and intake__c
Whenever a new claim is created i need to map all values of claim to intake.All values are getting mapped except the recordtype.Can anyone please tell me how to map recordtype from claim to intake 
Hi All,

I'm deploying Account and Contact layouts to production using Eclipse Ide. While validating i'm facing issue like  "ActionId specified was invalid for ActionType QuickAction". Please let me know how to resolve the issue.

Thanks
Hi Folks, 

I have one excel sheet. Which holds old records(already in salesforce) and new records. I want to insert only new records in salesforce. but don't know how to do. So basically migration needs to do following steps. 

1) Travers row by row data in excel sheet.(In excel sheet there is no Record ID columns, only domain data).
2) Check data already presents in salesforce or not. 
3) If this totally new records then insert. and If this is old then to updation. 

Please let me know If you need more clarification.

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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\    
 
    
}

 
Hi,

I am using a Map<Boolean, Idea> . I am trying to adding up values in the map in a for loop. But only the last added values only saved in the map. I can't able to identify it. 
 
listofIdeas = new Map<Boolean, Idea>();
        ideaList = [ SELECT Title,Body,Id,VoteScore,VoteTotal FROM Idea Order By CreatedDate desc ];
        for(Idea ids: ideaList)
        {
            ideaIds.add(ids.Id);
        }
        List<Vote> userVote = [SELECT CreatedById, ParentId FROM Vote WHERE CreatedById = :Userinfo.getUserId() AND ParentId = :ideaIds];
        System.debug('Hi' +userVote);
        for(Idea ideas : ideaList)
        {
            for(Vote votes: userVote)
            {
                if(votes.ParentId == ideas.Id)
                {    
                    isVoted = true;              
                }
                else
                {
                    notVoted = true; 
                }                
            }
            System.debug('Voted'+ ideas.Title + isVoted); 
            if(isVoted == true)
            {
                listofIdeas.put(true,ideas);
            }
            else if(notVoted == true)
            {
                listofIdeas.put(false,ideas);
            }  
        }
        System.debug('Ideas List' + listofIdeas);
I want to compare if the user already voted on particular idea. I am facing problems on comparing it and send it to VF page and based on that I should the promote and demote button.

Thanks,
Vetri
 
Is there a complete authoritative choice heirarchy for choosing which automation and customization strategy to use?  For instance I'm assuming the following list is a possible choice heirarchy might look like in order of least invasive/time to implement to most invasive/time to implement:

1.  Validation Rules
2.  Formulas
3.  Workflow Rules
4.  Apex

For example, if I need to complete a task in Salesforce, I would ask myself the question:  Can get the task done with a validation rule?  If yes, then go with that first rather than going straight to writing apex code.  If the task can't be completed through any other point and click means, then write Apex code.  However I'm relatively new at Salesforce and I don't know all of the tools between validations and apex.  I'm fairly certain I got the last one right--that Apex is a last resort.  Can anyone point me to an authoritative list of tools in order?

 


I have used Multiple components in VF page.

M4 Component code have overlapped in M1 component.

I have passed one variable to M4 component.

But this passed variable is showing in Page. But this value always showing as "null" in M4 Component controller constructor.
Please help to get this passed value in M4 Component controller.

My Main page code :

<apex:page sidebar="false" showHeader="false">
    <c:M1 ></c:M1>
</apex:page>


M1 Component Code:
_________________

<apex:component controller="retriveSetCon" >
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"></meta>

    <c:M2 ></c:M2>                       
                                             
    <body  style="margin-top: 1%;background-color:white" >
        <div class = "modal1">  
            <p style="position: fixed; padding-top: 25%;font-weight: bold;color: black;padding-left: 46%;font-size: 19px;" id="msgBlock"><b> Processing...</b></p>
        </div>                
        <div class="container-fluid">         
                
                    <div class="tab-content">
                    
                            <div>
                                <!-- some code -->
                                <c:M4 myValue1="AccountObject"></c:M4>
                           </div>
                       
                    </div>
        </div>

        <div>
            <c:M5 ></c:M5>
        </div>

    </body>
 
</apex:component>



M4 Component Code :
_______________________

<apex:component controller="TestComponentController">

  <apex:attribute name="myValue1" description="This is the value for the component." required = "true" type="String"  assignTo="{!myValue}"/>
  <div class="container">

  <apex:outputText value="{!myValue}" style="color:red" />
  
  <apex:dataTable value="{!taskList}" var="t">
 
    <apex:column >

        <apex:facet name="header">Name</apex:facet>

            <apex:outputText value="{!t.Name}"/>

        </apex:column>
  </apex:dataTable>
 
</div>
</apex:component>

global without sharing class TestComponentController{
    
    public String myValue{get;set;}


    public TestComponentController(){
     System.debug('myValue:::::::'+myValue);
       
    }
}


/*
 * **Created by Jack Wang 9.24.2014
*/
global class AR_Creating75DummyNML implements Database.Batchable<sObject>{
    
    static final Integer numofNML=75;
    global final String query;
    global AR_Creating75DummyNML(String q)
    {
        query=q;
    }
    
    public List<Task> createNML(List<ID> IDs)
    {
        integer size=IDs.size();
        List<integer> ints=new List<integer>();
        
        Integer numberDays = date.daysInMonth(Date.today().year(), Date.today().month());
        for(integer i=0;i<75;i++)
        {
            double k=Math.random()*size;
            ints.add(k.intValue());          
        }
        
        
        string userid=null;
        User[] users=[select id from User where name='Jeremy Young'];
        if(users.size()>0)
        {
            userid=users[0].id;
        }
        List<Task> tsks=new List<Task>();
        for(Integer i : ints)
        {
            double datek=Math.random()*numberDays;
            Task nml=new Task(ownerid=userid,CallType__c='NML',whatid=String.valueOf(IDs[i]),Subject='NML',
                              Status='Completed',Priority='Normal',ActivityDate=Date.today().tostartofMonth().addDays(datek.intValue()));
            tsks.add(nml);
        }
        return tsks;
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC)
    {        
        return Database.getQueryLocator(query);        
    }
    
    global void execute(Database.BatchableContext BC, List<Account> scope)
    {
        
        Map<String,List<ID>> territoryClientIDMap=new Map<String,List<ID>>();
        for(Account client : scope)
        {
            if(territoryClientIDMap.containsKey(client.client_territories__c))
            {
                territoryClientIDMap.get(client.client_territories__c).add(client.Id);
            }
            else
            {
                territoryClientIDMap.put(client.client_territories__c, new List<ID>());
                territoryClientIDMap.get(client.client_territories__c).add(client.Id);
            }
        }
        
        for(List<ID> clientIDS : territoryClientIDMap.values())
        {
            List<Task> tsks=createNML(clientIDS);
            insert tsks;
        }
        
        
    }
    
    global void finish(Database.BatchableContext BC)
    {
        
    }

}
@isTest
private class Test_AR_Creating75DummyNML {
    
    
    static testMethod void Test(){
        //create 10 advisors
        ////for each advisor create 100 clients
        //

        string userid=null;
        User[] users=[select id from User where name='Jeremy Young'];
        if(users.size()>0)
        {
            userid=users[0].id;
        }
        List<Account> advisors=new List<Account>();
    
        For(integer i=0;i<10;i++)
        {
            Account a=new Account(name='a'+String.valueOf(i),client_territories__c='a'+String.valueOf(i),account_type__c='provider',Monthly_Activity_Reporting__c=true,Account_Status__c='active');
            advisors.add(a);
        }
        insert advisors;
        
        For(integer j=0;j<advisors.size();j++)
        {
            List<Account> clients=new List<Account>();
            For(integer i=0;i<100;i++)
            {
                Account client=new Account(name=advisors[j].name+String.valueOf(i),client_territories__c=advisors[j].client_territories__c,account_type__c='prospect');
                clients.add(client);
            }
            insert clients;
        }
        
        
        List<Account> advisors1= [select client_territories__c from Account where
                                (account_type__c='provider' or account_type__c='advisor') 
                                 and Monthly_Activity_Reporting__c=true and Account_Status__c='active'];
        List<String> territories=new List<String>();
        List<String> advisorIDs=new List<String>();
        for(Account advisor : advisors1)
        {
            territories.add(advisor.client_territories__c);
            advisorIDs.add(advisor.id);
        }        
        //[select id,client_territories__c from Account where client_territories__c in :territories];
        string tempquery='Select id,client_territories__c from Account where client_territories__c in (';        
        for(String terr : territories)
        {
            tempquery+='\'';
            tempquery+=terr;
            tempquery+='\',';
        }
        tempquery=tempquery.substring(0, tempquery.length()-1);
        tempquery+=') and id not in (';
        for(String adid : advisorIDs)
        {
			tempquery+='\'';
            tempquery+=adid;
            tempquery+='\'';
            tempquery+=',';
        }
        string query=tempquery.substring(0, tempquery.length()-1);
        query+=')';
        
        Test.startTest();
        AR_Creating75DummyNML c=new AR_Creating75DummyNML(query);
        Database.executeBatch(c);
        Test.stopTest();
        
        List<Task> tsk=[select ownerid,CallType__c,Subject,
                              Status,Priority,ActivityDate from Task where createddate=TODAY and CallType__c='NML'
                       and ownerid= :userid and Status='Completed' and Priority='Normal'];
        
        //75 tasks for each advisor
        System.assertEquals(750, tsk.size());
        
        
	}

}

I tried to google this error, but I didn't get a satisfied answer.


  • September 24, 2014
  • Like
  • 0
Greetings everyone,

I recently changed all my triggers to classes and then created a main trigger for each object that calls the classes for each respective object.

Anywho, my opportunity trigger calls quite a few classes. The issue is that if I don't add a recursion check, I can't deploy the trigger due to the SOQL query limit being broken. But if I do add the recursion check, only the Before triggers work. Not the After triggers.


Here is the trigger (with the recursion call up top):

trigger MainTriggerOpportunity on Opportunity (before insert, before update, after insert, after update) {
   
    if(checkRecursive.runOnce()){
   
    if(trigger.isBefore){
        if(trigger.isInsert){
            ClassOppIndustry updater = new ClassOppIndustry();
            updater.updateOppIndustry(trigger.new);
           
            ClassRenewalDate updater1 = new ClassRenewalDate();
            updater1.updateRenewalDate(trigger.new);
        }
        if(trigger.isUpdate){
            ClassOppIndustry updater = new ClassOppIndustry();
            updater.updateOppIndustry(trigger.new);
           
            ClassRenewalDate updater1 = new ClassRenewalDate();
            updater1.updateRenewalDate(trigger.new);
        }
    }
   
    if(trigger.isAfter){
        if(trigger.isInsert){
            ClassRenewalProcess updater = new ClassRenewalProcess();
            updater.updateRenewalStatus(Trigger.new);
           
            ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
            updater1.addBrand(trigger.new);
        }
        if(trigger.isUpdate){
            ClassRenewalProcess updater = new ClassRenewalProcess();
            updater.updateRenewalStatus(Trigger.new);
           
            ClassOppBrandCreate updater1 = new ClassOppBrandCreate();
            updater1.addBrand(trigger.new);
           
            ClassChatterAlerts updater2 = new ClassChatterAlerts();
            updater2.addChatterAlert(Trigger.new,Trigger.oldMap);
        }
    }
}
   
}




Here is the recursion check class:

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



Perhaps I have to allow the trigger to run twice? I'm a newb, so any help would be much appreciated!

Thanks,
Greg

Hello,

 

We want to implement Basic auth in external SOAP call. Can anyone help us with best practices for Storing Passwords in SFDC. 

 

Regards,

Sushil

I am trying to prepare a zip file to import new articles into my org/sandbox but having trouble with mapping some key rich text area fields such as solution__c and Description__c. When I add them to the csv file that I am using in the zip file. I get the following error: "This value [Description] in the header for column 6 cannot be mapped (check both the header and its matching FLS).
[MESSAGE 4/16/2013 8:34 PM] -- Import Failed --" I get the same error for both fields and some other standard fields such as publishstatus. I checked the field level security including all the required knowledge permissions and everything looks fine to me. Does anyone know what I am doing wrong?

Any one has used Up and Down picklist values on Vote Object using Vote API. I have a requirement to insert data into vote object using Vote API for Knowledge articles.

 

I am able to insert data with Type 1 through 5 but when I do the same with Up or Down i am getting below error

"Invalid vote type 'Up(db=0,api=Up)' for voting mode '2(db=2,api=Rank1To5)'.: Vote Value"

Any help is much appreciated.

 

Thanks

 

 

 

I can get the apex log infirmation from apexlog object

 

SELECT Application, LastModifiedDate, DurationMilliseconds, Location, Id, LogLength, LogUserId, Operation, Request, StartTime, Status, SystemModstamp FROM ApexLog

 

I dont see a column where I can get the details about the log , the information that you see when you click on View link in debug log screen against each debug log item.

 

thanks

 

Hello

How to collapse & expand  salesforce Collapsible Sidebar in visual foce using coding ?

Thanks
Yogesh



Tried doing a callout from an execute method in a queueable class and go the @future error -
Callout not allowed from this future method. Please enable callout by annotating the future method. eg: @Future(callout=true)
07:13:51.752 (8701449752265601)|SYSTEM_METHOD_EXIT|[1263]|System.Http.send(ANY)
Is there a way to annotate the execute with "(callout=true)".

I sounds like what i want to do may be doable if there's just some syntax to get the annotation.

 

I can get the apex log infirmation from apexlog object

 

SELECT Application, LastModifiedDate, DurationMilliseconds, Location, Id, LogLength, LogUserId, Operation, Request, StartTime, Status, SystemModstamp FROM ApexLog

 

I dont see a column where I can get the details about the log , the information that you see when you click on View link in debug log screen against each debug log item.

 

thanks