• Piyush Sharma 6
  • NEWBIE
  • 33 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 7
    Replies
Hello,

Is there a way to know the exact logic behind Add Default Team button on Account Team Member related list on account. I have created a custom visualforce page and wants to extend this functionality.
On click on button takes to this url: 
https://xxxxxdev01xxxx.my.salesforce.com/opp/addsalesteam.jsp?id=0012100000xxxxx&tid=005&_CONFIRMATIONTOKEN=VmpFPSxNakF4T0MweE1pMHpNRlF4TVRvME9EbzBNUzQ1TmpsYSxwek4zT2xGYnBFVjFLaUVIeEZPNWpsLE1tVTBOekUy
In above url Id and tid values are clear but I am not able to obtain _CONFIRMATIONTOKEN.

I tried by getting its value from url and setting it in page reference when user selects Add Default Team, using below code:
 
confirmationToken = ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN');
 
PageReference pgRef = new PageReference('/opp/addsalesteam.jsp');
pgRef.getParameters().put('id', accId);
pgRef.getParameters().put('tid', '005');
pgRef.getParameters().put('_CONFIRMATIONTOKEN', confirmationToken);
But I am getting below error: 
Stale Session Exception
The page you submitted was invalid for your session. Please refresh your page and try again. 

I am not sure what I am missing. Any thoughts?

Thanks
PS
 
Hi,

I have a requirement to display lead even after it is converted. We can see converted lead details from report but business wants to see them in something similar to Lead Detail page. Is there any option by which we can achieve this. Also please suggest any possible customization that we can do for this. 

Note: This solution is needed in Salesforce Lightning.
Hi
I want to display a quick action which is visible only to syatem admin for all stages but visible to normal user during a specific stage.
I cant use page layouts since the requirement is based on the lead status as well
Can anyone please suggest how can this be achieved on Lead'd detail page in Lightning view.

Thanks
I have a scenario where the user has to slect the account and redirect to a new vf page but I am not able to pass the account id so that the new page displays the details about the selected account. I have posted the vf page and controller code.

Thanks in Advance!
 
<apex:page controller="pagination" tabStyle="Account">
<apex:form >
  <apex:pageBlock >
  Page No: {!pageNo} <br/><br/>
      <apex:pageBlockTable value="{!Accounts}" var="a" rows="10">
          <apex:column >
              <apex:actionSupport action="{!account}" event="onclick">
              <apex:outputtext value="{!a.id}"/>
              </apex:actionSupport>
          </apex:column>
          <apex:column >
          {!a.name}
          </apex:column>
      </apex:pageBlockTable>
  </apex:pageBlock>
  <apex:commandButton value="Previous" action="{!previous}" disabled="{!!hasPrevious}"/>
  <apex:commandButton value="Next" action="{!next}" disabled="{!!hasNext}"/>
  </apex:form>
</apex:page>
public class pagination {
    Public Integer size{get;set;}
    Public Integer noOfRecords{get; set;}
    Account accnt;
    Public Integer pageNo {
    get {
            if(pageNo == null) {
                return 1;
            }
        return pageNo;
        }
    set;
    }
    public ApexPages.Standardsetcontroller setcon {
    get {
        if(setcon == null) {
        size = 5;
        string querystring = 'select name,type from account order by name';
        setcon = new ApexPages.Standardsetcontroller(Database.getQueryLocator(querystring));
        setcon.setpagesize(size);
        noOfRecords = setcon.getResultSize();
        }
        return setcon;
    }
    set {}
    }
    public list<Account> getAccounts () {
        List<Account> accntList = new List<Account>() ;
        for(Account a: (List<Account>) setcon.getRecords()) {
            accntList.add(a);
        }
        return accntList;
    }
    public void setAccount (Account accnt) {
        this.accnt = accnt;
        System.debug('@@'+accnt);
    }
    public void next() {
        pageNo = pageNo+1; 
        setcon.next();
    }
    public void previous() {
        pageNo = pageNo-1;
        setcon.previous();
    }
    public Boolean hasNext {
        get {
            return setCon.getHasNext();
        }
        set;
    }
    public boolean hasPrevious {
        get {
            return setCon.getHasPrevious();
        }
        set;
    }
    public PageReference account() {
        //Account accnt;
        PageReference ref = new PageReference('/apex/wizard2?id='+accnt);
        ref.setRedirect(true);
        return ref;
    }
}


 
Hello
I have created a vf page to display graph but it only displays page blocks. The graphs are not created.
I checked soql query in Graph controller is returning values.
Not sure where I am going wrong.

