• Gaurish Gopal Goel
  • NEWBIE
  • 325 Points
  • Member since 2013
  • Lead Salesforce Developer
  • Wake'n'Code Technologies Private Limited


  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 5
    Questions
  • 130
    Replies
Hi all,

I am looking for a way to auto(pre) populate a Contact name as the curent user name when he/she create a new case.
This can be internal user creating a case and community user creating a case.
below is my take but when i test with clicking 'new' case, I still see 'Contact Name' blank and need to be searched. 

can anyone please help...?

trigger CaseContactName on Case (before insert) {

   // List <Case> caseContactName = new List <Case>();
    for (Case c : trigger.new){
    if(c.ContactId == null){
      c.ContactId = UserInfo.getUserId(); 
    }
    }
}
hello,
I'm having attempt to de-reference null object error with following code

public class StringChecking{
    
    public String name1{get; set;}
    public List<contact> list2;
    Contact contact1;
    public Contact getContact(){
        if(contact1!=null){
        contact1=[select id,Name,Country__c from Contact where Name=:name1];
    }
        return contact1;
    }
    
    public pagereference ContactList(){
       return null;
    }
    public List<Contact> getList(){
        try{
            if(contact1!=null && contact1.Country__c=='India'){
                list2.add(contact1);                
            }
            
            else if(contact1!=null && contact1.Country__c=='US'){
                 list2.add(contact1);
            }
            
            else{
                 list2.add(contact1);
            }
        }
        catch(DmlException e)
        {
            System.debug('An unexpected error has occurred: ' + e.getMessage());
        }
        return list2;
    }
    
    public pagereference edit(){
        pagereference pg=new Pagereference('https://ap5.salesforce.com/'+contact1.Id);
        return pg;
    }
    
}


please help me to solve this
Hi all,

I have a VF page using SLDS markup (I am in LEX) and I would like to implement expandable/collapsible sections in my form.

This is a code for one of my section with SLDS Expandable section https://www.lightningdesignsystem.com/components/expandable-section/
<div class="slds-form slds-form_compound">
                <fieldset class="slds-box slds-theme--default slds-container--medium slds-align_absolute-center"> 
                    <div class="slds-section">
                        <h3 class="slds-section__title">
                            <button class="slds-button slds-section__title-action" aria-controls="content" aria-expanded="false">
                                <svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left" aria-hidden="true">
                                    <use xmlns:xlink="http://www.w3.org/1999/xlink" 
                                         xlink:href="/apexpages/slds/latest/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
                                </svg>XXXX</button>
                        </h3>
                        <div class="slds-section__content" id="content" aria-hidden="true" >
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" >ABC</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.ABC}" styleClass="slds-input"/>
                                </div>
                            </div>                 
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" ">XYZ</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.XYZ}" styleClass="slds-input"/>
                                </div>
                            </div> 
....
</fieldset>
            </div>
I have tried to implement this solution with jquery: http://www.minerva18.com/blog/creating-expandablecollapsible-lightning-design-sections-in-salesforce/#comment-1763 but the section open only for a few second and close again and the screen jump to the top of the page (I am using Chrome). 

I have also tried other solutions such as
<script type="text/javascript">
    function toggle_visibility() {
   var e = document.getElementById('content'); 
          if(e.style.display == 'none')
          e.style.display = 'block';
       else
          e.style.display = 'none';
    }
</script>

adding onclick="toggle_visibility();" on the button
or
function showContent() {
   {
        document.getElementById('content').style.visibility="visible";
    }
    else
    {
        document.getElementById('content').style.visibility="hidden";
    }
}
or
$(function () { 
    $('content').on('click', function (e) {
        var menuItem = $( e.currentTarget );

        if (menuItem.attr( 'aria-expanded') === 'true') {
            $(this).attr( 'aria-expanded', 'false');
            $(this).attr( 'aria-hidden', 'true')
        } else {
            $(this).attr( 'aria-expanded', 'true');
            $(this).attr( 'aria-hidden', 'false')
        }
    });
});

using jquery: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

But nothing is working.
Any help will be greatly appreciated!
Sylvie
I have the following code that I want to trigger when a new Lead comes into the system.  The trigger will auto populate the "Child Exist" Lookup field on the Lead object if its email matches with a user in the Child object.  If the two emails match, I want to have the Parent_Customer_ID__c of the Child user to auto-populate into the Child Exist field on the Lead.  If there is no match, it can be left blank.

trigger LeadExist on Lead (before insert) {

    Set<String> EmailId = new Set<String>();
    Map<String,String> MapuserId = new Map<String,String>();
    List<Child__c> usrlist = new List<Child__c>(); 
    for(Lead ld : trigger.new)
    {
        If(ld.Email != null)
        {
            EmailId.add(ld.Email);
        }
    }
    
    If(EmailId.size() > 0)
    {
        usrlist = [Select Parent_Customer_ID__c, Email__c from Child__c Where Email__c IN: EmailId];     
    }    
    if(usrlist.size() > 0)
    {
         for(Child__c c : usrlist)
        {
            if(!MapuserId.containsKey(c.Email__c))
            {
                MapuserId.put(c.Email__c, c.Parent_Customer_ID__c);  
            }
            
        }
    }
    
    for(Lead ld : trigger.new)
    {
        ld.Email= MapuserId.get(ld.Child_Exist__c);   
    }

}



