• Arnold Joseph Todas
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 17
    Questions
  • 20
    Replies
Hello,

How can i retain checkbox in parent, I have picklist in child containing ('a','b','c','d','e'). I created a child with a picklist of 'a' and it should checked on parent and i delete the child, the checkbox 'a' of parent should be uncheked  . the main problem is if i created another child that contains picklist 'a', and i delete the first child which is picklist 'a' the checkbox of parent will retain because there is another child that i created with picklist 'a' . how can i create a trigger for that?

Thanks for help!
AJ
Hello guys,

I have two input fields, The first input is number of interval and the secod input is a picklist of months. I have 12 checkbox which is the months.
The validation is once i select any month on picklist the checkbox of particular month will be checked for example i selected March on picklist the checkbox of march will be checked. And the validation for interval is for example i selected March and the interval is 2, The checkbox of March, May,July,September, November, December will be checked. How can i create a trigger for that?

Thanks for help!
AJ
How can i filter my TO and FROM Date to fetch a record? Example i have VF page that have a input field of Date_To and Date_From if i inputed FROM: 19/01/2015 and I Inputed TO: 19/02/2015 all of the record that created yesterday and today will show to pageblocktable.

Thanks for help!

AJ
How do i code two input field with date FROM and TO?

Any help? Thanks
AJ

How can i call the email template in batch apex class and send an email?

Thanks

AJ
 

How can i put another checkbox on second Pageblock table Here is my code:
<apex:page controller="AccountSelectClassController" sidebar="false">
<!-- CheckBox -->
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
        
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

and here is my controller : 
public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}
When i select on first pageblock it will transfer to another pablock but how can i put another checkbox on second pageblocktable?

Thanks!
AJ
 
How can i highlight the rows to bold text once i clicked the Account Name here is my code : 
<apex:form id="frm" >
<apex:pageBlock title="Account" id="accounts">
   
      <apex:pageBlockTable value="{!accounts}" var="a" id="list" rules="rows"> 
      
        <apex:column headerValue="Account Name">
            <apex:commandLink rerender="contactDetails" value=" {!a.Name}" action="{!ContactLists}"> 
                <apex:param name="id" value="{!a.id}"/>
            </apex:commandLink> 
        </apex:column>
        
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>
        
      </apex:pageBlockTable>
      <center>
      <!--<apex:commandButton value="Show Contacts"/>-->
      <apex:commandButton value="Hide Contacts" action="{!EditContact}" rerender="contactDetails" />
      </center>
</apex:pageBlock>

all row should be bold once i click the account name.

Thanks!
AJ
How can i edit contact base on account here is my code:
<apex:page sidebar="false" standardController="Account" recordSetVar="accounts" tabstyle="account" extensions="DisplayContact">
<img src="{!$Resource.OnePiece}" />

<script>
var lastRow;
function highlight(elem){
    if(lastRow != undefined)
        elem.style.fontWeight = 'bold';
        lastRow = elem;
}
</script>

<apex:form id="frm" >
<apex:pageBlock title="Account" id="accounts">
   
      <apex:pageBlockTable value="{!accounts}" var="a" id="list" rules="rows" onRowClick="highlight(this);">
      
        <apex:column headerValue="Account Name">
            <apex:commandLink rerender="contactDetails" value=" {!a.Name}" action="{!ContactLists}"> 
                <apex:param name="id" value="{!a.id}"/>
            </apex:commandLink> 
        </apex:column>
        
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>
        
      </apex:pageBlockTable>
      <center>
      <!--<apex:commandButton value="Show Contacts"/>-->
      <apex:commandButton value="Hide Contacts" action="{!EditContact}" rerender="contactDetails" />
      </center>
</apex:pageBlock>