VF Page:
<apex:page controller="Graph" >
    <apex:pageblock title="Accounts and their Amount" >
        <apex:chart height="250" width="350" data="{!PieData}">
            <apex:pieSeries tips="true" dataField="data" labelField="name"/>
            <apex:legend position="bottom"/>
        </apex:chart>
    </apex:pageblock>                  
    <apex:pageblock title="Accounts and their Amount" >
        <apex:chart height="250" width="350" data="{!PieData}">
            <apex:axis type="Numeric" position="left" fields="data" title="Years of experience"/>    
            <apex:axis type="Category" position="bottom" fields="name" title="Account"/>            
            <apex:barSeries orientation="vertical" axis="left" xField="name" yField="data"/>
        </apex:chart>
    </apex:pageblock>    
</apex:page>

Controller:
public class Graph {
    public List<PieWedgeData> PieData{get;set;}
    public List<PieWedgeData> getPieData()
    {  
        List<PieWedgeData> data = new List<PieWedgeData>();
        List<Account> acc = new List<Account>();          
        String sql = 'SELECT Name, Total_Opportunity_Amount__c FROM Account where Total_Opportunity_Amount__c != null';
        acc = Database.Query(sql);
        System.debug('@@'+ acc);
        for(Account temp:acc)
        {           
            data.add(new PieWedgeData(temp.Name,temp.Total_Opportunity_Amount__c));
        }
        System.debug('@@ '+data);
        return data;
    }      
    // Wrapper class  
    public class PieWedgeData
    {  
        public String name { get; set; }  
        public Decimal data { get; set; }          
        public PieWedgeData(String name, Decimal data)
        {  
            this.name = name;  
            this.data = data;  
        }  
    }
}
 
Hi
I have created a trigger but it giving me this error on Line:7.
Error:Incompatible element type Id for collection of Account
Please help.
trigger getOptyAmt on Opportunity (after insert, after update) {
    	List<Account> accntId = new List<Account> ();
    	Integer optyAmt;
    	Account accId;
    for(Opportunity opty: Trigger.new) {
        if(opty.AccountId != null) {
            accntId.add(opty.AccountId);
        }
    }
    for(Opportunity opty: [select Id from opportunity where account in: accntId]) {
        optyAmt = opty.Amount;
        accId = opty.AccountId;
        accId.Total_Opportunity_Amount__c =+ optyAmt;
    }
}

 
I have written below trigger to update case status when case is assigned from Queue to a user, but it is giving a null pointer exception @line 10.
The requirement is to update case status when case is assigned from a queue to a user.
 
trigger updateCase on Case (before update) {
    List<Case> newCaseList = new List<Case>() ;
    System.debug('@@newCase' + newCaseList);
    for(Case c : Trigger.new) {
        System.debug('@@@' + c);
		//just add few more null checks- 
		If(c.status!=null && c.OwnerID.getsobjecttype()!=null)
		{
			if(c.OwnerID.getsobjecttype() == User.sobjecttype && c.Status == 'New') {
					if(Trigger.oldMap.get(c.Id).Owner.getsobjecttype() != User.sobjecttype) {
							c.Status = 'Working';
							newCaseList.add(c);
						}
				System.debug('@@' + newCaseList);
			}
		}
    }
    if(newCaseList.size() > 0) {
        insert newCaseList;
    }
}

 
Hi
I have created a trigger but it giving me this error on Line:7.
Error:Incompatible element type Id for collection of Account
Please help.
trigger getOptyAmt on Opportunity (after insert, after update) {
    	List<Account> accntId = new List<Account> ();
    	Integer optyAmt;
    	Account accId;
    for(Opportunity opty: Trigger.new) {
        if(opty.AccountId != null) {
            accntId.add(opty.AccountId);
        }
    }
    for(Opportunity opty: [select Id from opportunity where account in: accntId]) {
        optyAmt = opty.Amount;
        accId = opty.AccountId;
        accId.Total_Opportunity_Amount__c =+ optyAmt;
    }
}

 
Hi All, 
I am trying to hide the Upload Files button in the Files Related list. 
I want to force users to use Chatter Feed to upload files rather than use Upload Files option. 

Any workarounds? 

