• Ramin Mohammadi
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 4
    Replies
I don't understand test classes, can someone help me out.



public with sharing class whitespace{
  
    transient public String AccountID{get;set;}
    transient public String PAccountID{get;set;}
    transient public List<Account>TIPlist{get;set;}
    transient public String t{get;set;}
    transient public Map<String,List<Installed_Products__c>> IPList{get;set;}
    transient public String Account_Name {get;set;}
    transient public list<Installed_Products__c> P{get;set;}
    

    public whitespace(ApexPages.StandardController controller){
        }
        public Map<String,List<String>> IPListM{
            get{
                //Selects Account ID and Parent ID
                
                AccountID = ApexPages.currentPage().getParameters().get('id');
                PAccountID = [select ParentId from Account where ID = :AccountID].ParentId;
            
                //Queries Account info based on criteria
                if (PAccountID == null){
                    TIPList = [select Name,(select Account__c,Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];
                }
                else {
                    TIPList = [select Name,(select  Account__c,Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a  where ParentID =: PAccountID];   
                }
                //Declares Map and List
                Map<String,List<String>> IPList = new Map<String,List<String>>();
                
                for(integer j = 0; j < TIPList.size(); j++){ 
                    List <String> P = new List<String>{};
                    //sets temporary variable t, Account Name as String and clears the product list
                    P.clear();
                    t = '';
                    Account_Name = TIPList[j].Name;
                    
                
                    
                    for(Integer i = (TIPList[j].Product_Releases_del__r.size()-1) ; i >= 0; i--){
                        system.debug(TIPList[j]);
                        Installed_Products__c x = TIPList[j].Product_Releases_del__r[i];
                        
                        if(t == x.Product_Family__c){
                            }
                        else{
                            system.debug(TIPList[j].Product_Releases_del__r[i].Product_Family__c);
                            system.debug(TIPList[j]);
                            P.add(TIPList[j].Product_Releases_del__r[i].Product_Family__c);
                            t = x.Product_Family__c;
                                }
                        }
                        
                
                    
                            
                    system.debug(P);
                    system.debug(Account_Name);
                    IPList.put(Account_Name, P);
                    system.debug(IPlist);
                    }  
                return IPList;
                }

        
        
            set;
    }
}
All,

I have this controller extension that is supposed to yield a map in the form of <Account, List<Installed_Products__c (child object of account)>>.

I need my VF page to essentially display

Account.Name                                  Installed_Product__c.Field
​Account.Name                                  Installed_Product__c.Field
​Account.Name                                  Installed_Product__c.Field
etc.

I tried using Apex:Repeat but get a Unknown property Account standard controller.

What is the form for doing so?

Code:

​public with sharing class whitespace{
  
transient public String AccountID{get;set;}
transient public String PAccountID{get;set;}
transient public List<Account>TIPlist{get;set;}
transient public String t{get;set;}
transient Map<Account,List<Installed_Products__c>> IPList{get;set;}
transient public Account Account_Name {get;set;}
transient public list<Installed_Products__c> P{get;set;}
    

public whitespace(ApexPages.StandardController controller){
    
    }
    
    public Map<Account,List<Installed_Products__c>> IPListM(){
        
            AccountID = ApexPages.currentPage().getParameters().get('id');
            PAccountID = [select ParentId from Account where ID = :AccountID].ParentId;
            if (PAccountID == null){
                TIPList = [select Name,(select Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];
            }
            else {
                TIPList = [select Name,(select  Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a  where ParentID =: PAccountID];   
            }
    
    
            Map<Account,List<Installed_Products__c>> IPList = new Map<Account,List<Installed_Products__c>>();
            List <Installed_Products__c> P = new List<Installed_Products__c>{};
        
            for(integer j = 0; j < TIPList.size(); j++){ 
                t = '';
                system.debug(t);
                Account_Name = TIPList[j];
                P.clear();
                for(Integer i = (TIPList[j].Product_Releases_del__r.size()-1) ; i >= 0; i--){
                    Installed_Products__c x = TIPList.get(j).Product_Releases_del__r.get(i);
            
                    if(t == x.Product_Family__c){
                        system.debug('==='+ TIPList.get(j).Product_Releases_del__r.get(i));
                        system.debug(i);
                        system.debug(TIPList[j].Product_Releases_del__r) ;
                        system.debug('=== go');
                    }
                    else{
                        P.add(TIPList[j].Product_Releases_del__r[i]);
                        t = x.Product_Family__c;
                    }
                }
                IPList.put(Account_Name, P);   
            }
            system.debug(TIPList);
            system.debug(IPList.keySet());
            system.debug(IPList.values());
        
        return IPList;
        }
    }
Guys,

I have a list of lists that I am trying to iterate through and remove things from.
As it stands, the if/else statements are working(based on the debug statements), but the ".remove" function will not delete the entry in question.

All help is appreciated, this is the code:  

  for(integer j = 0; j < IPList.size(); j++){ 
        t = '';
        system.debug(t);
        for(Integer i = (IPList[j].Product_Releases_del__r.size()-1) ; i >= 0; i--){
            Installed_Products__c x = IPList.get(j).Product_Releases_del__r.get(i);
            system.debug(x);
            if(t == x.Product_Family__c){
                    IPList.get(j).Product_Releases_del__r.remove(i);
                    system.debug('=== go');
            }
            else{
                
                t = x.Product_Family__c;
                system.debug(t);
            }
     
        }
    
        system.debug(IPList[j].Product_Releases_del__r) ;
    }
Guys, 

I have a query/subquery that gives me this.
IPList = [select Name,(select Account__c, Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];

The issue is, I need the same list to only show unique "Product Family" fields. The way its set up now, an account can have multiple unique Product releases that have duplicate product family fields. 

Two things came to mind:

- Alter the query to only get one object per Product Family (which I didn't know how to do)
- Loop through the list and delete duplicate Product Family objects.

The code:

    FTemp = '';
    
    For(Account acc: IPList){
        integer i = 0;
        For(Installed_Products__c p: acc.Product_Releases_del__r){
            i = i + 1;
            if( p.Product_Family__c == FTemp){
                acc.remove(p[i]);
            }
            else {
                FTemp = p.Product_Family__c;
            }                       
        }

     }

The FTemp variable serves as a check for duplicates as the queried list is sorted alphabetically. Right now I am getting "Expression must be a list type: Installed_Products__c" error.

The main point is that I need IPlist to only contain installed products with unique "Product Family" Fields. 
Any ideas would be appreciated, the correct suggestion recieves kudos
Guys,

I need to loop through a subquery, but am getting an "Invalid Type: Product_Releases__r" Error.

Query:

IPList = [select Name,(select Account__c, Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];


Loop Code:

    For(Account acc: IPList){
        For(Product_Releases_del__r p: acc.Product_Releases_del__r){
            if( p.Product_Family__c == FTemp){
                acc.remove(p);
            }
            else {
                FTemp = acc.Product_Family__c;
            }   
        }


Thanks
 
<apex:page standardcontroller="Account" Extensions="whitespace" >
<head>

<style>
    table{
    padding: 0;
    border : 2px solid rgb(0,96,156);
    }
    
    .list{
    list-style-type:none;
    padding-left:0;
    
    width:150px;
    text-align:left;    
    }
    
    th{
    background-color:rgb(237,28,36);
    color: white;
    height: 50px;
    width:150px;
    padding-left:10;
    border : 1px solid rgb(90,104,112);
    font-weight: Bold;
    font-size: 16px;   
    
    }
    
    td.datafields{
    height: 50px;
    width:150px;
    text-align:left;
    padding-left:10;
    border : 1px solid rgb(0,96,156);
    font-weight: Bold;
    color: rgb(90,104,112);
    font-size: 12;
   
    }
    td.filled{
    height: 50px;
    width:150px;
    text-align:left;
    padding-left:10;
    border : 1px solid rgb(0,96,156);
    font-weight: Bold;
    color: white;
    font-size: 12;
    background-color:green;
   
    }
    td.accountName{
    color:white;
    background-color:rgb(90,104,112);
    font-size:14px;
    height: 50px;
    width:150px;
    text-align:left;
    padding-left:10;
    border : 1px solid rgb(90,104,112);
    font-weight: Bold;
    }
</style>
    <apex:includeScript value="{!URLFOR($Resource.jquery_1_10_2)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jQuery_UI)}" />
    <apex:styleSheet value="{!URLFOR($Resource.jQueryUI_Css)}" />
    
<script>   
    $(document).ready(function() {
          $('#entry').each(function() {
                var entry = $(this).text();
                for (entry i = 0; i <entry.length; i++){
                    if((entry[i] != ''){
                        $("#cell").addClass("td.filled");
                        $("#cell").removeClass("td.datafield");

                    });
                return false;
              });
</script>


</head>

<apex:form >

<table frame="box" width="100%" id ="DataTable">
        <tr>
            <th> Account Site </th>
            <th> Payments</th>
            <th> Cash Management</th>
            <th> Financial Messaging</th>
            <th> Merchant Services</th>
        </tr>
    <apex:repeat value="{!IPlist}" var="p">
        <tr>    
            <td class="accountName">
                <apex:outputText value="{!p.Name}" />
            </td>
            <td class="datafields" id ="cells">    <!-- Need this td to be conditionally highlighted-->
                <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list" >
                    <apex:outputText id="entry" rendered="{!prod.Product_Family__c== "ACHplus"|| prod.Product_Family__c=="CLS"|| prod.Product_Family__c=="Global PAYplus"||
                    prod.Product_Family__c== "BSA" || prod.Product_Family__c== "CLS" || prod.Product_Family__c== "FaxWire"|| prod.Product_Family__c=="GFXWeb"
                    || prod.Product_Family__c== "Global Payments" || prod.Product_Family__c== "Global Payments SP" || prod.Product_Family__c=="Originet"
                    || prod.Product_Family__c== "PARC PAYplus Connect"|| prod.Product_Family__c=="PARC PAYplus USA" || prod.Product_Family__c=="PAYplus Connect/GFX"
                    || prod.Product_Family__c=="PAYplus USA"|| prod.Product_Family__c=="PARC"|| prod.Product_Family__c=="Payment Archive Manager"|| prod.Product_Family__c=="WebACH"}"
                    value="{!prod.Product_Family__c}"   />   <!-- Based on this output being present-->             
                </apex:datalist>
            </td>
            <td class="datafields" id ="cells">
               <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list">
                   <apex:outputText  id="entry" rendered="{!prod.Product_Family__c=="ACCESS"|| prod.Product_Family__c=="Banker"|| prod.Product_Family__c=="Banker Web Client (BWC)"
                   || prod.Product_Family__c=="Global CASHplus"|| prod.Product_Family__c=="CASHplus"|| prod.Product_Family__c=="webACCESS"|| prod.Product_Family__c=="webACCESS ACH"}"
                   value="{!prod.Product_Family__c}"/>  
               </apex:datalist>
            </td>
            <td class="datafields" id ="cells">
               <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list">
                   <apex:outputText id="entry" rendered="{!prod.Product_Family__c=="IGTplus"|| prod.Product_Family__c=="IGTplus Compliance                       Filter"|| prod.Product_Family__c=="TurboSwift"
                   || prod.Product_Family__c=="Clarity"|| prod.Product_Family__c=="TurboFileAct"|| prod.Product_Family__c=="Datasphere"|| prod.Product_Family__c=="MessagePro"|| prod.Product_Family__c=="GMP"}"
                   value="{!prod.Product_Family__c}"/> 
               </apex:datalist>
            </td>
            <td class="datafields" id ="cells">
               <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list">
                   <apex:outputText id="entry" rendered="{!prod.Product_Family__c=="PaymentsHQ"||prod.Product_Family__c=="Bacsactive-IP"||prod.Product_Family__c=="PayAway"
                   ||prod.Product_Family__c=="NetDeposit"||prod.Product_Family__c=="DepositNow"||prod.Product_Family__c=="Same Day Pay"||prod.Product_Family__c=="Mobilescape"
                   ||prod.Product_Family__c=="RDC"|| prod.Product_Family__c=="IP"|| prod.Product_Family__c=="RDC/IP"|| prod.Product_Family__c=="Merchants"}" value="{!prod.Product_Family__c}"/> 
               </apex:datalist>           
            </td>            
        </tr>
    </apex:repeat>
</table>

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


I have this VF/JQuery that I am using to create an html table that contains different lists. These lists render based on certain criteria. I am trying to write a jquery that will change the <td> entries background color to green, while keeping the empties white. If anyone can tell me what I'm doing wrong, I will be grateful.
public with sharing class whitespace{
public String AccountID{get;set;}
public String PAccountID{get;set;}
public List<Account> IPlist{get;set;}


public whitespace(ApexPages.StandardController controller){
    AccountID = ApexPages.currentPage().getParameters().get('id');
           
    PAccountID = [select ParentId from Account where ID = :AccountID].ParentId;
    if (PAccountID == null){
        IPList = [select Name,(select Product_Family__c from Product_Releases_del__r) from Account a where ParentID =: AccountID];
    }
    else {
        IPList = [select Name,(select Product_Family__c from Product_Releases_del__r) from Account a where ParentID =: PAccountID];   
    }
    
}
    
    
        
        
}

This works, I just have no idea what writing test code entails
Guys, 

I have a query/subquery that gives me this.
IPList = [select Name,(select Account__c, Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];

The issue is, I need the same list to only show unique "Product Family" fields. The way its set up now, an account can have multiple unique Product releases that have duplicate product family fields. 

Two things came to mind:

- Alter the query to only get one object per Product Family (which I didn't know how to do)
- Loop through the list and delete duplicate Product Family objects.

The code:

    FTemp = '';
    
    For(Account acc: IPList){
        integer i = 0;
        For(Installed_Products__c p: acc.Product_Releases_del__r){
            i = i + 1;
            if( p.Product_Family__c == FTemp){
                acc.remove(p[i]);
            }
            else {
                FTemp = p.Product_Family__c;
            }                       
        }

     }

The FTemp variable serves as a check for duplicates as the queried list is sorted alphabetically. Right now I am getting "Expression must be a list type: Installed_Products__c" error.

The main point is that I need IPlist to only contain installed products with unique "Product Family" Fields. 
Any ideas would be appreciated, the correct suggestion recieves kudos
<apex:page standardcontroller="Account" Extensions="whitespace" >
<head>

<style>
    table{
    padding: 0;
    border : 2px solid rgb(0,96,156);
    }
    
    .list{
    list-style-type:none;
    padding-left:0;
    
    width:150px;
    text-align:left;    
    }
    
    th{
    background-color:rgb(237,28,36);
    color: white;
    height: 50px;
    width:150px;
    padding-left:10;
    border : 1px solid rgb(90,104,112);
    font-weight: Bold;
    font-size: 16px;   
    
    }
    
    td.datafields{
    height: 50px;
    width:150px;
    text-align:left;
    padding-left:10;
    border : 1px solid rgb(0,96,156);
    font-weight: Bold;
    color: rgb(90,104,112);
    font-size: 12;
   
    }
    td.filled{
    height: 50px;
    width:150px;
    text-align:left;
    padding-left:10;
    border : 1px solid rgb(0,96,156);
    font-weight: Bold;
    color: white;
    font-size: 12;
    background-color:green;
   
    }
    td.accountName{
    color:white;
    background-color:rgb(90,104,112);
    font-size:14px;
    height: 50px;
    width:150px;
    text-align:left;
    padding-left:10;
    border : 1px solid rgb(90,104,112);
    font-weight: Bold;
    }
</style>
    <apex:includeScript value="{!URLFOR($Resource.jquery_1_10_2)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jQuery_UI)}" />
    <apex:styleSheet value="{!URLFOR($Resource.jQueryUI_Css)}" />
    
<script>   
    $(document).ready(function() {
          $('#entry').each(function() {
                var entry = $(this).text();
                for (entry i = 0; i <entry.length; i++){
                    if((entry[i] != ''){
                        $("#cell").addClass("td.filled");
                        $("#cell").removeClass("td.datafield");

                    });
                return false;
              });
</script>


</head>

<apex:form >

<table frame="box" width="100%" id ="DataTable">
        <tr>
            <th> Account Site </th>
            <th> Payments</th>
            <th> Cash Management</th>
            <th> Financial Messaging</th>
            <th> Merchant Services</th>
        </tr>
    <apex:repeat value="{!IPlist}" var="p">
        <tr>    
            <td class="accountName">
                <apex:outputText value="{!p.Name}" />
            </td>
            <td class="datafields" id ="cells">    <!-- Need this td to be conditionally highlighted-->
                <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list" >
                    <apex:outputText id="entry" rendered="{!prod.Product_Family__c== "ACHplus"|| prod.Product_Family__c=="CLS"|| prod.Product_Family__c=="Global PAYplus"||
                    prod.Product_Family__c== "BSA" || prod.Product_Family__c== "CLS" || prod.Product_Family__c== "FaxWire"|| prod.Product_Family__c=="GFXWeb"
                    || prod.Product_Family__c== "Global Payments" || prod.Product_Family__c== "Global Payments SP" || prod.Product_Family__c=="Originet"
                    || prod.Product_Family__c== "PARC PAYplus Connect"|| prod.Product_Family__c=="PARC PAYplus USA" || prod.Product_Family__c=="PAYplus Connect/GFX"
                    || prod.Product_Family__c=="PAYplus USA"|| prod.Product_Family__c=="PARC"|| prod.Product_Family__c=="Payment Archive Manager"|| prod.Product_Family__c=="WebACH"}"
                    value="{!prod.Product_Family__c}"   />   <!-- Based on this output being present-->             
                </apex:datalist>
            </td>
            <td class="datafields" id ="cells">
               <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list">
                   <apex:outputText  id="entry" rendered="{!prod.Product_Family__c=="ACCESS"|| prod.Product_Family__c=="Banker"|| prod.Product_Family__c=="Banker Web Client (BWC)"
                   || prod.Product_Family__c=="Global CASHplus"|| prod.Product_Family__c=="CASHplus"|| prod.Product_Family__c=="webACCESS"|| prod.Product_Family__c=="webACCESS ACH"}"
                   value="{!prod.Product_Family__c}"/>  
               </apex:datalist>
            </td>
            <td class="datafields" id ="cells">
               <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list">
                   <apex:outputText id="entry" rendered="{!prod.Product_Family__c=="IGTplus"|| prod.Product_Family__c=="IGTplus Compliance                       Filter"|| prod.Product_Family__c=="TurboSwift"
                   || prod.Product_Family__c=="Clarity"|| prod.Product_Family__c=="TurboFileAct"|| prod.Product_Family__c=="Datasphere"|| prod.Product_Family__c=="MessagePro"|| prod.Product_Family__c=="GMP"}"
                   value="{!prod.Product_Family__c}"/> 
               </apex:datalist>
            </td>
            <td class="datafields" id ="cells">
               <apex:datalist value="{!p.Product_Releases_del__r}" var="prod" styleClass="list">
                   <apex:outputText id="entry" rendered="{!prod.Product_Family__c=="PaymentsHQ"||prod.Product_Family__c=="Bacsactive-IP"||prod.Product_Family__c=="PayAway"
                   ||prod.Product_Family__c=="NetDeposit"||prod.Product_Family__c=="DepositNow"||prod.Product_Family__c=="Same Day Pay"||prod.Product_Family__c=="Mobilescape"
                   ||prod.Product_Family__c=="RDC"|| prod.Product_Family__c=="IP"|| prod.Product_Family__c=="RDC/IP"|| prod.Product_Family__c=="Merchants"}" value="{!prod.Product_Family__c}"/> 
               </apex:datalist>           
            </td>            
        </tr>
    </apex:repeat>
</table>

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


I have this VF/JQuery that I am using to create an html table that contains different lists. These lists render based on certain criteria. I am trying to write a jquery that will change the <td> entries background color to green, while keeping the empties white. If anyone can tell me what I'm doing wrong, I will be grateful.
public with sharing class whitespace{
public String AccountID{get;set;}
public String PAccountID{get;set;}
public List<Account> IPlist{get;set;}


public whitespace(ApexPages.StandardController controller){
    AccountID = ApexPages.currentPage().getParameters().get('id');
           
    PAccountID = [select ParentId from Account where ID = :AccountID].ParentId;
    if (PAccountID == null){
        IPList = [select Name,(select Product_Family__c from Product_Releases_del__r) from Account a where ParentID =: AccountID];
    }
    else {
        IPList = [select Name,(select Product_Family__c from Product_Releases_del__r) from Account a where ParentID =: PAccountID];   
    }
    
}
    
    
        
        
}

This works, I just have no idea what writing test code entails