<apex:pageBlock title="Contact" id="contacts">
   <apex:outputPanel id="contactDetails" >
     <apex:pageBlockTable value="{!conList}" var="con" id="conlist" title="Contact">
         <apex:column value="{!con.Name}"/>
         <apex:Column value="{!con.Phone}" />
         <apex:Column value="{!con.Email}" />
         <apex:column >
             <apex:commandLink action="{!Edit}" > Edit </apex:commandLink>
         </apex:column>
       <!--  
         <apex:column headerValue="Edit Record">
            <apex:commandLink rerender="contacts" value="edit" action="{!ContactLists}"> 
                <apex:param name="id" value="{!edit.id}"/>
            </apex:commandLink> 
        </apex:column>-->
         
     </apex:pageBlockTable>
     <center><apex:commandButton value="Add New Contact" rendered="{!showResults}" action="{!AddnewCont}"/></center>
   </apex:outputPanel>
</apex:pageBlock>
   </apex:form>
</apex:page>






------------------------------------------------------------------------------------



public with sharing class DisplayContact {

    public DisplayContact(ApexPages.StandardSetController controller) {

    }


    public List<Contact> conList {get;set;}
    public List<Account> accList{get;set;}
    public Contact con{get; set;}
    public Boolean showResults {get; set;}
     
    
    public PageReference ContactLists()
    {
    showResults = true;
    if(ApexPages.currentPage().getParameters().get('id') != null)
      conList = [Select id,Name,Phone,Email from contact where accountId =: ApexPages.currentPage().getParameters().get('id')];
      accList = [Select id From Account Where Id=:ApexPages.currentPage().getParameters().get('id')];
      System.debug('*****' + conList);
      System.debug('*****' + accList);
     return null;
    }   
    
    
    public PageReference EditContact(){ 
      conList = null;
      PageReference hide = new PageReference('https://c.ap0.visual.force.com/apex/AccountSearchContact');   
      showResults = false;   
      return null;
    }
    public PageReference AddnewCont(){
    
        if(ApexPages.currentPage().getParameters().get('id') != null)
              
              
              accList = [Select id From Account Where Id=:ApexPages.currentPage().getParameters().get('id')];
                  for(Account a: accList ){
                  PageReference addnew = new PageReference('https://ap.salesforce.com/003/e?retURL=%2F' + a.Id+ '&accid='+a.Id);
                  return addnew;
      }
              
        return null;
}
        
        
    
    public PageReference Edit(){
    
    if(ApexPages.currentPage().getParameters().get('id') != null)
            
              conList = [Select id,Name,Phone,Email, AccountId from Contact where AccountId =: ApexPages.currentPage().getParameters().get('id')];
              
               System.debug('&&'+conList);
                  for(Contact c: conList){
                  PageReference addnew = new PageReference('https://ap.salesforce.com/' + c.Id );
                  return addnew;
        }
              
        return null;

    }
}

User-added image
When i click edit it should edit the specific contact in row.
Thanks!
AJ
How can i Bold the row selected once i clicked the Account Name?
Here is my code : 
<apex:page sidebar="false" standardController="Account" recordSetVar="accounts" tabstyle="account" extensions="DisplayContact">
<img src="{!$Resource.OnePiece}" />

<apex:form id="frm" >
<apex:pageBlock title="Account" id="accounts">
   
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
      
        <apex:column headerValue="Account Name">
            <apex:commandLink rerender="contactDetails" value=" {!a.Name}" action="{!ContactLists}"> 
                <apex:param name="id" value="{!a.id}"/>
            </apex:commandLink> 
        </apex:column>
        
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>
        
      </apex:pageBlockTable>
      <center>
      <!--<apex:commandButton value="Show Contacts"/>-->
      <apex:commandButton value="Hide Contacts" action="{!EditContact}" rerender="contactDetails" />
      </center>
</apex:pageBlock>


