• 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
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