• Chamil Madusanka
  • PRO
  • 3102 Points
  • Member since 2011
  • Senior Software Engineer
  • Dazeworks Technologies (pvt) Ltd


  • Chatter
    Feed
  • 102
    Best Answers
  • 5
    Likes Received
  • 1
    Likes Given
  • 88
    Questions
  • 705
    Replies
I want get the approvaler id in trigger. after the user submit the records to approval.  Could someone can help me. and i attached my trigger code as below, very apprecaiate if someone can help. thanks a lot!

User-added image

trigger Promo_ItemList_af_Up on Campaign (before update) {
  set<id> set_campId = new set<id>();
  String APIName = '';
  String APIType = 'Checkbox;';
  Map<id,Decimal > Map_setp = new Map<id,Decimal>();
  Map<Id,String>  Map_APIupdate = new Map<Id,String> ();
  Map<Id,Id>  Map_CurrentApprovaler = new Map<Id,Id> ();
  List<Campaign> List_update;
   ID recordTypeId = Schema.SObjectType.Campaign.getRecordTypeInfosByName().get('Internal propose item approval promotion').getRecordTypeId();
   System.debug('Get Record type id========' + recordTypeId);//只适用于record type为Item的 // recordtype name =Internal propose item approval promotion
   for(Campaign cm:trigger.new){
       if(cm.recordtypeId == recordTypeId){
            set_campId.add(cm.id);//把campain 封装到set里面
            Map_setp.put(cm.id, cm.CurrentApprovalStep__c);  //对应的审批步骤和campain做一个绑定,用来判断是否是有新的审批步骤,从而确定是否需要暴露新的字段给用户操作
        }
   }
   //下面获取需要暴露的字段API名字
   if(set_campId.size()>0){  
        integer currentStep =0;  
       for(ProcessInstance pi:[Select p.TargetObjectId, p.Status, p.Id, (Select Id, StepStatus,OriginalActorId, ActorId,Actor.UserRole.Name From Steps) step From ProcessInstance p where TargetObjectId =:set_campId and Status = 'Pending']){
          currentStep= pi.Steps.size();
           
           String Label = pi.Steps[currentStep -1].Actor.UserRole.Name;
           //System.debug('GET actor name Label======' +Label );
           // System.debug('pi.Steps ========= ========= ===== ======= ===== ======= ===== ======= ===== === ===== ======='+ pi.Steps.size() + '===currentStep======'+currentStep);
         if(Map_setp.get(pi.TargetObjectId) != currentStep){ //当有新的step的时候才做更新,如果是相等的情况下,则跳过。
              APIName = PromoUtils.TransferLabelToAPI(Label,'Promotion_Account_List__c');//调用公共方法转换label为API名字
             // System.debug('APIName ===== ===== ===== ===APIName== ===== ===== ======='+ APIName);
              Map_APIupdate.put(pi.TargetObjectId,APIName);//封装成map,然后再查询出campain的字段,并更新campain字段
              Map_CurrentApprovaler.put(pi.TargetObjectId,pi.Steps[currentStep -1].OriginalActorId);
              Map_setp.put(pi.TargetObjectId,pi.Steps.size());           
           }
        }
   }
   if(Map_APIupdate !=null && Map_APIupdate.size()>0){
       
           for(Campaign cm: trigger.new){
           
                cm.PromoField__c =cm.PromoField__c + Map_APIupdate.get(cm.id);
                  cm.PromoFieldType__c =cm.PromoFieldType__c + APIType;
                  cm.CurrentApprovaler__c = Map_CurrentApprovaler.get(cm.id);
                  cm.CurrentApprovalStep__c = Map_setp.get(cm.id);
           }
   }
 
}
Hi, 

I am trying to display the account details ( name, address, phone ) for the account selected in picklist. I have written the code for picklist as below. Any help is appreciated. 

<apex:page Controller="accountcontroller" showHeader="false">
    <apex:form>
        <apex:pageBlock title="Display Account Details: ">
            
            <apex:pageBlockSection>
            <apex:outputLabel value="Account Name: " />
            
            <apex:selectlist value="{!accid}" size="1" >
                <apex:selectOptions value="{!accountnames}" />
                <apex:actionSupport event="onchange" rerender = "display"/>
            </apex:selectlist>
            </apex:pageBlockSection>
            
        <apex:pageBlockSection title = 'Account Details'>
            
        </apex:pageBlockSection>    
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller 

public class accountcontroller {

    public string accid {get; set;}
    
    public list<selectoption> getaccountnames() {
        
        list<selectoption> accoptions = new list<selectoption>();
        for (account acc : [select id, name from account]){
            accoptions.add(new selectoption(acc.id, acc.name));
        }  
        return accoptions;
    } 
}

Thank you,
Satya
Hi,
I have three objects.i.e. Car, Driver and Booking. Booking has Master-Detail relationship with the Car and Driver Objects. OWD of the Car is public Read/Write and for Driver it is Read only.
In such scenario, how the visibility and secuity setting of Booking will behave in the application.

Regards
Priyank
I want to integrate sales force integration in asp.net and i need support please help me 

Hi everyone,  I have a VF report that I have made the pulls together a single conceptual record based on information in mutiple different SObjects. I wrote this controller class to feed the report, and it works and does exactly what I need. However, report takes between 20 to 30 seconds to run because the query is seriously not optimized (written that way to avoid hitting governor limits)- sometimes we even get timeout errors and have to wait until another time to run the report.

What I'm trying to do is come up with a way to recode this so that it is more efficient and we don't timeout without hitting governor limits.  I'm not looking for someone to recode it for me, but if anyone has any thoughts on how to do this, I'd really appreciate hearing it!

Thanks in advance!

public class DiaperReportController 
{ 
   public List<DiaperReportDummy> results {get;set;}

   public DiaperReportController()
   {
       results = getResults();
   }