<apex:pageBlock title="Contact" id="contacts">
   <apex:outputPanel id="contactDetails" >
     <apex:pageBlockTable value="{!conList}" var="con" id="conlist" title="Contact">
         <apex:column value="{!con.Name}"/>
         <apex:Column value="{!con.Phone}" />
         <apex:Column value="{!con.Email}" />
         <apex:commandLink value="edit"/>
       <!--  
         <apex:column headerValue="Edit Record">
            <apex:commandLink rerender="contacts" value="edit" action="{!ContactLists}"> 
                <apex:param name="id" value="{!edit.id}"/>
            </apex:commandLink> 
        </apex:column>-->
         
     </apex:pageBlockTable>
     <center><apex:commandButton value="Add New Contact" rendered="{!showResults}" action="{!AddnewCont}"/></center>
   </apex:outputPanel>
</apex:pageBlock>
   </apex:form>
</apex:page>

User-added image
Thanks for Help!
AJ
How can i make PageblockTable row clickable. Once i click Account Name it will show all the related Contacts for account?
I very very appreciate if you could help me with my code :
 
<apex:page sidebar="false" standardController="Account" recordSetVar="accounts" tabstyle="account">
<img src="{!$Resource.OnePiece}" />

<apex:pageBlock title="Pirate Account"> 
    <apex:form >
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">

        <apex:column headerValue="Account Name">
            <apex:outputLink value="{!a.name}">{!a.name}</apex:outputLink>
        </apex:column>
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>
        
      </apex:pageBlockTable>
      <center><apex:commandButton value="Show Contacts"/><apex:commandButton value="Hide Contacts"/></center>
      
    </apex:form>
</apex:pageBlock>


</apex:page>

Thanks!
AJ
How do i display all Account in VF Page with the Account Name, Type, Address and Created by?

Thanks a lot!
AJ
How can i Update Mailingaddress in contact base on Account BillingAddress? and if i put null on account Name in Contact the Mailing Address should be null too

Thanks for Help!
AJ
Why i am getting an error on method charAt(i)? this is a piglatin word exercise.
here is my code:
String s = 'happy';
s = s.toUpperCase();

Integer l = s.length();
Integer pos = -1;
String str;
Integer i;

for( i = 0; i < l; i++){
    str = s.chartAt(i);
    if(str == 'A' || str == 'E' || str == 'I' || str == 'O' || str == 'U'){
        pos = i;
        break;
    }
}
if(pos != -1){
    String a = s.substring(pos);
    String b = s.substring(0,pos);
    String pig = a + b + 'ay';
    System.debug('' + pig);
}else
    System.debug('Eat bulaga');
Very appreciate if you can help me thaks!
AJ
 
i have an exercise that is to create a pig latin in developers console. Can somebody teach me how to code a pig latin word

Thanks for help!
AJ
I'm creating an duplication validation on account Names. why am i getting an error of 'caused by: System.ListException: Row with null Id at index: 0 Class.AccountDuplicate.checkDuplicateName: line 7, column 1 here is my code:
public static void checkDuplicateName(List<Account> newRecords) {
    Set<String> articles = new Set<String>{'the', 'an', 'a'};
    Set<String> newNames = new Set<String>();
    Map<String, Id> newNameToAccount = new Map<String, Id>();
    Map<Id, Account> accountMap = new Map<Id, Account>(newRecords);

    for (Account account: newRecords) {
        if (account.Name == null) {
            continue;
        }

        List<String> nameParts = account.Name.split(' ');
        if (nameParts.isEmpty()) {
            continue;
        }

        for (String part: nameParts) {
            part = part.toLowerCase();
        }
        
        if (articles.contains(nameParts.get(0))) {
            nameParts.remove(0);
        }

        String newName = String.join(nameparts,' ');

        newNameToAccount.put(newName, account.Id);
    }

    if (!newNameToAccount.isEmpty()) {
        List<Account> matchingAccounts = [
            select Name
            from Account
            where Name = :newNameToAccount.keySet()
        ];

        if (!matchingAccounts.isEmpty()) {
            for (Account account: matchingAccounts) {
                accountMap.get(newNameToAccount.get(account.Name.toLowerCase())).addError('You cannot create a duplicate name');
            }
        }
    }
}
Thanks For Help!
AJ
 