Currently, I'm able to save the trigger and create a test lead & child.  However, when I save the test Lead, the email address is not being saved -- once I update the lead after it has been created, the email address will save.  The Parent_Customer_ID__c still won't auto populate.  Any help here will be greatly appreciated!
I created a visualforce page in which it has
form for create new contact,
form for create new account,
and form for create new opportunity..
inside <apex:form>
(Fields are dynamic)

Task:
- create variable in controller for Contact’s LastName and variable for Account’s Name and call it in InputText in VF.
- if I created a new contact, and new opportunity, the Contact will be the Primary Contact of the Opportunity created.

Help me to improve my Controller.

Thanks in advance, I’ll appreciate the help..
public class myController {

public Contact con {get;set;}
public Account acc {get;set;}
public Opportunity opp {get;set;}

public Contact getcon() {
return con;
}

public Account getacc() {
return acc;
}

public Opportunity getopp() {
return opp;
}

public PageReference save() {
insert con;
insert acc;
insert opp;
return null;
}

}


 
Under accounts, we have a custom related list called "related parties"
Related parties can be different types (Beneficiary, Guardian, Interested Party, LPOA)
I want to make a rule so that the same person cannot be both an interested party an LPOA. 
Example: Under Alex's account, Rebecca is a related party of type "Interested Party", if someone else tries to add Rebecca as an "LPOA" under Alex's account, they should not be allowed since she is already an "Interested Party".
The other types don't matter. We just dont want to allow someone to be both Interested Party and LPOA under the same account. 

I was thinking of doing a VLOOKUP, but this does not work.
VLOOKUP($ObjectType.Related_Party__c.Fields.Name , $ObjectType.Related_Party__c.Fields.Name , Party_Type__c ) = "Interested Party" && VLOOKUP($ObjectType.Related_Party__c.Fields.Name , $ObjectType.Related_Party__c.Fields.Name , Party_Type__c ) = "LPOA" 
 

Background:
Our company works in print media and when we sell ads for our magazine, our reps fill the fulfillment information out at the Quote Line Item object.

Our accounting software can only read from the Opportunity Product level.

I have created a trigger that achieves that with one catch, it doesn't recognize when a rep needs to sync the primary quote with the Opportunity.

The button is a standard Salesforce button, meaning it comes with Salesforce and I don't see how to customize it. (Start and Stop Sync button)
If I were to update a record at the Quote Line Item object after syncing the Quote, the trigger works as expected.

Question:
How to execute a trigger on click of a Standard Button?

 

trigger UpdateOpportunityProductMonthsToFulfill on QuoteLineItem (after insert, after update) {
    String monthsToFulfill = '';
    map<String, String> updateMap = new map<String, String>();
    
    // This is where the text for the Months_To_Fulfill__c field is built
    for(QuoteLineItem qli : Trigger.new){
        // To make a spelled-out list of months & years instead of the older "start through end"
        
        List<String> yearOneMonths = qli.Months_Served_Y1__c.replaceAll('None(;)?', '').split(';');
        for(String month : yearOneMonths){
            monthsToFulfill += ( monthsToFulfill.length()==0 ? '' : '; ' ) + month + ' ' + qli.Year_Served_First__c;
        }
        if(!(qli.Year_Served_Second__c == null || qli.Year_Served_Second__c.equals('None'))){
            List<String> yearTwoMonths = qli.Months_Served_Y2__c.replaceAll('None(;)?', '').split(';');
            for(String month : yearTwoMonths){
                monthsToFulfill += '; ' + month + ' ' + qli.Year_Served_Second__c;
            }
        }
        
        updateMap.put(qli.QuoteId, monthsToFulfill);
    }
  
    for(String quoteID : updateMap.keySet()){
        // This is the calculated value we saved from looping through the Trigger.new Collection
        monthsToFulfill = updateMap.get(quoteID);
        
        // Get the OpportunityLineItems associated with this QuoteId
        List<OpportunityLineItem> oliList = [Select Id, OpportunityId, Months_To_Fulfill__c 
                                             From OpportunityLineItem Where OpportunityId In (Select OpportunityId 
                                                                                              From Quote Where Id = :quoteID )];
        
        List<OpportunityLineItem> olisToUpdate = new List<OpportunityLineItem>();
        
        if(oliList.size() > 0){
            for (OpportunityLineItem oli : oliList){
                // Populate this olisToUpdate list because we may 
                // want to get smarter about what's actually updated 
                // in the future.  For now, everything is updated.
                oli.Months_To_Fulfill__c = monthsToFulfill;
                olisToUpdate.add(oli);
            }
            
            // Batch update the OpportunityLineItems we identified earlier
            if(olisToUpdate.size() > 0){
                update olisToUpdate;
            }
        }
    }     
}
 

 