   public DiaperReportDummy[] getResults() 
   { 
      results = new List<DiaperReportDummy>();
      
      //query for all the data 
      Date d = System.today() - 59; //will get all ongoing diaper people who havent gotten a donation in 60 days
      Contact[] allContacts = [select Name, Phone, OtherPhone, Contact_Info_Notes__c, Description, Diapers_Needed__C, Diaper_Size__c, Diaper_Size_Date__c, AccountId, Id, npe01__Primary_Address_Type__c, MailingStreet, MailingCity, MailingState, MailingPostalCode, npe01__Secondary_Address_Type__c, OtherStreet, OtherCity, OtherState, OtherPostalCode from Contact where (npo02__LastCloseDate__c < :d or npo02__LastCloseDate__c = null) and (Diapers_Needed__c = True or Num_Diapers_Dependents__c > 0) order by MailingPostalCode];
      Dependent__c[] allDependents =  [select Contact__c, Name, Diapers__c, Diaper_Size__c, Diaper_Size_Date__c, Gender__c, Age__c from Dependent__c where (Contact__r.Diapers_Needed__c = True or Contact__r.Num_Diapers_Dependents__c > 0)]; 
      Opportunity[] allOpptys = [select Account.Id, CloseDate, Amount, Description, Name, RecordTypeId, Campaign.Id from Opportunity where Is_Last_Donation__c = True and Contact_Is_Ongoing_Diapers__c = True and RecordTypeId = '012i0000000RGFh'];
      OpportunityLineItem[] allOLIs = [select Opportunity.Id, Description, Product2.Name, Quantity, TotalPrice from OpportunityLineItem where Opportunity.Is_Last_Donation__c = True and Opportunity.Contact_Is_Ongoing_Diapers__c = True and Opportunity.RecordTypeId = '012i0000000RGFh'];
      
      //find all the related data and put into dummy class 
      for(Contact c: allContacts) 
      {
      Dependent__c[] lstDeps = new List<Dependent__c>();
      OpportunityLineItem[] lstOLIs = new List<OpportunityLineItem>();
      Opportunity lastopty;
      
         //get the related Dependents 
         for(Dependent__c dep: allDependents) 
         { 
           if(dep.Contact__c == c.id) 
            { 
               
               lstDeps.add(dep);    
            } 
         }
         //get the most recent sent donation
         for(Opportunity opp: allOpptys)
         {
             if (opp.AccountId == c.AccountId)
             {
                 lastopty = opp;
                 break;
             }
             else
             {
                 lastopty = null;
             }
         }
         //get the products of the most recent sent donation- if there is one
         if (!(lastopty == null))
         {
             for(OpportunityLineItem oli: allOLIs)
             {
                 if (oli.OpportunityId == lastopty.Id)
                 {
                     lstOLIs.add(oli);
                 }
             }
         }
         
         //create the Dummy class and add to the result list 
         results.add(new DiaperReportDummy(c, lstDeps, lastopty, lstOLIs)); 
         
      } 
      return results; 
   }
   
   //Inner class to hold relevant details for each Contact
   class DiaperReportDummy 
   { 
       public Contact contact { get; set; }  
       public Dependent__c[] dependents { get; set;} 
       public Opportunity opportunity {get;set;}
       public OpportunityLineItem[] opptylineitems {get;set;}
       
       public DiaperReportDummy(Contact con1, Dependent__c[] dep1, Opportunity opp1, OpportunityLineItem[] oli1) 
       { 
          this.contact = con1; 
          this.dependents = dep1;
          this.opportunity = opp1; 
          this.opptylineitems = oli1;
       } 
   }

}

 
Hi I have a scheduler class which implements Schedulable and in the execute method I am executing a batch using 
SynchronizerBatch batch = new SynchronizerBatch(UserInfo.getSessionId(),query);
Database.executeBatch(batch,1);

How do I schedule this scheduler class every 30 minutes in salesforce?
I want to use of migration tool in salessforce>
 I want to know use of migation tool in salesforce.
I'm not sure how to align the radio button text. My VF code and the output are as below . The itemlable text aligns under the radio button if its too long. I need text to align under text and  not under radio button. Any suggestions ?

Thanks.
 
<apex:selectRadio value="{!searchCategory}"  style="width:350px;" layout="pageDirection" id="theRadio" >
    <apex:selectOption itemValue="Accepted" itemlabel=" I acceptI acceptI acceptI acceptI acceptI acceptI acceptI acceptI acceptI acceptI accept"  />
    <apex:selectOption itemValue="Declined" itemlabel=" I decline this invitation"/>
     
</apex:selectRadio>
User-added image
 
  • January 15, 2015
  • Like
  • 0

I have a VF Extension class with subclass, that has a void method.

 

public with sharing class myWizard {

    public myWizard(ApexPages.StandardController stdController) {
        ...
    }

        public List<listMap> getHierarchy() { 
            ... 
            return returnList;
        }


        // ------------------------------------------------------
        // Custom class for the Gantt Chart Projects
        // ------------------------------------------------------
            public class listMap {
                
                public listMap(...) {              
                   instantiateValues();
                }
                
                private void instantiateValues() {
                   ...
                }
                
                public void addChild() {
                    try {
                        ...
                    } catch (Exception e) {
                        if(e.getTypeName() != 'System.DmlException') {
                            this.myRecord.addError(e.getMessage());
                        }
                    }
                }
                
                
            }

            
}

 

When the void method (addChild) from my VF Page, I want to return an error for an Exception. Is there a way I can do this?

 

 

I have a trigger which calls a class method, now inside the class i need to send message.

 

Eg:

 

Trigger: calling class Testclass

class: Testclass(){

if(somecondition)

{

from here i want pass messsage to trigger.

}

 

  • March 06, 2013
  • Like
  • 0

Hi

 

