• Sharad Soni
  • NEWBIE
  • 124 Points
  • Member since 2017
  • Simplyforce Technology

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies
I want to display an alert message at the instant when the checkbox is ticked. I had a VF code but the problem was- alert message display only after clicking standard save button. Plz, help me on this issue.

    <apex:page standardController="Opportunity" rendered="{!(Opportunity.Forecast_Indicator__c)}">
        <script type="text/javascript">
            window.alert("Text");
        </script>
    </apex:page>

 
Hi, 

 I am trying to update the billing country in account below is the trigger updating in AFTER update event. 

 But I am getting below error 
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger AccountTrigger caused an unexpected exception, contact your administrator: AccountTrigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: ()

 
  Trigger. 
  
trigger AccountTrigger on Account (Before Insert, Before Update,
                                   After Insert, After Update ) {

   if(Trigger.isAfter){  
      OpportunityAccountUtils.ProcessAcctCountryCode(Trigger.newMap, Trigger.oldMap);   
    }
                                               
}

Helpe Class
public class OpportunityAccountUtils {

  public static void ProcessAcctCountryCode(Map<id, Account> newMap, Map<id, Account> oldMap) {
    List<Account> ActLst = new List<Account>();
    Map<String, Country_Code__c> MapCountryCode = new Map<String, Country_Code__c>([SELECT Country_Code__c, Country_Name__c FROM Country_Code__c]);  
    
    for(Account Act : newMap.values()){
      Act.billingcountry = MapCountryCode.get(Act.billingcountry).Country_Code__c;
      ActLst.add(Act);
     }
    
     if(!ActLst.isEmpty()){
       Update ActLst;
     }  
    
    } 
  }

Please suggest me what is the issue with the code. 

Thanks
Sudhir
  • January 29, 2018
  • Like
  • 0
Hi,
  
 I have a below query which will display parent, grand parent till top 5 grand parent can we do this using apex which should automatically display parents till top parent Please suggest me
select id, Name,
                                     ParentId,
                                     Parent.ParentId,
                                     Parent.Parent.ParentId,
                                     Parent.Parent.Parent.ParentId,
                                     Parent.Parent.Parent.Parent.ParentId                                     
                                     from 
                                        Account
                                     where 
                                        ParentId != null
                                        and
                                        id = '0013400001S5ZTm'

Thanks
Sudhir
 
can anybody say how to restrict users to enter only '10' digit Mobile number in <apex:inputtext> field in vf page & to display error message if they enter an incorrect mobile number???
Hello Devs,

I want to access data from below child parent dependencies:

Object tnw_invoice__InvoiceItem__c connected with Object OrderItem and OrderItems connected with Orders

I'm trying to add WHERE condition like Order.Status != 'Closed Lost' in below query:

SELECT Id, tnw_invoice__Order_Item__c FROM tnw_invoice__InvoiceItem__c WHERE tnw_invoice__Product_Code__c = 'xxxxxxxxx8989'

But it's give me error of "Didn't understand relationship......." on developer console query editor.

Thanks for help :)

Kapil
Hey,
Here is the requirement.
Basically I have to add a button to the Contact related list in the Account Layout. When that button is clicked it sould redirect to a Visualforce Page with all the related Contacts and the contact details for that Account and the details should be editable with a save button.
Its basically Mass Update for Related List Details.
I was able to get all related contacts and give inline edit support for them and wrote a save function for the same. I don't know what is wrong but you can edit but when you click save it wont save to salesforce DB.

Here is the controller,
public class stanset_EX_Controller1{
    
    private final Contact setCon;
    
    public stanset_EX_Controller1(ApexPages.StandardSetController controller)
    {
        this.setCon = (Contact) controller.getRecord();
    }

    List<Contact> Conts;

    public List<Contact> getConts(){
        return Conts;
    }

    public ApexPages.StandardSetController  doSomething{
    get {
        // do something with the selected records
        doSomething = new ApexPages.StandardSetController(
                        Database.getQueryLocator([
                                SELECT  Phone,
                                        Name,
                                        AccountId,
                                        Email,
                                        FirstName,
                                        Id,
                                        LastName,
                                        Title
                                FROM Contact
                                WHERE AccountId
                                        = :ApexPages.currentPage().getParameters().get('id')


                        ]));
     return doSomething;
 }
 private set;
}

 public List<Contact> getAccountContactsPagination() {
        //system.debug(doSomething.getRecords()+'ppp');
        return (List<Contact>) doSomething.getRecords();  
}
public PageReference save() {
        system.debug(getAccountContactsPagination());
        //update(getAccountContactsPagination());
        PageReference pageRef = ApexPages.currentPage();
        pageRef.setRedirect(true);
        return pageRef;

    }


   
    
}

Here is the Visualforce page,
 
<apex:page
  standardController="Contact"
  recordSetVar="contacts"
  extensions="stanset_EX_Controller1" showHeader="true" sidebar="false">
  <apex:form >
     <apex:pageBlock >
       <apex:pageBlockTable value="{!accountContactsPagination}" var="contact">
         <apex:column value="{!contact.name}"/>
         <apex:column value="{!contact.FirstName}"/>
         <apex:column value="{!contact.LastName}"/>
         <apex:column value="{!contact.Title}"/>
         <apex:column value="{!contact.Id}"/>
         <apex:column>
         <apex:outputField value=" {!contact.Email}">
         	<apex:inlineEditSupport disabled="false"/>
         </apex:outputField>
     	 </apex:column>
         <apex:column value="{!contact.Phone}"/>
         <apex:inlineEditSupport />
       </apex:pageBlockTable>
       <apex:pageBlockButtons location="bottom">
         <!-- <apex:commandButton value="Do Something" action="{!doSomething}"/> -->
         <apex:commandButton value="Save" action="{!save}" />
       </apex:pageBlockButtons>
     </apex:pageBlock>
  </apex:form>
</apex:page>
Tried many things dont know what is wrong with the code.
HELP!! Thanks In Advance! Cheers!
I want to display an alert message at the instant when the checkbox is ticked. I had a VF code but the problem was- alert message display only after clicking standard save button. Plz, help me on this issue.

    <apex:page standardController="Opportunity" rendered="{!(Opportunity.Forecast_Indicator__c)}">
        <script type="text/javascript">
            window.alert("Text");
        </script>
    </apex:page>

 
I want to show the number of contacts of an Account in the vf page using Apex code and Vf page..
 
Hi All 

I am trying to redirect to a different page when clicked on a button in VF page, but it is actually showing a completely BLANK page. Can anyone please HELP ..!

Thanks