Hi Team,

Need to display popup with contains account and contact button ..  If i click on contact need to display list of contacts with pagination .
if i click on accounts need to display list of accounts with pagination
need to support both lightning and classic.

Thanks for advance
So i created my test class for a controller. And I have coverage 100% but i need to make some assertions using the System.assert(), System.assertEquals(), System.assertNotEquals(), I wrote a simple assert but it's way to simple. 

@isTest 
public class ControllerTestClass 
{
   static testMethod void testMethod1() 
   {

        screen1 sc = new screen1();
        Account acc = sc.getAccount();
        acc.name = 'TestAcc';
        sc.save();
       
        System.assertEquals('TestAcc', acc.name);

          PageReference pageRef = Page.screen1VSF ;
          pageRef.getParameters().put('id',acc.Id);
          Test.setCurrentPage(pageRef);

     }
}


And the class which I'm testing.
public class screen1 
{
  
    public Account myAccount;
    public Account callAccMethod; 
    
    public Account getAccount()
    {
        if(myAccount == null)
        {
            myAccount = new account();
        }
        return myAccount;
    }

    public PageReference save()
    {
       
       callAccMethod = getAccount();
       if(callAccMethod != null)
       {
           insert myAccount;
       }
       
       PageReference pageRef = new PageReference('/apex/screen2');
       pageRef.getParameters().put('id', myAccount.Id);
       return pageRef;
       
    }
    
}
Hi All,

I have taken Salesforce Certified Sales Cloud Consultant (SP17) on May21st 2017.I received result as “Fail” , but my aggregate result would be greater than  68.5%.

Below is my breakup points in all sections:
Test Taker Name: Shyamala LS
Exam: Salesforce Certified Sales Cloud Consultant (SP17)
Result: FAIL
Date Completed: 05/21/2017
Section-Level Scores:
Industry Knowledge: 100%
Implementation Strategies: 50%
Sales Cloud Solution Design: 66%
Marketing and Leads: 75%
Account and Contact Management: 71%
Opportunity Management: 55%
Sales Productivity: 42%
Communities and Site Management: 66%
Sales Cloud Analytics: 100%
Integration and Data Management: 60%

I have raised a Case with Webassossor .But i didn't reciebve the proper details.

I have checked all the sections weightage , I hope I have scored passing percentage(%) in all the sections.
Please let me how salesforce is calculating the sectional percentage and In which section I scored less score ?
My colleagues also took the same exam on last month and cleared the exam and their percentage in all the section is lesser than me.Please let me know the in-detail information on my result.

 
Thanks and Regards,
Shyamala
Mob: +91 8095813508

I am making an HTTP Callout using Apex in which I am not getting authenticated.

 

There are two required parameters : username and api_key

 

Http h = new Http();

HttpRequest req = new HttpRequest();

req.setEndpoint('whatever the url is');

req.setmethod(POST);

 

req.setheader('username','goelgaurish@gmail.com');