   i want to add records through VF page to Standardobjects using buttons(newContact) and it is stored using Controllers not using the StandardControllers.....

 

 

 

Thanks

========

VenkatSforce89

hi,

 

I want display LinkedIn connections for the matching business in salesforce.

when user select one company popup is open in that popup i want to display linkedin profile of that business.
so give me solution.

 

Thanks

prashant

<apex:page sidebar="false"  standardController="Business_Status_Report__c" extensions="BSRData"  tabStyle="Business_Status_Report__c">
<script>
 function setFocusOnLoad() {}
</script>
   <apex:form >
   <apex:outputText >From Date :</apex:outputText>
 
   <apex:inputField value="{!bsrObj1.Date__c}"/>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   
   <apex:outputText >To Date :</apex:outputText>
   <apex:inputField value="{!bsrObj2.Date__c}"/>
    <br/><br/>
   <apex:commandButton value="Generate Report" action="{!getData}"/><br/> <br/>

    <apex:pageBlock >
     <apex:pageBlockTable value="{!bsr1}" var="b">
       <apex:column headerValue="CreatedByName">
       <apex:outputLink >{!b.CreatedByName__c}</apex:outputLink>
      </apex:column>  
     
      <apex:column headerValue="BSR Name">
       <apex:outputLink >{!b.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Account Name">
      <apex:outputLink  >{!b.Account__r.Name}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Main Contact">
      <apex:outputLink >{!b.Contact__c}</apex:outputLink>
      </apex:column>
      <apex:column headerValue="Date">
      <apex:outputText >{!b.Date__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Status">
      <apex:outputText >{!b.Status_Update_Notes__c}</apex:outputText>
      </apex:column>
      <apex:column headerValue="Type">
      <apex:outputText >{!b.Type__c}</apex:outputText>
      </apex:column>
     </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>
</apex:page>

-------------------
public class BSRData  
{
  public List<Business_Status_Report__c> bsr1 { set; get; }
  public Business_Status_Report__c bsrobj1;
  public Business_Status_Report__c bsrobj2;
 
     public Business_Status_Report__c getBsrObj1()
    {
     if (bsrobj1 == null)
     {
      bsrobj1 = new Business_Status_Report__c();
      return bsrobj1;
     }
     else
       return bsrobj1;
    }
    
   public Business_Status_Report__c getBsrObj2()
    {
     if (bsrobj2 == null)
     {
      bsrobj2 = new Business_Status_Report__c();
      return bsrobj2;
     }
     else
       return bsrobj2;
    }

    public BSRData(ApexPages.StandardController controller) {
   
    }

 public List<Business_Status_Report__c> bsr { set; get; }
 public BSRData()
 {
 
 }
 public void getData()
 {
  if ( bsrobj1.Date__c != null && bsrobj2.Date__c != null)
   {
     
       Datetime dt = bsrobj1.Date__c;      
       Date dates = dt.date();       
    
       Datetime dt1 = bsrobj2.Date__c;    
       Date dates1 = dt1.date();
       

       if ( Date.valueOf(String.valueOf(dates)) > Date.valueOf(String.valueOf(dates1)) )
       {   
       
       }
      else
       {      
        System.debug('I am in else block');
       
        bsr1 = [SELECT CreatedByName__c,Account__r.Name,Name,Agency__c,BSR_Name__c,Contact__c,CreatedById,Date__c,Status_Update_Notes__c,Type__c FROM Business_Status_Report__c where CreatedDate__c >=: Date.valueOf(String.valueOf(dates)) and CreatedDate__c <=: Date.valueOf(String.valueOf(dates1)) order by CreatedById ];                
       }
    }
 }

 

By clicking the output link have to display particular record of that standard page. how to display that standard record page by clicking the command link can any one help on this.
}

  • February 14, 2013
  • Like
  • 0

I have developer edition account. I am implementing customer portal as stated in this ( https://na6.salesforce.com/help/doc/en/salesforce_customer_portal_implementation_guide.pdf ) guide. To enable customer portal, we need to set some user permissions like 'customize application', 'manage users' etc. How to set those permissions?

  • February 13, 2013
  • Like
  • 0

Hello,

 

I have an inputField set to a lookup relationship of type Contact. When the lookup button next to the inputField is pressed, it returns every contact that matches up with the name entered. I want to limit the results of that search to contacts with a specific account value. Basically what I'm trying to accomplish is to allow the user to select the contact record of the person that is escorting a visitor into our workplace. It wouldn't make sense that they could select someone that doesn't work at the company as an escort.

 

Can I do this in some way?

 

I thank anyone that can help.

Hello.  

 

I'm trying to modify to code from force.com cookbook, found here,  to render the page detail or related list, based on the user selection of the drop-down field.   I added the drop-down list, but not sure how to grab the selected value and render the outputPanels.   I'm new to VisualForce developement, any assistance is very much appreaciated.

 

My VF page:

<apex:page controller="contactController" showHeader="true" tabStyle="Contact">
<apex:form >

    <select id="selection">
      <option value="Detail">Detail</option>
      <option value="List">List</option>
    </select>

  
    <apex:dataTable value="{!contacts}" var="c" cellpadding="4" border="1">
      <apex:column >
        <apex:facet name="header"><b>Name</b></apex:facet>
        
        <apex:commandLink reRender="detail">{!c.name}
          <apex:param name="id" value="{!c.id}"/>
        </apex:commandLink>
      </apex:column>
      
      <apex:column >
        <apex:facet name="header"><b>Account Name</b></apex:facet>
        {!c.account.name}
      </apex:column>
    </apex:dataTable>
  </apex:form>
  
  <apex:outputPanel id="detail" >
    <apex:detail subject="{!contact}" title="false" relatedList="false"/>
  </apex:outputPanel>
  
  <apex:outputPanel id="list">
     <apex:relatedList list="ActivityHistories"  subject="{!contact}"/>
  </apex:outputPanel>  
  
</apex:page>

 Controller:

 

public class contactController {

   
   public List<Contact> getContacts() {
      return [SELECT Id, Name, Account.Name, Phone, Email
              FROM Contact
              ORDER BY LastModifiedDate DESC LIMIT 10];
   }

  
   public Contact getContact() {
      Id id = System.currentPageReference().getParameters().get('id');
      return id == null ? new Contact() : [SELECT Id, Name
                                             FROM Contact
                                            WHERE Id = :id];
   }
   
}

 

I would like to have a page that allows for an Account creation. When user hits Save it'll redirect them to another VF page where they can add a contact, set an activity, and create a custom object record (note). The part I can't figure out is how to provide the id of the new account record to the redirected VF page. Any help?

 

 

  • February 05, 2013
  • Like
  • 0

Hi,

 

I have a vf page with this problem about security risk: Cross-site Scripting.

I have no idea how to solve it.

 

The red line is the part of my vf page where i have the problem:

 

<apex:pageblocktable value="{!accsandtmember}"  var="accdet">

<apex:column headervalue="ID" style="{!accdet.Otra_informaci_n__c}">

 

I take the Otra_informaci_n__c value from a method in an apex class.

 It's got to be something simple. Any help will be appreciated.

 

 

  • September 04, 2012
  • Like
  • 0

Hello All, I am trying to create a VFPage for Accounts and show it's related Contacts. i am getting the following error-

 

System.QueryException: List has no rows for assignment to SObject Class.practiseOneController.getAccount: line 5, column 1

  Please find below VF Page-

<apex:page controller="practiseOneController" tabStyle="Account">
<apex:pageBlock title="Hello {!$User.FirstName}!!!">
You belong to {!account.name} Account.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:dataTable value="{!account.contacts}" var="contacts" cellpadding="4" border="1">
<apex:column value="{!contacts.FirstName}" headerValue="FirstName"/>
<apex:column value="{!contacts.LastName}" headerValue="LastName"/>
</apex:dataTable>
</apex:pageBlock>
 
</apex:page>

  Apex Class-

 

public class practiseOneController
 {
    public Account getAccount()
    {
        return [select id,Name,(select id,firstname,lastname from Contacts limit 5) from Account where id=
                 :System.currentPageReference().getParameters().get('id')];
    }

}

please help me in this and pls suggest how can we avoid this type of errors while creating pages and classes 

 

Thanks for your help.

 

Thanks,

JaanVivek

<apex:page standardController="Opportunity" showHeader="false" sidebar="false" extensions="testsavenclose" tabStyle="Opportunity">

<apex:form id="form">
<apex:pageBlock id="results" >
<apex:pageMessages id="msg" />

<apex:pageBlockButtons >
<apex:commandbutton action="{!save}" id="savebutton1" value="Save"/>


<apex:commandbutton action="{!cancel}" id="cancelbutton" value="Cancel" onclick="return confirmCancel();" immediate="true"/>
<script language="JavaScript" type="text/javascript">
function confirmCancel()
{
    var isCancel = confirm("Are you sure you wish to cancel?");
    if (isCancel)
    {
    window.top.close();
    return true;
    }
    return false;
}
</script>

</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Header" collapsible="false" id="pbs1">
<apex:outputField value="{!opp.Name}" id="abc"/>
</apex:pageBlockSection>
<apex:pageBlocksection id="pbs2">
<apex:pageBlock title="Opportunity Line Items" mode="edit" id="pb">
<apex:pageBlockTable value="{!opp.OpportunityLineItems}" var="oppitems" align="center" id="main">
<apex:column value="{!oppitems.PricebookEntry.Name}" />
<apex:column headerValue="Line Description">
<apex:inputField value="{!oppitems.Description}"/>
</apex:column>
<apex:column headerValue="Date" >
<apex:inputField value="{!oppitems.ServiceDate}"/>
</apex:column>
<apex:column headerValue="Quantity">
                                <apex:inputField value="{!oppitems.Quantity}" rendered="{!NOT(oppitems.HasSchedule)}"/>
                                <apex:outputField value="{!oppitems.Quantity}" rendered="{!oppitems.HasSchedule}"/>
                            </apex:column> 

</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Hi,

 

Please find the below code:

 

 Apex Code:

 

public class testsavenclose
{
public Opportunity opp{get;set;}
public testsavenclose(ApexPages.StandardController stdController)
{
 opp = [SELECT Amount, Id, Name,CloseDate,StageName,Account.Name,Probability, (SELECT Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate,HasSchedule,HasRevenueSchedule FROM OpportunityLineItems order by PricebookEntry.Name) FROM Opportunity where id =:ApexPages.currentPage().getParameters().get('id')];
}
public PageReference save()
{
update opp.opportunitylineitems;
return null;
}
public PageReference cancel()
{
return null;
}
}

 Steps to get exception:

 

Edit the Quantity field on opportunity line item page block table. Give value "0.00" in quantity field.Click on save.

It throws following exception.

 

System.DmlException: Update failed. First exception on row 0 with id 00k90000005VlrnAAC; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: Quantity (quantity must be nonzero): [Quantity]

 

how do i handle this exception.

 

 

Hi All,  

What is the best way to deploy profiles from a sandbox to production, when the profiles in production changed since the last refresh & profiles in sandbox gained additional settings since the refresh?

How to 'add up' to prod without overwriting the existing settings?

Thanks in Advance

Hi All,

 

What is the best way to deploy profiles from a sandbox to production, when the profiles in production changed since the last refresh & profiles in sandbox gained additional settings since the refresh?

How to 'add up' to prod without overwriting the existing settings?

 

Thanks in Advance

Hi All,

What is the best way to deploy profiles from a sandbox to production, when the profiles in production changed since the last refresh & profiles in sandbox gained additional settings since the refresh?

How to 'add up' to prod without overwriting the existing settings?

Thanks in Advance

Hi All,

 

I know that administrators can create up to 300 sharing rules per object, including up to 50 criteria-based rules.

My question is,

Is there any limit for Apex sharing?

 

Thanks in Advance!

Hi All,

Is there way to restrict the download file(shared file) in chatter?

Thanks in Advance!!

Hi All,

 

Is there way to restrict the download file(shared file) in chatter?

 

Thanks in Advance!!

How to capture details of any person from web and it should directly go in to account in salesforce like web-to-Lead?

Hi All,

 

How to send chatter private messages from Apex code? Any example code ?

 

Thanks in Advance

Hi All,

 

I want to create a managed package as a release. But, when I'm going to create it, it says, "Released to upload an upgradeable version. After upload, some attributes of Salesforce components are locked."

 

What type of components will be locked after upload?

Where will be the locked components (In Development Org OR in uploaded package)?

After create a managed release package, Can I do further developments in normal way?

 

Thanks in Advance!

Hi All,

 

In winter 12 release note has mentioned following,

Total number of executed code statements is 1,000,000 instead of 200,000.

 

But in debugs logs, it is still 200,000.

 

Number of SOQL queries: 3 out of 100
  Number of query rows: 13 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 33 out of 200000
  Maximum heap size: 0 out of 3000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

How to increase that?

 

Thanks in advance

Hi All,

 

I have successfully created a managed package for my current project. That managed package is included few approval processes in apex classes. There are no any issue in Test coverage. But, when I going to install that package to another organization, it triggered few errors from test classes (These errors never triggered when running test classes in previous org). Following are the issues,

 

1. Apex Classes(01pU0000000QCbP)

test_developmentplanmanagerextension.testSearchDevelopmentPlans()

System.DmlException: Process failed. First exception on row 0; first error:

NO_APPLICABLE_PROCESS, No applicable approval process found.: []

(Talent2o)

 

External entry point

 

2. Apex Classes(01pU0000000QCbO)

test_developmentplanextension.testSearchDevelopmentPlans()

System.DmlException: Process failed. First exception on row 0; first error:

NO_APPLICABLE_PROCESS, No applicable approval process found.: []

(Talent2o)

 

External entry point

 

3. Apex Classes(01pU0000000QCb1) testtrainingplanextention.testgetTPbyId()

System.DmlException: Process failed. First exception on row 0; first error:

NO_APPLICABLE_PROCESS, No applicable approval process found.: []

(Talent2o)

 

External entry point



*******************************************

This is the code segment of approval process which related to the PROBLEM 3.

 

if(emp2.size() > 0)
        {            
            idL.add(emp2[0].User__c);            
            System.Debug('approvalId :: '+approvalId);            
            System.Debug('idL :: '+idL);             
             
            if(tempTP.Status__c == 'New')
            { 
                Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
                req1.setComments('Submitting request for approval.');
                req1.setObjectId(approvalId);
                req1.setNextApproverIds(idL);
                Approval.ProcessResult result = Approval.process(req1); 
            
            
            if(result.isSuccess())
            {
           
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Approval Sent');
                ApexPages.addMessage(myMsg);         
            
            }
            }else
            {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'User have not any approver');
            ApexPages.addMessage(myMsg);
           
            }
       }    

 

How can I resolve this problem?

 

Thanks in Advance!

Hi All,

 

I having some issue with lookup field in visualforce. In one of my visualforce page has three lookup fields. The lookup window doesn't close after select a record. All three lookup fields has same issue. I thought, it is a javascript issue. So  I removed javascripts and css in that VF page and check it. But It didn't  work. Any idea why this is happens?

 

Thanks in Advance

Hi all,

 

Is there any possibility to create (dynamically create) custom fields in apex code?In that case we have to access schema. isn't it? How can i do this?

 

Thanks in Advance

Hi All,

 

I want to create a output link  with some value and it needs to have an action method to control that link. That mean, according to the return value of action method, output link will be populate. How can  I do this?

 

Thanks in Advance!!

Hi All,

 

Salesforce has nice popup feature as in followin link.

 

http://www.4shared.com/photo/FfIWpT_i/popup.html

 

Can we use this feature in our own visualforce page?

 

Thanks in Advance

Hi All,

 

How can we add users into an existing Queue or newly created (in apex code) Queue in apex code?

Then I want to use that queue for an approval process which also created in apex code. How can I resolve this issue?

 

 

Thanks in Advance

Hi All,

 

I want to create a approval process and assign some specific users to that approval process in apex class. I tried as follows;

 

Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval.');
req1.setObjectId(newDPCD.id);
req1.setNextApproverIds(idList); //idList is a list of contact ids

 

But It didn't work. The main issue is I want to assign specific users dynamically.

 

Is there any work around? If someone have any idea or sample code please share it.

 

Thanks in Advance

Hi,

 

How can I get current user Id in apex code? I tried {!$User.Id}. But it didn't work. How to resolve it?

 

Thanks in Advance

When I add workflow with time triggers to the package, I got "Workflow rules with Time Triggers cannot be uploaded to the AppExchange" after pressing "upload". All other workflow can.
Any Workaround for this issue?

 

Thanks in Advance

Hi All,

 

I have create a managed package and install that in different environment. After the installation I could realize that the all the workflows had been deactivated in installed environment. So, how can I automatically activate then at installation?

Or any workaround for stop the deactivation when create the package?

 

Thanks in Advance

Hi All,

 

How can we add users into an existing Queue or newly created (in apex code) Queue in apex code?

Then I want to use that queue for an approval process which also created in apex code. How can I resolve this issue?

 

 

Thanks in Advance

HI All,

 

How to create a fomula field for my age field ? It will be calculated by using the Date_of_Birth__c field. I have a fomula.

 

IF(MONTH(TODAY())>MONTH(DOB_API),YEAR(TODAY())-YEAR(DOB_API),IF(AND(MONTH(TODAY())=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)),YEAR(TODAY())-YEAR(DOB_API),(YEAR(TODAY())-YEAR(DOB_API))-1))  

 That's from Ankit's blog. But I don't know how to use it and where to use it.

 

Thanks in Advance

Hi All,

 

Can we use Bulk API in APEX class?

 

Thanks in Advance

I want to populate treeview same as Organization's Role Hierarchy in salesforce. Add/Edit features should be threre. But this tree view should not reflect the Organization's Role Hierarchy.

 

Example:

 

Admin1
|------ Manager1
--|------ ReportingPerson1
--|------ ReportingPerson2
|------ Manager2
--|------ ReportingPerson3
--|------ ReportingPerson4
--|------ ReportingPerson5
|------ Manager3
--|------ ReportingPerson1
--|------ ReportingPerson6
--|------ ReportingPerson7
--|------ ReportingPerson8
|------ Manager4
--|------ ReportingPerson2
Admin2
|------ Manager5
--|------ ReportingPerson1
--|------ ReportingPerson2
|------ Manager6
--|------ ReportingPerson3
--|------ ReportingPerson4
--|------ ReportingPerson5

 

--Chamil Madusanka

Hi,

I'm new to salesforce, APEX and SOQL. I want to know, how can we update some record using SOQL in APEX code?

Hi All,
 
I am new in salesforce . i write a code to insert  a record in custome object and used system.debug to check the code .

Public Class inserrecordincampsite
{
Public Static Void InsertRecord()
{
Campsite__c Camp = new Campsite__c  (Name='Mayank',Description__c='xyz');
insert Camp;
system.debug('Record Inserted'  +Camp)
}}

after exeuction of code through anonymous window , debug message generated is blank and showing 0 DML operation performed.

can anyone suggest wht's wrong in code .
Hello -

I'm sure I'll say wrong, but, I need help in building a Custom Controller for a Visualforce page I created so my sales team can see a 1/2 dozen charts on a custom dashboard.  One of the charts my boss wants is a gauge.  Unfortunately, since I had to create the gauge inside the dashboard and not on the report itself, I will need to build the gauge using a Custom Controller.  This is way over my head and everyone else I've talked to.  Is anyone able to babystep me through the formatting and order of things? 

Thanks to anyone who can help me get this thing built.
Kay
 
Hello,

I am looking to see if it is possible to create a Button on an object that when clicked it will direct to the most recent item in the recent items list in the side panel. Does anyone know if this is possible. Any help would be appreciated.

Thanks!

Hi All,

I've got a Visualforce page that shows a table with numbers in it. Numbers are calculated in the controller and saved in variables like Decimal division.
Then are called in the visualforce with {!division}.
The division can have as result a positive number, 0 or impossible. In the controller, when the division is impossibile, it is forced in the variable division the number -1.
I would like to show in the visualforce the symbol " - " only when {!division}​ is equal to -1. I cannot do it in the controller because it is Decimal.

Any idea?

Thankyou!!

I have two VisualForce pages that I've created that deal with a custom object.  The first page has several search criteria.  The second page is called from the first and is designed to show the details of a selected record.

How do I pass the ID from the Search page to the Detail page?  The code snippit I'm using is:
                        <apex:outputLink value="{! URLFOR('/apex/boleteDetailView', bol.Id) }">
                            View
                        </apex:outputLink>
This opens the detail page fine, but I don't see any evidence that the ID has been passed.

I've also tried creating a function in the controller that would hold the ID (so I could get around this problem), but that doesn't seem to work either (probably due to a misunderstanding of the way the apex:outputLink tag works).
                        <apex:outputLink value="{! URLFOR('/apex/boleteDetailView', bol.Id) }">
                            <apex:actionSupport action="{!setSelectedID}" event="onclick">
                                <apex:param name="ID" value="{!bol.ID}"/>
                            </apex:actionSupport>
                            View
                        </apex:outputLink>


Also, once I am on the detail page, how do I retrieve the details for the selected record?  Is there a way to retrieve the custom object's fields/values directly (like you can with the standard controller) or will I also need to create a function in the custom controller to get the detail records?
I want get the approvaler id in trigger. after the user submit the records to approval.  Could someone can help me. and i attached my trigger code as below, very apprecaiate if someone can help. thanks a lot!

User-added image

trigger Promo_ItemList_af_Up on Campaign (before update) {
  set<id> set_campId = new set<id>();
  String APIName = '';
  String APIType = 'Checkbox;';
  Map<id,Decimal > Map_setp = new Map<id,Decimal>();
  Map<Id,String>  Map_APIupdate = new Map<Id,String> ();
  Map<Id,Id>  Map_CurrentApprovaler = new Map<Id,Id> ();
  List<Campaign> List_update;
   ID recordTypeId = Schema.SObjectType.Campaign.getRecordTypeInfosByName().get('Internal propose item approval promotion').getRecordTypeId();
   System.debug('Get Record type id========' + recordTypeId);//只适用于record type为Item的 // recordtype name =Internal propose item approval promotion
   for(Campaign cm:trigger.new){
       if(cm.recordtypeId == recordTypeId){
            set_campId.add(cm.id);//把campain 封装到set里面
            Map_setp.put(cm.id, cm.CurrentApprovalStep__c);  //对应的审批步骤和campain做一个绑定,用来判断是否是有新的审批步骤,从而确定是否需要暴露新的字段给用户操作
        }
   }
   //下面获取需要暴露的字段API名字
   if(set_campId.size()>0){  
        integer currentStep =0;  
       for(ProcessInstance pi:[Select p.TargetObjectId, p.Status, p.Id, (Select Id, StepStatus,OriginalActorId, ActorId,Actor.UserRole.Name From Steps) step From ProcessInstance p where TargetObjectId =:set_campId and Status = 'Pending']){
          currentStep= pi.Steps.size();
           
           String Label = pi.Steps[currentStep -1].Actor.UserRole.Name;
           //System.debug('GET actor name Label======' +Label );
           // System.debug('pi.Steps ========= ========= ===== ======= ===== ======= ===== ======= ===== === ===== ======='+ pi.Steps.size() + '===currentStep======'+currentStep);
         if(Map_setp.get(pi.TargetObjectId) != currentStep){ //当有新的step的时候才做更新,如果是相等的情况下,则跳过。
              APIName = PromoUtils.TransferLabelToAPI(Label,'Promotion_Account_List__c');//调用公共方法转换label为API名字
             // System.debug('APIName ===== ===== ===== ===APIName== ===== ===== ======='+ APIName);
              Map_APIupdate.put(pi.TargetObjectId,APIName);//封装成map,然后再查询出campain的字段,并更新campain字段
              Map_CurrentApprovaler.put(pi.TargetObjectId,pi.Steps[currentStep -1].OriginalActorId);
              Map_setp.put(pi.TargetObjectId,pi.Steps.size());           
           }
        }
   }
   if(Map_APIupdate !=null && Map_APIupdate.size()>0){
       
           for(Campaign cm: trigger.new){
           
                cm.PromoField__c =cm.PromoField__c + Map_APIupdate.get(cm.id);
                  cm.PromoFieldType__c =cm.PromoFieldType__c + APIType;
                  cm.CurrentApprovaler__c = Map_CurrentApprovaler.get(cm.id);
                  cm.CurrentApprovalStep__c = Map_setp.get(cm.id);
           }
   }
 
}
SELECT Id, AccountId, (SELECT Id,Core__c FROM Properties__r where Core__c !=null ) FROM Contact WHERE Accountid IN : accountIds

This is my Query..Any limit i have to put in inner query....

This is my trigger.......
trigger updateAccCorefrmProperty on Property__c (after insert, after update, after delete) {


      Set<Id> accountIds = new Set<Id> ();                   
      Map<id,List<Property__c>> mpAccProperty = new  Map<id,List<Property__c>>();     
      Set<String>  PropCores= new Set<String>();
      List<Account> accountListToUpdate = new List<Account>();
      List<Account> accountListToUpdate2 = new List<Account>();
      set<id>  contactId= new set<id> ();
      set<id>  accountwithoutProp = new set<id> ();
                
        if(Trigger.IsInsert ) {
            for(Property__c prp: [SELECT Contact__c, core__c, Contact__r.Accountid from Property__c WHERE Id IN : Trigger.new] )
            {
                if(prp.Contact__c!=null && prp.core__c !=null && prp.Contact__r.Accountid !=null)
                accountIds.add(prp.Contact__r.Accountid);
            }
        
        }
        
        if( Trigger.IsUpdate ) {
            for(Property__c prp: Trigger.new )
            {
               if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c); 
            }
            
            for(Property__c prp: Trigger.old)
            {
               if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c); 
            }
            
             for(Contact con: [select id, AccountId from Contact where id in : contactId and AccountId != null])
                accountIds.add(con.Accountid);
       
        }
        
        
        