Regards,
I have a button that calls a VisualForce page that I would like to overwrite the field level security i.e. fields that are read only will become editable in the VisualForce Page. I have created a the Class that acts without sharing and queries the relevant fields and returns them. The class and Visualforce page will both load, but the fields are still ready only. Any help would be appreciated!
Class
public without sharing class MASIExtension {

        private final CustomObject__c INC;

    // The extension constructor initializes the private member
    // variable INC by using the getRecord method from the standard
    // controller.
    public MASIExtension(ApexPages.StandardController stdController) {
        this.INC = (CustomObject__c)stdController.getRecord();
    }
    CustomObject__c I = [SELECT id, Name, customfield1__c, customfield2__c, 
                                            FROM CustomObject__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];



    public CustomObject__c getRecordName() {
        return I;
    }

    public PageReference save(){
        update I;
        return null;
    }
}

Visualforce page
<apex:page standardController="CustomObject__c" extensions="MASIExtension">
    <apex:form >
        <apex:pageBlock title="Enter MASI">
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>                
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="Legal Guardian" > 
                <apex:inputText value="{!CustomObject__c.customfield1__c}"/>            
                <apex:inputField value="{!CustomObject__c.customfield2__c}"/>
                <apex:inputField value="{!INC.Name_of_legal_guardian__c}"/>      
            </apex:pageblockSection>                
              
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
I have a scenario where the user has to slect the account and redirect to a new vf page but I am not able to pass the account id so that the new page displays the details about the selected account. I have posted the vf page and controller code.

Thanks in Advance!
 
<apex:page controller="pagination" tabStyle="Account">
<apex:form >
  <apex:pageBlock >
  Page No: {!pageNo} <br/><br/>
      <apex:pageBlockTable value="{!Accounts}" var="a" rows="10">
          <apex:column >
              <apex:actionSupport action="{!account}" event="onclick">
              <apex:outputtext value="{!a.id}"/>
              </apex:actionSupport>
          </apex:column>
          <apex:column >
          {!a.name}
          </apex:column>
      </apex:pageBlockTable>
  </apex:pageBlock>
  <apex:commandButton value="Previous" action="{!previous}" disabled="{!!hasPrevious}"/>
  <apex:commandButton value="Next" action="{!next}" disabled="{!!hasNext}"/>
  </apex:form>
</apex:page>
public class pagination {
    Public Integer size{get;set;}
    Public Integer noOfRecords{get; set;}
    Account accnt;
    Public Integer pageNo {
    get {
            if(pageNo == null) {
                return 1;
            }
        return pageNo;
        }
    set;
    }
    public ApexPages.Standardsetcontroller setcon {
    get {
        if(setcon == null) {
        size = 5;
        string querystring = 'select name,type from account order by name';
        setcon = new ApexPages.Standardsetcontroller(Database.getQueryLocator(querystring));
        setcon.setpagesize(size);
        noOfRecords = setcon.getResultSize();
        }
        return setcon;
    }
    set {}
    }
    public list<Account> getAccounts () {
        List<Account> accntList = new List<Account>() ;
        for(Account a: (List<Account>) setcon.getRecords()) {
            accntList.add(a);
        }
        return accntList;
    }
    public void setAccount (Account accnt) {
        this.accnt = accnt;
        System.debug('@@'+accnt);
    }
    public void next() {
        pageNo = pageNo+1; 
        setcon.next();
    }
    public void previous() {
        pageNo = pageNo-1;
        setcon.previous();
    }
    public Boolean hasNext {
        get {
            return setCon.getHasNext();
        }
        set;
    }
    public boolean hasPrevious {
        get {
            return setCon.getHasPrevious();
        }
        set;
    }
    public PageReference account() {
        //Account accnt;
        PageReference ref = new PageReference('/apex/wizard2?id='+accnt);
        ref.setRedirect(true);
        return ref;
    }
}


 
I have written below trigger to update case status when case is assigned from Queue to a user, but it is giving a null pointer exception @line 10.
The requirement is to update case status when case is assigned from a queue to a user.
 
trigger updateCase on Case (before update) {
    List<Case> newCaseList = new List<Case>() ;
    System.debug('@@newCase' + newCaseList);
    for(Case c : Trigger.new) {
        System.debug('@@@' + c);
		//just add few more null checks- 
		If(c.status!=null && c.OwnerID.getsobjecttype()!=null)
		{
			if(c.OwnerID.getsobjecttype() == User.sobjecttype && c.Status == 'New') {
					if(Trigger.oldMap.get(c.Id).Owner.getsobjecttype() != User.sobjecttype) {
							c.Status = 'Working';
							newCaseList.add(c);
						}
				System.debug('@@' + newCaseList);
			}
		}
    }
    if(newCaseList.size() > 0) {
        insert newCaseList;
    }
}