req.setheader('api_key','idsfiubsdkjrnwopeiurwoheoir12431);

 

HttpResponse res = h.send(req);
return res.getBody();

 

I am not able to get a success while authenticating. Please correct the code if I am missing something.

 

I am using an application which is not made in salesforce and used for marketing purposes. I want to export all the leads of my salesforce org into my application. How can I do this ?

I want to insert an image as a header in my PDF and some text as a footer. There are total 3 pages. I want these header and footers to be repeated on every page.

 

I have applied some CSS which I found on the internet but none of them worked for me. I need it urgent. Please help.

I am writing a trigger on Contract. When a contract is inserted an opportunity should be inserted under the same Account. Opportunity's name should be the Account's name.

 

I am trying to access the account's fields in this way:

 

For(Contract con:Trigger.new)

{

Opportunity opp = new Opportunity;

opp.name = con.Account.name;

opp.accountid = con.accountid;

insert opp;

}

 

But con.Account.name always return Null value. How should i accomplish this task and Why can't I access the account's name in this way ?

I have a WSDL for some currency convertor application. I am trying to generate an apex class from wsdl.

 

When i tried to upload the wsdl, some errors came like Multiple Porttype, Multiple binding etc. After editing this wsdl somehow i fixed those errors and successfully parsed the wsdl.

 

But at the final step an error is occuring saying that: APEX GENERATION FAILED. UNABLE TO FIND SOAP 1.1 ADDRESS.

 

Please give some tips I am new to web services.

 

In th following code the action support for my input text field is not working as it should work(Line number 69-70 in vf code).I want to navigate to the page number entered by the user.Following is my controller and VF code:
Code for controller
public class ContactListViewController {
    public ContactlistViewController(){
        system.debug('constructor first called');
        RecordsPerPageslist=10;
        allContactList = new list<wrapper>();
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c));
        System.debug('constructor called');
    }
    Map<id,Boolean> m = new Map<id,boolean>();  	 // To store boolean values of checkboxes corrosponding to every contact id
    list<contact> con = [SELECT Name,id,Account.name,Title,Phone,Email FROM Contact];
    public list<wrapper> allContactList;			//Wrapper class object
    
    public list<wrapper> getWrapperContacts(){  	//List of wrapper class to display in table
        return allContactList;
    }
    
    public void getSelectedListContacts(){  		// Select contacts and save them in a map
        for(wrapper wc:allContactList){
            m.put(wc.con.id,wc.isSelected);
        }
        
        System.debug('getSelectedListContacts = '+m);
        
    }
    public void getSelectedAllContacts(){			//To select all contacts in a page
        for(wrapper wc:allContactList){
            m.put(wc.con.id,wc.isSelected=true);
        }
    }
    public void next(){
        System.debug('next');
		allContactList.clear();        
        this.stdSetController.next();
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c)); 
        for(wrapper wc:allContactList){
            wc.isSelected=m.get(wc.con.id);
        }
    }
    public void previous(){
		allContactList.clear();        
        this.stdSetController.previous();
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c)); 
        for(wrapper wc:allContactList){
            wc.isSelected=m.get(wc.con.id);
    }
    }
    public void last(){
        allContactList.clear();        
        this.stdSetController.last();
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c)); 
        for(wrapper wc:allContactList){
            wc.isSelected=m.get(wc.con.id);
    }
    }
    public void first(){
        allContactList.clear();        
        this.stdSetController.first();
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c)); 
        for(wrapper wc:allContactList){
            wc.isSelected=m.get(wc.con.id);
    }
    }
    public boolean getHasNext(){
        return stdSetController.getHasNext();
    }
    public boolean getHasPrevious(){
        return stdSetController.getHasPrevious();
    }
    public list<String> alphabet{
        get{															//To display a list of alphabets on vf page 
            alphabet = new list<string>{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Others','All'};
       		return alphabet;	 
                }
        set;
    }
    public String alphaSearchConct{get;set;}							// To get commandlink parameter for alphabet selected
    public Pagereference getalphaSearch(){								//To update contact list as per the alphabet selected by the user
        allContactList.clear();
        if (alphaSearchConct=='All'){
            con = [SELECT name,Account.name,Title,Phone,Email FROM contact];
        }
        else{
            	con = [SELECT name,Account.name,Title,Phone,Email FROM contact WHERE lastName Like:alphaSearchConct+'%'];
        }
        ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(con);
        stdSetController= ssc;
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c));
        system.debug('alphaSearchconct called');
        return null;
    }      
    public Integer PageNumber{
        get{                                                            //To get current page number
  		    System.debug('get of pageNumber called '+ PageNumber);
            this.PageNumber=stdSetController.getPageNumber();   
            return this.PageNumber;
        }
        set{  
            System.debug('set of pageNumber called');
           	this.pageNumber=value;         
    }
        }
    
    public PageReference NavigateByText(){
        
        System.debug('getNavigateByText '+ stdSetController.getPageNumber());
        allContactList.clear();
        this.stdSetController.setPageNumber(PageNumber);
            for(contact c:(list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c));
            //System.debug(stdSetController.getRecords());
           for(wrapper wc:allContactList){
            wc.isSelected=m.get(wc.con.id);
               System.debug(wc.isSelected);
               System.debug('pageNumber called');
               
    }
        return null;
    }
    public Integer TotalPages{                                            // Total number of pages as per user selection of Records per page
        get{
              if(stdSetController.getResultSize() <=10)
                   this.TotalPages=1;
              if(Math.Mod(stdSetController.getResultSize() ,stdSetController.getPageSize()) == 0)
                  this.TotalPages =(stdSetController.getResultSize()/stdSetController.getPageSize());
              else
                this.TotalPages = (stdSetController.getResultSize()/stdSetController.getPageSize())+1;
              //System.Debug(this.TotalPages);
                return totalpages;
        }
        set;
    }
    public Integer MaxNumberOfRecords{                                    //Maximum number of records in a query list
        get{
             return stdSetController.getRecords().size();
        }
        set;
    }
    public list<SelectOption> getRecordsPerPageOptionList(){              //To display a drop down list on vf page  
            list<SelectOption>  options = new list<SelectOption>();
            options.add(new selectOption('10','10'));
            options.add(new selectOption('25','25'));
            options.add(new selectOption('50','50'));
            options.add(new selectOption('100','100'));
            options.add(new selectOption('200','200'));
            return options;
    }
    public Integer RecordsPerPageslist{ 
        get;
        set{                                                          //To select number of records per page
            if(value!=null){
                this.RecordsPerPagesList=value;
                System.debug('RecordsPerPageList called');
            }
        }       
    }
    public Pagereference getChangeNumberOfRecordsPerPage(){
        allContactList.clear();
        for(contact c: (list<contact>)stdSetController.getRecords())
                allContactList.add(new wrapper(c)); 
         for(wrapper wc:allContactList)
            wc.isSelected=m.get(wc.con.id);
        return null;
    } 
    public ApexPages.StandardSetController stdSetController{            //Instantiating a standard set controller
        get{
            if(stdSetController==null){
             	 stdSetController = new ApexPages.StandardSetController(con);
            }
              stdSetController.setPageSize(RecordsPerPageslist);        //Limiting Number of records to be displayed per page 
            	System.debug('stdSetController called '+ stdSetController.getPageNumber());
            return stdSetController;   
        }
        set;
    }
    public class wrapper{
      public boolean isSelected{get;set;}
      public Contact con{get;set;}
       
         wrapper(contact con){
            isSelected = false;
            this.con = con;
        }
    }
}
Code for VF page:
<apex:page controller="ContactListViewController" sidebar="false">
    <apex:form >
        <!-- For alphabetic search-->
        <div align="right">
            <apex:panelGrid >
                <apex:repeat value="{!alphabet}" var="alph">
                    <apex:commandLink value="{!alph} | " action="{!getalphaSearch}" reRender="table">
                        <apex:param name="a" value="{!alph}" assignTo="{!alphaSearchConct}"/>
                    </apex:commandLink>
                </apex:repeat>
            </apex:panelGrid>
        </div>
        <apex:PageBlock id="table">
            <apex:pageMessages />
            <apex:commandButton action="{!getSelectedAllContacts}" value="Select All" reRender="table"/>
            <apex:PageBlockTable value="{!WrapperContacts}" var="contacts" >
                <!-- To display and select Checkboxes-->
                <apex:column >
                    <apex:facet name="header">
                    	<apex:inputCheckbox value="{!contacts.isSelected}">
                        	<apex:actionSupport event="onclick" action="{!getSelectedAllContacts}" reRender="table"/>
                        </apex:inputCheckbox>	
                        </apex:facet>
                    <apex:inputCheckbox value="{!contacts.isSelected}">
                        <apex:actionSupport event="onclick" action="{!getSelectedListContacts}" reRender="table"/>
                    </apex:inputCheckbox>  
                </apex:column>
                <!-- To Edit and Delete a record -->
                <apex:column headerValue="Action">
                    <apex:outputLink value="{!URLFOR($Action.Contact.Edit,contacts.con.id)}"> 
                        Edit |
                    </apex:outputlink>
                    <apex:outputLink value="{!URLFOR($Action.Contact.Delete,contacts.con.id)}"> 
                        Del |
                    </apex:outputlink>
                </apex:column>
                <apex:column headerValue="Name">
                    <apex:outputLink value="/{!contacts.con.id}">
                        {!contacts.con.name}
                    </apex:outputLink>
                </apex:column>
                <apex:column headerValue="Account Name">
                    <apex:outputLink value="/{!contacts.con.account.id}">
                        {!contacts.con.account.name}
                    </apex:outputLink>
                </apex:column>
                <apex:column value="{!contacts.con.Title}"/>
                <apex:column value="{!contacts.con.Phone}"/>
                <apex:column value="{!contacts.con.email}"/>
                <apex:inlineEditSupport />
            </apex:PageBlockTable>
      		</apex:PageBlock> 
        <!-- below code for pagination -->
        <apex:outputPanel id="button"> 
        <div align = "center" >
            <!-- To return to first page of records-->
            <apex:commandButton action="{!first}" value="<<" title="First Page" disabled="{!!HasPrevious}" reRender="table,button"/>
            <!-- To return to Previous page of records-->
            <apex:commandButton action="{!previous}" value="Previous" disabled="{!!HasPrevious}" reRender="table,button"/>
            <!-- To return to next page of records-->
            <apex:commandButton action="{!next}" value="Next >" disabled = "{!!HasNext}" reRender="table,button"/>
            <!-- To return to last page of records-->
            <apex:commandButton action="{!last}" value=">>" title="Last Page" disabled="{!!HasNext}" reRender="table,button"/>
            <!-- InputText to display current page and to navigate to any page number, At righmost side of page-->
            <span style="float:right">
                <apex:outputLabel value="Page ">
                </apex:outputLabel>
                 <!-- To navigate to the page--> 
                <apex:InputText value="{!PageNumber}" maxLength="4" size="1"/>
                <apex:actionSupport event="onchange" action="{!NavigateByText}" reRender="table,button"/>
                <!-- The above action support is not working-->         
                <apex:outputLabel value=" of {!TotalPages}">
                </apex:outputLabel>
            </span>
            <!-- To display a list for number of records to be selected per page-->
            <span style = "float:left">
                <apex:SelectList value="{!RecordsPerPageslist}" size="1" >
                    <apex:selectOptions value="{!RecordsPerPageOptionList}">    
                    </apex:selectOptions>
                    <apex:actionSupport event="onchange" action="{!getChangeNumberOfRecordsPerPage}" reRender="table,button"/>
                </apex:SelectList>
            </span>
        </div>
    </apex:outputPanel>      
    </apex:form>