        if(Trigger.IsDelete ){
            for(Property__c prp :Trigger.old){
                if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c);        
            }

            for(Contact con: [select id, AccountId from Contact where id in : contactId and AccountId != null])
            accountIds.add(con.Accountid);
        }    
   
        for(Contact conT: [SELECT Id, AccountId, (SELECT Id,Core__c FROM Properties__r where Core__c !=null limit 2000) FROM Contact WHERE Accountid IN : accountIds]){
            if(conT.Properties__r != null && conT.Properties__r.Size() > 0) {
                if(mpAccProperty.containskey(cont.AccountId)){
                List<Property__c> lstProperty= mpAccProperty.get(cont.AccountId);
                lstProperty.addall(conT.Properties__r);
                }
                else{
                mpAccProperty.put(cont.AccountId,conT.Properties__r);}  
            }
            system.debug('wwwwwwwconT.Properties__r.Size()www'+conT.Properties__r.Size());
            if( conT.Properties__r.Size() == 0) {  
                accountwithoutProp.add(cont.AccountId);
                system.debug('wwwwwwwwww'+accountwithoutProp);
            } 
        }
        
        for(Id accId: mpAccProperty.keyset()){
            if(accountwithoutProp.contains(accId))
                accountwithoutProp.remove(accid);
        }
        
           
        String new_propCore;
        for(Id accId: mpAccProperty.keyset()){
            new_propCore='';
            PropCores.clear();
            for(Property__c prop: mpAccProperty.get(accId))
            PropCores.add(prop.core__c);

            new_propCore=String.Join(new List<String>(PropCores),',');
            
            if(!String.IsBlank(new_propCore))
            accountListToUpdate.add(new Account(Id=accId,core__c=new_propCore));         

        }
        if(accountwithoutProp!=null && accountwithoutProp.size()>0){
            for(Id accwithoutPropId : accountwithoutProp){
                accountListToUpdate.add(new Account(Id=accwithoutPropId,core__c=''));
            }
        }
        
        
        //if(accountListToUpdate2.size()>0)
        //update accountListToUpdate2;

        if(accountListToUpdate.size()>0)
        update accountListToUpdate;//update Impacted account 
        
        
}



