Salesforce Certified Application Architect

Friday, 24 March 2017

Validation for disbale and enable in VF page











<apex:page >    
  <apex:form>
   <apex:pageblock title="Customer Information" id="PBBlockTemp">
    <apex:pageBlockSection title="Basic Details" id="PBBlockSectionTemp">
       <script>
      
            /* Start After save button disabled option won't be changed 
             document.onreadystatechange = function(){
                 if(document.readyState === 'complete'){
                     if(document.getElementById('{!$Component.PBBlockTemp.Tempoccupation}').value == 'false'){
                         document.getElementById('{!$Component.PBBlockTemp.PBBlockSectionTemp.OtherBusinesstemp}').disabled = false;
                        }
                     else{
                         document.getElementById('{!$Component.PBBlockTemp.PBBlockSectionTemp.OtherBusinesstemp}').disabled = true ;
                        }
                    }
                }
              End After save button disabled option won't be changed  */
             
        /* Start Once Changed filed value other field will be disabled     
        function othersUpdateValue(input) {   
               
            if(input.value == 'Others'){
                document.getElementById('{!$Component.PBBlockTemp.PBBlockSectionTemp.OtherBusinesstemp}').disabled = false;
                document.getElementById('{!$Component.PBBlockTemp.Tempoccupation}').value = false;
            }
       
        else{
                 document.getElementById('{!$Component.PBBlockTemp.PBBlockSectionTemp.OtherBusinesstemp}').disabled = true;
                 document.getElementById('{!$Component.PBBlockTemp.Tempoccupation}').value = true;
            }
        }
        </script>
       
         <apex:inputField label="Test Type" value="{!lead.Tset_Type__c}" onchange="othersUpdateValue(this);"/>
         <apex:inputField label="OccuTest" value="{!lead.Others_Test}" Id="OtherBusinesstemp"/>
         End Once Changed filed value other field will be disabled */
       
         After Button
       
        <apex:inputHidden value="{!Tempoccupation}" id="Tempoccupation"/>
       
    </apex:form>
     </apex:page >   
          Controller Property
          public boolean Tempoccupation {get;set;}

Friday, 21 October 2016

Managing a list of New Records in Visualforce



Apex class:

public class ManageListController
{
 public List<AccountWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;

 public ManageListController()
 {
  wrappers=new List<AccountWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
 }

 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
 
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }

 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
 }

 public PageReference save()
 {
  List<Account> accs=new List<Account>();
  for (AccountWrapper wrap : wrappers)
  {
   accs.add(wrap.acc);
  }
 
  insert accs;
 
  return new PageReference('/' + Schema.getGlobalDescribe().get('Account').getDescribe().getKeyPrefix() + '/o');
 }

 public class AccountWrapper
 {
  public Account acc {get; private set;}
  public Integer ident {get; private set;}
 
  public AccountWrapper(Integer inIdent)
  {
   ident=inIdent;
   acc=new Account(Name='Bulk Acc ' + ident);
  }
 }
}

--------------------------------------------------------------------------
Page :
<apex:page controller="ManageListController" tabstyle="Account">
 <apex:form >
   <apex:pageBlock title="Bulk Account Create">
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
         <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
         <apex:column headerValue="Name">
            <apex:inputField value="{!wrapper.acc.Name}"/>
         </apex:column>
         <apex:column headerValue="Parent">
            <apex:inputField value="{!wrapper.acc.ParentId}"/>
         </apex:column>
         <apex:column headerValue="Industry">
            <apex:inputField value="{!wrapper.acc.Industry}"/>
         </apex:column>
         <apex:column headerValue="Type">
            <apex:inputField value="{!wrapper.acc.Type}"/>
         </apex:column>
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
            </apex:commandButton>
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
 </apex:form>
</apex:page>

Wednesday, 30 March 2016

How to parse response (Getting from third party ) through DOM Parser in SFDC

The DOM (Document Object Model) represents an XML document as a hierarchy of nodes. Some nodes may be branch nodes and have child nodes, while others are leaf nodes with no children.
 
Here is the steps as listed under FYR :
1. Get DOM document
2. Get root Element
3. Get child Element
4. Get children

Example :
Integer Temp = 0;
for(integer i=0; i<=Temp; i++){
   
    Dom.Document docx = res.getBodyDocument();
    dom.XmlNode xroot = docx.getrootelement();
    dom.XmlNode [] xrrec = xroot.getChildElements();
   
    for(Dom.XMLNode child : xrrec){           
   
     for (dom.XmlNode awr : child.getchildren()){

        }
    }
}

Cheers ..

Salesforce Certified Application Architect & Certified Data Architecture and Management Designer Exam

How to pass Salesforce Certified Data Architecture and Management Designer Exam This exam was 1st architect exam for me. Its not that muc...