</apex:page>


 
Hi,

I have a requirement to populate "parent account" on Account based on a custom field value. I tried to achieve it through a trigger.
In bulk upsert,if the child account is inserted before the parent account,parent account on child is not getting assigned. 

Accounts data will be upserted to salesforce through a scheduled pentaho job from another application on dailiy basis.

Could some one please advise me how to resolve the issue?

Thanks in advance.

BR,
BB
  • April 13, 2018
  • Like
  • 0
Hi all,

I am looking for a way to auto(pre) populate a Contact name as the curent user name when he/she create a new case.
This can be internal user creating a case and community user creating a case.
below is my take but when i test with clicking 'new' case, I still see 'Contact Name' blank and need to be searched. 

can anyone please help...?

trigger CaseContactName on Case (before insert) {

   // List <Case> caseContactName = new List <Case>();
    for (Case c : trigger.new){
    if(c.ContactId == null){
      c.ContactId = UserInfo.getUserId(); 
    }
    }
}
HI,

I need to write an apex trigger, that restricts the account name field on the orders object to be changed, after the record has been cloned.

Can somebody help me with this
Hi,

This change pertains to the Orders object.

It has an account name lookup field on it. Once the order is validated or reduced, user gets the option to clone the record. 

The idea behind cloning is to create a duplicate offer copy under same account.