How can i ignore the word of The, An, A in when i create an account Name for example The Company = Company; An Company = Company; it should show an error and it will not added to the list. And how can i put the SELECT query outside the loop here is my code : 
public static void checkDuplicateName(List<Account> newRecord){         
        Set<String> str = new Set<String>{'The','An','A'};
        for(Account account: newRecord){              
            List<Account> existingName = [SELECT Id, Name FROM Account WHERE Name =: account.Name];
            if(existingName.size()>0){
                account.adderror('You cannot create a duplicate Name');
            }
        }
    }

Thanks For Help!
AJ
How can i ignore the www. for not showing an error example (www.yahoo.com = yahoo.com; www.cs.org != www.cs.ph)
here is duplication method for my website. Thanks in advance

public static void checkDuplicateWebsite(List<Account> newRecord){
       for(Account a: newRecord){
           List<Account> account = [SELECT Id, Website FROM Account WHERE Website=:a.Website];
           if(account.size()>0){
               a.adderror('You cannot create a duplicate Website');
           }       
    }
Hello,

How can i retain checkbox in parent, I have picklist in child containing ('a','b','c','d','e'). I created a child with a picklist of 'a' and it should checked on parent and i delete the child, the checkbox 'a' of parent should be uncheked  . the main problem is if i created another child that contains picklist 'a', and i delete the first child which is picklist 'a' the checkbox of parent will retain because there is another child that i created with picklist 'a' . how can i create a trigger for that?

Thanks for help!
AJ
Hello guys,

I have two input fields, The first input is number of interval and the secod input is a picklist of months. I have 12 checkbox which is the months.
The validation is once i select any month on picklist the checkbox of particular month will be checked for example i selected March on picklist the checkbox of march will be checked. And the validation for interval is for example i selected March and the interval is 2, The checkbox of March, May,July,September, November, December will be checked. How can i create a trigger for that?

Thanks for help!
AJ
How can i Bold the row selected once i clicked the Account Name?
Here is my code : 
<apex:page sidebar="false" standardController="Account" recordSetVar="accounts" tabstyle="account" extensions="DisplayContact">
<img src="{!$Resource.OnePiece}" />

<apex:form id="frm" >
<apex:pageBlock title="Account" id="accounts">
   
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
      
        <apex:column headerValue="Account Name">
            <apex:commandLink rerender="contactDetails" value=" {!a.Name}" action="{!ContactLists}"> 
                <apex:param name="id" value="{!a.id}"/>
            </apex:commandLink> 
        </apex:column>
        
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>
        
      </apex:pageBlockTable>
      <center>
      <!--<apex:commandButton value="Show Contacts"/>-->
      <apex:commandButton value="Hide Contacts" action="{!EditContact}" rerender="contactDetails" />
      </center>
</apex:pageBlock>


<apex:pageBlock title="Contact" id="contacts">
   <apex:outputPanel id="contactDetails" >
     <apex:pageBlockTable value="{!conList}" var="con" id="conlist" title="Contact">
         <apex:column value="{!con.Name}"/>
         <apex:Column value="{!con.Phone}" />
         <apex:Column value="{!con.Email}" />
         <apex:commandLink value="edit"/>
       <!--  
         <apex:column headerValue="Edit Record">
            <apex:commandLink rerender="contacts" value="edit" action="{!ContactLists}"> 
                <apex:param name="id" value="{!edit.id}"/>
            </apex:commandLink> 
        </apex:column>-->
         
     </apex:pageBlockTable>
     <center><apex:commandButton value="Add New Contact" rendered="{!showResults}" action="{!AddnewCont}"/></center>
   </apex:outputPanel>
</apex:pageBlock>
   </apex:form>
</apex:page>

User-added image
Thanks for Help!
AJ
How do i display all Account in VF Page with the Account Name, Type, Address and Created by?

Thanks a lot!
AJ
i have an exercise that is to create a pig latin in developers console. Can somebody teach me how to code a pig latin word

Thanks for help!
AJ
How can i ignore the word of The, An, A in when i create an account Name for example The Company = Company; An Company = Company; it should show an error and it will not added to the list. And how can i put the SELECT query outside the loop here is my code : 
public static void checkDuplicateName(List<Account> newRecord){         
        Set<String> str = new Set<String>{'The','An','A'};
        for(Account account: newRecord){              
            List<Account> existingName = [SELECT Id, Name FROM Account WHERE Name =: account.Name];
            if(existingName.size()>0){
                account.adderror('You cannot create a duplicate Name');
            }
        }
    }

Thanks For Help!
AJ
How can i ignore the www. for not showing an error example (www.yahoo.com = yahoo.com; www.cs.org != www.cs.ph)
here is duplication method for my website. Thanks in advance

public static void checkDuplicateWebsite(List<Account> newRecord){
       for(Account a: newRecord){
           List<Account> account = [SELECT Id, Website FROM Account WHERE Website=:a.Website];
           if(account.size()>0){
               a.adderror('You cannot create a duplicate Website');
           }       
    }
How can i assert for the return value of save(), Here is my code for class
public pagereference save() {

        ipAsset.AsLi_Status__c = AsLi_Constants.ASSETSTATUS_DRAFT;
        try {
            copyAccountCompanyDesc();
            upsert ipAsset;

            for(AsLi_AssetTechnology__c at : assetTechTags){
                if(at.AsLi_AssetMD__c == null){
                    at.AsLi_AssetMD__c = ipAsset.Id;
                }
            }

            upsert assetTechTags;
            
            
            PageReference IPAssetPage = new ApexPages.StandardController(ipasset).view();
                
            IPAssetPage.setRedirect(true);
            return IPAssetPage;
            
        } catch (DmlException ex) {
            ApexPages.addMessages(ex);
            return null;
        }
            
    }
Here is my test class
RecordType rt = [select id,Name from RecordType where SobjectType='AsLi_IPAsset__c' And Name = 'RFP Answer'];
        System.debug(rt);
        
        List<AsLi_TechnologiesTags__c> techTest = new List<AsLi_TechnologiesTags__c>();
        AsLi_TechnologiesTags__c tags1 = new AsLi_TechnologiesTags__c(Name = 'Google', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        AsLi_TechnologiesTags__c tags2 = new AsLi_TechnologiesTags__c(Name = 'Google Talk', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        AsLi_TechnologiesTags__c tags3 = new AsLi_TechnologiesTags__c(Name = 'Google Drive', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        
        techTest.add(tags1);
        techTest.add(tags2);
        techTest.add(tags3);
        
        insert techTest;
        
        AsLi_IPAsset__c asset2 = new AsLi_IPAsset__c(RecordTypeId = rt.Id, Name = 'test2');
        insert asset2;
        PageReference pageRef = new PageReference('https://c.cs24.visual.force.com/apex/AsLi_AssetEdit/?Id=' + asset2.Id);



Test.setCurrentPage(pageRef);
        
        ApexPages.StandardController sCon = new ApexPages.StandardController(asset2);
        AsLi_AssetEditControllerExtension controller = new  AsLi_AssetEditControllerExtension(sCon);
        AsLi_AssetEditControllerExtension.TechnologyWrapper wr = new AsLi_AssetEditControllerExtension.TechnologyWrapper();
        controller.showPopup();
        Test.startTest();
        PageReference search1 = controller.showPopup();
        controller.searchText = 'Google';
        controller.search();
        controller.getOnFirstPage();
        controller.getOnLastPage();
        controller.add();   
        controller.save();
        Test.stopTest();
        
        
        
        System.assertEquals(3,controller.searchCount.size());
        AsLi_AssetTechnology__c assetTag = [Select Id, Name, AsLi_TechnologiesTagsMD__c, AsLi_AssetMD__c From AsLi_AssetTechnology__c];
        
        System.debug(assetTag);
        System.assertEquals(asset2.id,assetTag.AsLi_AssetMD__c);
        System.assertEquals(techTest[0].id,assetTag.AsLi_TechnologiesTagsMD__c);
        

        
    }