>>>>>>>>>>>>>

ny using batch m updating Properties...and this trigger fires
Hi, 

I am trying to display the account details ( name, address, phone ) for the account selected in picklist. I have written the code for picklist as below. Any help is appreciated. 

<apex:page Controller="accountcontroller" showHeader="false">
    <apex:form>
        <apex:pageBlock title="Display Account Details: ">
            
            <apex:pageBlockSection>
            <apex:outputLabel value="Account Name: " />
            
            <apex:selectlist value="{!accid}" size="1" >
                <apex:selectOptions value="{!accountnames}" />
                <apex:actionSupport event="onchange" rerender = "display"/>
            </apex:selectlist>
            </apex:pageBlockSection>
            
        <apex:pageBlockSection title = 'Account Details'>
            
        </apex:pageBlockSection>    
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller 

public class accountcontroller {

    public string accid {get; set;}
    
    public list<selectoption> getaccountnames() {
        
        list<selectoption> accoptions = new list<selectoption>();
        for (account acc : [select id, name from account]){
            accoptions.add(new selectoption(acc.id, acc.name));
        }  
        return accoptions;
    } 
}

Thank you,
Satya
 Lets say i have four dates , how to find which one is the latest date using apex ?
or
 If we add dates to a List of dates can we sort ?
 