Hoeever, After cloning, user sometimes end up doing regression and change the account name. I am tryinf to put a validation rule , that helps me restrict the change , But i want it to work , once once the order is cloned.

Below is the validation rule written. Please propose changes if any?

AND( 
ISCLONE(), 
NOT(ISNEW()), 
PRIORVALUE(AccountId) <> "", 
ISCHANGED( AccountId) 
)

Do I need an Apex trigger for the same
Hello everyone,

I am doing render as pdf for  generating pdf by vf page . But i want to generate pdf according to size sellection like A4, A3,A2,A1.


Please suggest me what can i do for implement

 
I'm getting the following error when validating an inbound change set: "myRule_7_A2 (Action Call) - We can't find an action with the name and action type that you specified." Does anybody know the resolution?
this is my vf page

<apex:page showHeader="false" sidebar="false"  controller="bankform1">
  <apex:form >
  <apex:commandButton value="save and new" action="{!savenew}"/>
  <apex:commandButton value="cancel" action="{!cancel}"/>
  <apex:commandButton value="dipaly" action="{!display}"/>
  <apex:sectionHeader title="bank" subtitle="bank form"/>
  
  <apex:pageBlock title="personal info">
  <apex:pageBlockSection title="bankform1">
  <apex:pageBlockSectionItem >
  <apex:outputLabel >account holder Name</apex:outputLabel>
  <apex:inputText value="{!c_Name}"/>
  </apex:pageBlockSectionItem><br/>
  
     
  
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>




and this is my controller


public class bankform1 {

    public String c_Name { get; set; }

    public PageReference display() {
        return null;
    }


    public PageReference cancel() {
        return null;
    }


    public PageReference savenew() {
        return null;
    }

    public PageReference save()
    
    {
        bankform1__c obj = new bankform1__c();
        obj.name=c_Name;
        insert obj;
        return null;
}
}
hello,
I'm having attempt to de-reference null object error with following code

public class StringChecking{
    
    public String name1{get; set;}
    public List<contact> list2;
    Contact contact1;
    public Contact getContact(){
        if(contact1!=null){
        contact1=[select id,Name,Country__c from Contact where Name=:name1];
    }
        return contact1;
    }
    
    public pagereference ContactList(){
       return null;
    }
    public List<Contact> getList(){
        try{
            if(contact1!=null && contact1.Country__c=='India'){
                list2.add(contact1);                
            }
            
            else if(contact1!=null && contact1.Country__c=='US'){
                 list2.add(contact1);
            }
            
            else{
                 list2.add(contact1);
            }
        }
        catch(DmlException e)
        {
            System.debug('An unexpected error has occurred: ' + e.getMessage());
        }
        return list2;
    }
    
    public pagereference edit(){
        pagereference pg=new Pagereference('https://ap5.salesforce.com/'+contact1.Id);
        return pg;
    }
    
}


please help me to solve this
Hi all,

I have a VF page using SLDS markup (I am in LEX) and I would like to implement expandable/collapsible sections in my form.

