• KMN
  • NEWBIE
  • 15 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
Hi Community,
 
I have Some fields on Account Object.
Fields                       DataType
Count__c                     Number
Count1__c                   Currency
Count2__c                   Number
Final_Count__c            Formula
in the Final Count i used a Formula........ 
Count1__c / Count__c  / 1000 *  Count2__c
The Requirement is if i putt 0 (zero) in count therefore Final Count Should not be null.
Like in image shown there will be value of Count1 and Count2 If i put 1 or any number that should Count and value get printed in Final Count. Means 0 (Zero we have to ignore if we put zero in any three field.. it is possible to do Like this by any Condition check.
User-added imageThank You in Advanced
  • November 24, 2021
  • Like
  • 0
User-added imageHi,
Can Someone give me any idea to create page like this.
i have 2 object.
1. Contact
fields for contact EMP NAME, EMP CODE etc....
2. Attendance.
fields For Attendance are Date, shift time compant name,employee Id (LookUp with Contact).
So the requirement is Which contact i choose in the Employee Id that contact should show in the below with EMP NAME & EMP CODE Etc.
please help me to do this... 
Thank You In advance.....
  • November 11, 2021
  • Like
  • 0
HI,
I have Create a page like account form and add some related contacts
and i want make that contacts editable.
Can someone help i am practicing on it.
code...on standardcontroller
<apex:page standardController="Account">
    <style>
        .s1{Background-Color: LightBlue;}
        .s2{Background-Color: Pink;}
    </style>
    <apex:form >
        <apex:sectionHeader title="Account" subtitle="Account Form"/>
        <apex:pageBlock title="Account Form" >
            <apex:pageBlockSection title="Account Information" columns="2">    
                <apex:inputField value="{!Account.Owner.Name}" styleClass="s1"/>
                <apex:inputField value="{!Account.Rating}" style="BackGround-Color:Pink; color: blue;"/>
                <apex:inputField value="{!Account.Name}" styleClass="s1"/>
                <apex:inputField value="{!Account.Phone}" styleClass="s2"/> 
                <apex:inputField value="{!Account.ParentId}" styleClass="s1"/>
                <apex:inputField value="{!Account.Fax}" styleClass="s2"/> 
                <apex:inputField value="{!Account.AnnualRevenue}" styleClass="s1"/>
                <apex:inputField value="{!Account.NumberOfEmployees}" styleClass="s2"/>  
                <apex:inputField value="{!Account.Ownership}" styleClass="s1"/>
                 <apex:inputField value="{!Account.website}" styleClass="s2"/>  
                
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Additional Information" columns="2">    
                <apex:inputField value="{!Account.Site}" styleClass="s1"/>
                <apex:inputField value="{!Account.AccountNumber}" styleClass="s2"/>
                <apex:inputField value="{!Account.Industry}" styleClass="s2"/>
                <apex:inputField value="{!Account.Type}" styleClass="s1"/> 
            </apex:pageBlockSection>           
            <apex:pageBlockSection title="Address Information" columns="2">  
                <apex:inputField value="{!Account.BillingStreet}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingStreet}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingState}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingState}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingCity}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingCity}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingPostalCode}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingPostalCode}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingCountry}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingCountry}" styleClass="s2"/>
            </apex:pageBlockSection>            
            <apex:pageBlockSection title="Description" columns="2">    
                <apex:inputField value="{!Account.Description}" styleClass="s1"/>
            </apex:pageBlockSection> 
            <apex:pageBlock title="Related Contacts">
    
                <apex:pageBlockTable value="{!Account.contacts}" var="con">
                    <apex:column value="{!con.firstName}"/>
                    <apex:column value="{!con.LastName}"/>
                    <apex:column value="{!con.Phone}"/>
                    <apex:column value="{!con.AccountId}"/>         
                </apex:pageBlockTable>

                </apex:pageBlock>
            
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton action="{!Save}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>          
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
  • September 27, 2021
  • Like
  • 0
Pre-Reqs:
Create a field on Account called “Out_of_Zip”, checkbox, default off

Assignment:
When a Billing Address is modified, get the new Postal Code. 
Then check which Contacts on the Account are outside that Postal Code. 
If 1 or more Contacts are outside of the Postal Code, mark Out_of_Zip as TRUE.

This code is in Nasted loop how to avoid nasted loop and make this code with Map
Trigger..................

trigger AccoounTriggerZip on Account (before update) {
    if(Trigger.isBefore){
        if(Trigger.isUpdate){
            AccoounTriggerZipHelper.checkZip(Trigger.new);
        }
    }
}

Helper Class..............

public class AccoounTriggerZipHelper {
    Static Boolean firsCall = True;  // usig flag to avoid recursive trigger
    public static void checkZip(List<Account> updatedAccountList){
        Account accountToUpdate;
        List<Account> accountToUpdateList; // contains accounts
        List<Account> acc = [SELECT id, Out_of_Zip__c, Billingpostalcode,
                             (SELECT id,Mailingpostalcode 
                                        FROM Contacts)
                                    FROM Account WHERE id IN :updatedAccountList];
        accountToUpdateList = new List<Account>();
        if(firsCall == True){
            for(Account a : acc){
                System.debug('Iterate Over Accounts');
                for(Contact c : a.Contacts){
                    System.debug('Iterating over contacts');
                    if(c.MailingPostalCode == a.BillingPostalCode) {
                        continue;
                    }else{
                       accountToUpdate = new  Account(Id = a.Id, Out_of_Zip__c=True);
                    }
                }
            }
        }
        if(accountToUpdateList.size()>0){
            firsCall = False;            // this will not call again
            update accountToUpdateList;
        }
    }
}
  • September 22, 2021
  • Like
  • 0
Hi Community,
 
I have Some fields on Account Object.
Fields                       DataType
Count__c                     Number
Count1__c                   Currency
Count2__c                   Number
Final_Count__c            Formula
in the Final Count i used a Formula........ 
Count1__c / Count__c  / 1000 *  Count2__c
The Requirement is if i putt 0 (zero) in count therefore Final Count Should not be null.
Like in image shown there will be value of Count1 and Count2 If i put 1 or any number that should Count and value get printed in Final Count. Means 0 (Zero we have to ignore if we put zero in any three field.. it is possible to do Like this by any Condition check.
User-added imageThank You in Advanced
  • November 24, 2021
  • Like
  • 0
HI,
I have Create a page like account form and add some related contacts
and i want make that contacts editable.
Can someone help i am practicing on it.
code...on standardcontroller
<apex:page standardController="Account">
    <style>
        .s1{Background-Color: LightBlue;}
        .s2{Background-Color: Pink;}
    </style>
    <apex:form >
        <apex:sectionHeader title="Account" subtitle="Account Form"/>
        <apex:pageBlock title="Account Form" >
            <apex:pageBlockSection title="Account Information" columns="2">    
                <apex:inputField value="{!Account.Owner.Name}" styleClass="s1"/>
                <apex:inputField value="{!Account.Rating}" style="BackGround-Color:Pink; color: blue;"/>
                <apex:inputField value="{!Account.Name}" styleClass="s1"/>
                <apex:inputField value="{!Account.Phone}" styleClass="s2"/> 
                <apex:inputField value="{!Account.ParentId}" styleClass="s1"/>
                <apex:inputField value="{!Account.Fax}" styleClass="s2"/> 
                <apex:inputField value="{!Account.AnnualRevenue}" styleClass="s1"/>
                <apex:inputField value="{!Account.NumberOfEmployees}" styleClass="s2"/>  
                <apex:inputField value="{!Account.Ownership}" styleClass="s1"/>
                 <apex:inputField value="{!Account.website}" styleClass="s2"/>  
                
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Additional Information" columns="2">    
                <apex:inputField value="{!Account.Site}" styleClass="s1"/>
                <apex:inputField value="{!Account.AccountNumber}" styleClass="s2"/>
                <apex:inputField value="{!Account.Industry}" styleClass="s2"/>
                <apex:inputField value="{!Account.Type}" styleClass="s1"/> 
            </apex:pageBlockSection>           
            <apex:pageBlockSection title="Address Information" columns="2">  
                <apex:inputField value="{!Account.BillingStreet}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingStreet}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingState}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingState}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingCity}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingCity}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingPostalCode}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingPostalCode}" styleClass="s2"/>
                <apex:inputField value="{!Account.BillingCountry}" styleClass="s1"/>
                <apex:inputField value="{!Account.ShippingCountry}" styleClass="s2"/>
            </apex:pageBlockSection>            
            <apex:pageBlockSection title="Description" columns="2">    
                <apex:inputField value="{!Account.Description}" styleClass="s1"/>
            </apex:pageBlockSection> 
            <apex:pageBlock title="Related Contacts">
    
                <apex:pageBlockTable value="{!Account.contacts}" var="con">
                    <apex:column value="{!con.firstName}"/>
                    <apex:column value="{!con.LastName}"/>
                    <apex:column value="{!con.Phone}"/>
                    <apex:column value="{!con.AccountId}"/>         
                </apex:pageBlockTable>

                </apex:pageBlock>
            
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton action="{!Save}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>          
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
  • September 27, 2021
  • Like
  • 0
Pre-Reqs:
Create a field on Account called “Out_of_Zip”, checkbox, default off

Assignment:
When a Billing Address is modified, get the new Postal Code. 
Then check which Contacts on the Account are outside that Postal Code. 
If 1 or more Contacts are outside of the Postal Code, mark Out_of_Zip as TRUE.

This code is in Nasted loop how to avoid nasted loop and make this code with Map
Trigger..................

trigger AccoounTriggerZip on Account (before update) {
    if(Trigger.isBefore){
        if(Trigger.isUpdate){
            AccoounTriggerZipHelper.checkZip(Trigger.new);
        }
    }
}

Helper Class..............

public class AccoounTriggerZipHelper {
    Static Boolean firsCall = True;  // usig flag to avoid recursive trigger
    public static void checkZip(List<Account> updatedAccountList){
        Account accountToUpdate;
        List<Account> accountToUpdateList; // contains accounts
        List<Account> acc = [SELECT id, Out_of_Zip__c, Billingpostalcode,
                             (SELECT id,Mailingpostalcode 
                                        FROM Contacts)
                                    FROM Account WHERE id IN :updatedAccountList];
        accountToUpdateList = new List<Account>();
        if(firsCall == True){
            for(Account a : acc){
                System.debug('Iterate Over Accounts');
                for(Contact c : a.Contacts){
                    System.debug('Iterating over contacts');
                    if(c.MailingPostalCode == a.BillingPostalCode) {
                        continue;
                    }else{
                       accountToUpdate = new  Account(Id = a.Id, Out_of_Zip__c=True);
                    }
                }
            }
        }
        if(accountToUpdateList.size()>0){
            firsCall = False;            // this will not call again
            update accountToUpdateList;
        }
    }
}
  • September 22, 2021
  • Like
  • 0
Hi everyone!!

How to do with trigger?

Change contact owner on new record through trigger when industry = agriculture.