Hi Team,

I have few doubts in salesforce. Please clarify me ASAP.

    1. Does salesforce support multi tenant applications? Means I have created a a vehicle related application in SFDC.
        I want to handle this app with two seperate companies (Company A and Company B). The data and every activity should be separate.
        Is there any simple way in SFDC or shall I do manually?
        
    2. Can I create dynamic objects? Means Need to create an object with fields in run time.Is that possible?
    
    3. Let me know the pricing details of SFDC? If I develop or maintaining  a small app I can pay less cost Otherwise my app is big
     I can Pay huge amount. Could you please clarify the pricing in SFDC?

Error: Unknown property 'zipcodes2.pcode

vf code:- 








apex code:-
public class zipcodes2 {
List pcode{set;get;}

public zipcodes2()
{
pcode = [SELECT Id FROM Postal_codes__c] ;

    }

}

 
How will we implement the controlling and dependent pick list functionality using VF?
So the use case is as follows:  On the Account page there is the territories field that for a given account will show whatever territories are assigned to that particular Account.  So, as an example, Acme Corp. may show a territories field of National, Northeast, and NY on the page.  However, in reporting, SFDC returns for the Account by territories report individual line items for Acme Corporation for National, Northeast and NY respectively.  The consumer requirement here is to report on territories for Accounts in the same manner they are displayed on the Account page: all concatenated within the same field.