This is a code for one of my section with SLDS Expandable section https://www.lightningdesignsystem.com/components/expandable-section/
<div class="slds-form slds-form_compound">
                <fieldset class="slds-box slds-theme--default slds-container--medium slds-align_absolute-center"> 
                    <div class="slds-section">
                        <h3 class="slds-section__title">
                            <button class="slds-button slds-section__title-action" aria-controls="content" aria-expanded="false">
                                <svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left" aria-hidden="true">
                                    <use xmlns:xlink="http://www.w3.org/1999/xlink" 
                                         xlink:href="/apexpages/slds/latest/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
                                </svg>XXXX</button>
                        </h3>
                        <div class="slds-section__content" id="content" aria-hidden="true" >
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" >ABC</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.ABC}" styleClass="slds-input"/>
                                </div>
                            </div>                 
                            <div class="slds-form-element">
                                <label class="slds-form-element__label" ">XYZ</label>
                                <div class="slds-form-element__control">
                                    <apex:inputfield value="{!FF.XYZ}" styleClass="slds-input"/>
                                </div>
                            </div> 
....
</fieldset>
            </div>
I have tried to implement this solution with jquery: http://www.minerva18.com/blog/creating-expandablecollapsible-lightning-design-sections-in-salesforce/#comment-1763 but the section open only for a few second and close again and the screen jump to the top of the page (I am using Chrome). 

I have also tried other solutions such as
<script type="text/javascript">
    function toggle_visibility() {
   var e = document.getElementById('content'); 
          if(e.style.display == 'none')
          e.style.display = 'block';
       else
          e.style.display = 'none';
    }
</script>

adding onclick="toggle_visibility();" on the button
or
function showContent() {
   {
        document.getElementById('content').style.visibility="visible";
    }
    else
    {
        document.getElementById('content').style.visibility="hidden";
    }
}
or
$(function () { 
    $('content').on('click', function (e) {
        var menuItem = $( e.currentTarget );

        if (menuItem.attr( 'aria-expanded') === 'true') {
            $(this).attr( 'aria-expanded', 'false');
            $(this).attr( 'aria-hidden', 'true')
        } else {
            $(this).attr( 'aria-expanded', 'true');
            $(this).attr( 'aria-hidden', 'false')
        }
    });
});

using jquery: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

But nothing is working.
Any help will be greatly appreciated!
Sylvie
Hi,

Can anybody please help me in below query,

My requirment is, There are two objects Goal and related Actions. 
So On vf page I am displaying all goals and all Actions records but I want to give Link to Goal record and onClick of this fetch only related Action records and not all records. How to achieve this on VF?

Thanks
I have the following code that I want to trigger when a new Lead comes into the system.  The trigger will auto populate the "Child Exist" Lookup field on the Lead object if its email matches with a user in the Child object.  If the two emails match, I want to have the Parent_Customer_ID__c of the Child user to auto-populate into the Child Exist field on the Lead.  If there is no match, it can be left blank.

trigger LeadExist on Lead (before insert) {

    Set<String> EmailId = new Set<String>();
    Map<String,String> MapuserId = new Map<String,String>();
    List<Child__c> usrlist = new List<Child__c>(); 
    for(Lead ld : trigger.new)
    {
        If(ld.Email != null)
        {
            EmailId.add(ld.Email);
        }
    }
    
    If(EmailId.size() > 0)
    {
        usrlist = [Select Parent_Customer_ID__c, Email__c from Child__c Where Email__c IN: EmailId];     
    }    
    if(usrlist.size() > 0)
    {
         for(Child__c c : usrlist)
        {
            if(!MapuserId.containsKey(c.Email__c))
            {
                MapuserId.put(c.Email__c, c.Parent_Customer_ID__c);  
            }
            
        }
    }
    
    for(Lead ld : trigger.new)
    {
        ld.Email= MapuserId.get(ld.Child_Exist__c);   
    }

}



Currently, I'm able to save the trigger and create a test lead & child.  However, when I save the test Lead, the email address is not being saved -- once I update the lead after it has been created, the email address will save.  The Parent_Customer_ID__c still won't auto populate.  Any help here will be greatly appreciated!
Hello 

I've built a VF page along with a controller extension where the user is able to delete a record via an action button. I've set the chosen record id to go to my controller and from there the controller deletes the the record via a DML Statement. What I'm struggling with is writing the test code for it as every delete resource I've found has failed. Or I've written it incorrectly.

I would be grateful for some assistance on that last bit of my test class. Here's my code below:

*****VG PAGE*****
<apex:page standardController="Opportunity" extensions="ClaimAndExtensionsROR" title="SIPP Claim Internal Questionnaire - Previous Claim Details " sidebar="false" showHeader="false">
<br>
<div style="text-align:center;font-size: 30px;">
<apex:outputlabel value="SIPP Claim Internal Questionnaire - Previous Claim Details"/>
</div>
</br>
<apex:pageMessages />
<apex:form >
<script type="text/javascript">
function CloseWindow()
{
window.top.close();
UpdateOpener();
}
</script>

<apex:pageBlock mode="mainDetail">
<apex:pageBlockButtons location="Bottom" >
<apex:commandButton action="{!save}" value="Save Changes" />
<apex:commandButton action="{!save}" value="Save and Close" status="closer" oncomplete="CloseWindow();" />
<apex:actionStatus startText="(Saving... Window will close shortly)" stopText="" id="closer"/>
</apex:pageBlockButtons>
</apex:pageBlock>