So given there is no way to do this via formula, I investigated doing via Apex.  It turned out that 4 objects would be needed to produce the territory relationship for Accounts: Account, AccountShare, Group, & Territory.  However, the kicker is that basically 3 separate queries are needed to accoumplish this.  The parent-child relationships are not accessble in SOQL, and of course you can't do joins between objects like you can in T-SQL unless there is that parent-child relationship.

So I attempted a batch job to somehow put this together.  However, my approach is wrong in that I am running into query limits with my compiled code, and I am not sure how to structure this to get around the problem.  Below is my compliled code that errors out.  Guidance would be appreciated.  Thanks in advance, TDM
 
global class batchTerritoryCustomUpdate implements Database.Batchable<sObject>

{
    //The purpose of this batchClass is to return concatenated Territory Names to the Account object custom field Account_Territory__c for reporting purpose specific to user requests
    
    global Database.QueryLocator start(Database.BatchableContext BC)
    
    {  
        String query = 'Select Id From Account';
        return Database.getQueryLocator(query);      // returns AccountId and UserOrGroupId for queries below.  

    }
    global void execute(Database.BatchableContext BC, List<Account> scope)
    {
        Integer i = 0;
                
        for(Account updateAccount : scope)
        {    
            String acctID = updateAccount.Id;
            String relId;
            String groupId;
            String matchinAcctId;
            List <AccountShare> aShare = new List <AccountShare>();
            aShare = [Select AccountId, UserOrGroupId from AccountShare Where RowCause = 'Territory' and AccountId =: acctID];
            Do{
            for(AccountShare ash : aShare)  // setup accounts for update
            { 
                groupId = ash.UserOrGroupId;
                List <Group> pickGroup = new List<Group>();
                pickGroup = [Select RelatedId from Group where Type ='Territory' and Id =: groupId];
                
                For(Group selectGroup : pickGroup)  //loop through Group data
                {
                    
                    relId = selectGroup.RelatedId;
                    String terrName = '|';
                    List <Territory> terra = new List <Territory>();
                    terra = [Select Name from Territory Where Id =: relId];
                    for(Territory terraNova : terra)  //loop through Territory data
                    {
                        List <Account> matchAccount = new List <Account>();
                        matchAccount = [Select Id from Account where Id =: acctId];
                        For(Account finalAcct : matchAccount)
                        { 
                                terrName = terrName + terraNova.Name + '|'; 
                                matchinAcctId = finalAcct.Id;
                                finalAcct.Id = acctId;
                               
                            updateAccount.Account_Territory__c = terrName;  //write the concatenated territories to the custom Account field
                        
                        }
                     }
                 }
                
                
                }
            } while(matchinAcctId==acctId);
           update scope;
        }    
    }    
       
    global void finish(Database.BatchableContext BC)
    {
    }
    
    
}

 
Hi All,

Did anyone implement QR code scanner in Salesforce project?

What I need? If user scans the attached QR code, it should return the result after decode.

For e.g. If you scan the attached image (QR code) then it should return “ER-0000130”.

We are able to get the results from online demo’s, here is one example:http://dwa012.github.io/html5-qrcode/

However, after implementing code in SFDC, I am getting one or more errors. 

Please let me know if anyone implemented any QR code scanner in their project, with the instruction to implement.

Thank you.
Regards,
Paddy 
User-added image
How to achieve Collapsible functionality(Show Search / Hide Search) & multiple search filter criteria which looks like in above image?
<apex:pagemessages> not working in visualforce page.

Error with details directly redirected to new page
I want to show errormesage in standard error messagebox.
Below is the code details.

If the logedin user doesn't have FLS access then error message should get display on same page.
Visualforce Page:
 
<apex:pageMessages id="pmsg" />

<apex:pageBlock title="Cases">
   <apex:pageBlockButtons >
      <apex:commandButton value="Select "  onclick="return Test();" action="{!caseMethod}"  reRender="pmsg" />
   </apex:pageBlockButtons>

Controller Code:
if (!CaseComment.sObjectType.getDescribe().isDeletable()){
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'Insufficient access'));
          return null;
        }
 delete ChildComment;

 
I want to integrate sales force integration in asp.net and i need support please help me 

haiiiii.............

 

         I created one vf page {Search applicants}  in that i need    

InputFields{skill set,experience, expected salary, match()all ()any---->radio buttons}   

                                ________

                                | search    |     <---------- clicking on search records to be displayed.

                                --------------    

 

to get Input fields how could i write the controller code for that fields.

 

 Any one help me.............................