<apex:pageBlock title="Pensions" tabstyle="SIPP_Operator__c">
<apex:outputPanel id="PensionMessage">
<apex:pageMessage summary="{!primarymsg}" severity="error" strength="3" rendered="{!primarymsgck}" />
</apex:outputPanel> <div align="center" draggable="false" >
<apex:commandButton action="{!newPensions}" value="New Pension" rendered="{!ISNULL(Opportunity.SIPP__c)}" rerender="PensionsList"/> </div>
<apex:outputPanel id="PensionsList">
<apex:repeat value="{!Pensions}" var="pen" >
<apex:pageBlockSection columns="1" title="Pension {!pen.Name}" collapsible="true">
<apex:pageBlockSectionItem >
<apex:pageBlockSection columns="2">
<apex:pageBlockSection columns="1">
<apex:outputField value="{!pen.Person_Account__c}"/>
<apex:inputField value="{!pen.SIPP_Provider__c}"/>
<apex:inputField value="{!pen.Date_SIPP_opened__c}" />
<apex:inputField value="{!pen.Pension_Category__c}"/>
<apex:inputField value="{!pen.Pension_Type__c}" />
</apex:pageblockSectionItem>
<apex:commandButton value="Delete Pension" action="{!deletePensions}" rendered="{!ISNULL(Opportunity.SIPP__c)}" rerender="PensionsList, PensionMessage">
<apex:param name="PensionsIdent" value="{!pen.id}" assignTo="{!chosenPensionsId}"/> <!-- id goes to the controller --->
</apex:commandButton>
</apex:pageBlocksection>
</apex:repeat>
</apex:outputPanel>
</apex:pageBlock>


****THE CONTROLLER****

public class CtrlExtension {
   public ApexPages.StandardController std;

   public Id chosenPensionsId {get; set;}
   public List<SIPP_Operator__c> Pensions;

public ClaimAndExtensionsROR(ApexPages.StandardController stdCtrl){
        std = stdCtrl;
        List<string> fields = new list<string>{'AccountId', 'Previous_Relevant_Claim__c', 'StageName', 'Opportunity_Sub_Stage__c', 'SIPP__c', 'Previous_Relevant_Claim__r.SIPP__c', 'Previous_Relevant_Claim__r.Financial_Advice__c', 'Total_Compensation_Payable__c', 'Previous_Relevant_Claim__r.Introducer_Agent__c', 'Introducer_Agent__c'};

        if(!Test.isRunningTest())    
           {
        stdCtrl.addFields(fields);    
         }
    }

    public Opportunity getOpportunity()
    {
     return (Opportunity) std.getRecord();
    }

public void newPensions()
    {
      if (updatePensions())
       {
           SIPP_Operator__c pen=new SIPP_Operator__c(Person_Account__c = getOpportunity().Accountid);   
           insert pen;      
            
           Pensiontoinsert = pen.id;
           
          Pensions=null;

       }
    }

public void deletePensions()
    
    {
       if (updatePensions())
       {
          if (null!=chosenPensionsId)
          {
             SIPP_Operator__c pen = new SIPP_Operator__c(Id=chosenPensionsId);
              try{
              delete pen;
              }
              catch (System.DMLException e)
              {  
               primarymsgck = true;
               primarymsg = 'Error - You cannot delete a Pension that is already associated with a claim. Please inform your Salesforce Administrator.';
              }
        
           // null the contacts list so that it is rebuilt
              Pensions=null;
              chosenPensionsId=null;
          }
       }
    }

****TEST CLASS****

@isTest
public class ClaimAndExtensionsRORTestClass {

    Static ClaimAndExtensionsROR clext;


Account testacc = new Account();
        testAcc.LastName = 'test';
        testacc.Email_Address__c = 'alex@brangaene.com';
        testacc.PersonEmail = 'alex@brangaene.com';
        testacc.RecordTypeId = '01258000000VBdv';
        insert testacc;
        
        SIPP_Operator__c pen = new SIPP_Operator__c();
        pen.Person_Account__c = testacc.Id;
        insert pen;
        clext.newPensions();

        PageReference pref = Page.SIPP_Claim_Internal_Questionnaire_PRC;
        pref.getParameters().put('id', opp.id);
        test.setCurrentPage(pref);
        ApexPages.StandardController con = new ApexPages.StandardController(opp);
        clext = new ClaimAndExtensionsROR(con);

//Testing deletion
pen.id = clext.chosenpensionsId;
​delete pen

Clext.deletePensions();
}


Many thanks
Alex

 
I'm stuck.  I've created a custom VF page that lists some records. 

I want to include the ListView select option so the user can pick some of them and update them, List this....

User-added image
How do I get the checkbox to work for a cutom VF page??
Can you please provide some code