• Rockz
  • 91 Points
  • Member since 2013

  • Chatter
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 28



I'm on a project together Trigger on Task SObject in this class Trigger a call must be made according to the DevelopperName.
I can not encode the current recovery DevelopperName.
And how to test the current DelopperName ?

Thank you.

What is the purpsoe of custom settings & labels?

Hi Folks ,


Can any one help me out 


how to customize a code for an APPROVAL PROCESS through class or a trigger?



Thanks in Advance 


  • December 06, 2013
  • Like
  • 0
trigger ToDisplayMessage on NEWOPTION__c (after insert) {
    List<NEWOPTION__c> ls=Trigger.new;
    for(NEWOPTION__c nw:ls)
        if(nw.Opt__c == 'yes')
            if(nw.Primary_interest__c != null && nw.Secondary_interest__c !=null)
                if(ApexPages.currentPage() != null)
                    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.info,'I like '+nw.Primary_interest__c+' specifically ‘+nw.Secondary_interest__c'));


  • December 16, 2013
  • Like
  • 0

Hi Everyone,


getting the following error


Class.testvantage.MultiAdd.addMoreconst: line 51, column 1
Class.testvantage.MultiAdd.<init>: line 90, column 1


I wrote the Apex class for add and deleting the records in VF page.

When i tried to the save the page i get the following error.


###APEX CLASS############

public class MultiAdd

public List<contact> lstcontact = new List<contact>();
public List<Contact> contacts;
public ApexPages.StandardController std;

//list of the inner class
public List<innerClass> lstInner
{ get;set; }

//will indicate the row to be deleted
public String selectedRowIndex

//no. of rows added/records in the inner class list
public Integer count = 1;

////save the records by adding the elements in the inner class list to lstAcct,return to the same page
public PageReference Save()
PageReference pr = new PageReference('/apex/jqueryDoctorProfile');

for(Integer j = 0;j<lstInner.size();j++)


lstcontact .add(lstInner[j].acct);
upsert lstcontact;
return pr;

//add one more row
public void Add()
count = count+1;
public void addMoreconst()
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
List<Contact> lstCon = getContacts();

for(Contact c: lstCon){
objInnerClass = new innerClass(count);
objInnerClass.acct = c;
//add the record to the inner class list

}/* end addMore*/

/*Begin addMore*/
public void addMore()
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);

//add the record to the inner class list
}/* end addMore*/

/* begin delete */
public void Del()
system.debug('selected row index---->'+selectedRowIndex);
count = count - 1;

}/*End del*/

public MultiAdd(ApexPages.StandardController ctlr)

lstInner = new List<innerClass>();
selectedRowIndex = '0';

}/*End Constructor*/
public Account getAccount()
return (Account) std.getRecord();

/*Inner Class*/
public class innerClass
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount

public contact acct

/*Inner Class Constructor*/
public innerClass(Integer intCount)
recCount = String.valueOf(intCount);

/*create a new account*/
acct = new contact();

}/*End Inner class Constructor*/
}/*End inner Class*/
public List<Contact> getContacts()
{ if ( (null!=getAccount().id) && (contacts == null) )
contacts=[SELECT Id, Name, testvantage__TotalNumber__c , testvantage__DoctorDescription__c, LastName, FirstName FROM Contact WHERE AccountId = : getAccount().ID ORDER BY CreatedDate];
} return contacts;
}/*End Class*



/########VF PAGE##############

<apex:page StandardController="Account" extensions="MultiAdd" id="thePage">
<apex:form >
<apex:pageblock id="pb" >
<apex:pageBlockButtons >
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<apex:commandbutton value="Save" action="{!Save}"/>

<apex:pageBlockSection title="Account Details" collapsible="true" id="mainRecord" columns="2" >
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!Account.Type}"/>
<apex:inputField value="{!Account.BillingStreet}"/>
<apex:inputField value="{!Account.Industry}"/>
<apex:inputField value="{!Account.Phone}"/>

<apex:pageblock id="pb1">

<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:panelGrid columns="6">

<apex:panelGrid headerClass="Name">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>

<apex:panelGrid title="SPD" >
<apex:facet name="header">LastName</apex:facet>
<apex:inputfield value="{!e1.acct.LastName}"/>

<apex:panelGrid >
<apex:facet name="header">FirstName</apex:facet>
<apex:inputfield value="{!e1.acct.FirstName}"/>

<apex:panelGrid >
<apex:facet name="header">TotalNumber</apex:facet>
<apex:inputfield value="{!e1.acct.TotalNumber__c}"/>

<apex:panelGrid >
<apex:facet name="header">DoctorDescription</apex:facet>
<apex:inputfield value="{!e1.acct.DoctorDescription__c}"/>





Pl help me out





  • December 16, 2013
  • Like
  • 0

Hi How to disable/Enable custom buttons on case detail view.



i have one custom button on case detail view , it has to enable or disabel  based on some condition when case detail view loading .

Ex: when i click on case record it will open detail view that time only the custom button has to disable  based on user.




pls give me suggestions how to do.

public class checksobjectprofiles

public List<SelectOption> ListOfUser {public get; private set; }

public String selecteduserId { get; set; }

public string searchresult;
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public List <SelectOption> objectNames{public get; private set;}
public String selectedObject {get; set;}
public boolean updatecheck;
// public Boolean isUpdateable();

public checksobjectprofiles ()
objectNames = initObjNames();
ListOfUser= initListOfUser();

private List<SelectOption> initObjNames()
List<SelectOption> objNames = new List<SelectOption>();
List<String> entities = new List<String>(schemaMap.keySet());
objNames.add(new SelectOption( ' ' ,'---Select---'));
for(String name : entities)

objNames.add(new SelectOption(name,name));
return objNames;

private List<SelectOption> initListOfUser()
// String uid = UserInfo.getUserId();
List<User> thisUser = [select id, Username, profile.name from User where IsActive=true];
List<SelectOption> Ulist = new List<SelectOption>();
Ulist.add(new SelectOption( ' ' ,'---Select---'));
for(User u : thisuser )

Ulist.add(new SelectOption(u.Username ,u.username));
return Ulist ;

public void checkFields()

system.debug('$$$$$' + selectedObject);
list<string> lstFields = new list<string>();

list<string> sobjectfields = new list<string>();
Map <String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObject).getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values())
schema.describefieldresult fieldresult = sfield.getDescribe();

// system.debug('#######' + lstFields );

// system.debug('@@@@@@@@@@@@@@@@@@@'+selectedObject);

Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe();
Schema.DescribeSObjectResult r = gd.get(selectedObject).getDescribe();
String tempName = r.getName();

searchresult= 'select' + lstFields +'from' + 'tempName' + ' WHERE ' + ' Id =: selecteduserId ';

// return Database.query(searchresult);
if(searchresult != NULL )
updatecheck=searchresult.isUpdateable(); ============> here, iam getting an error please hepl me, how to solve solve it ...just user have access fields means enable checkbox in visaulforce page



I have two object.Training and training survey...training record lookup relationship with training
survey.training object have training start date custom field...training survey have traning__c
lookup field.Traing survey have survey type custom field.
Process: if training start date --today+1,today+2,today+3--will send trainingsurvey email (day 1
or day 2 or day3 )to corresponding taining object record.else will send drop training survey.i
have set formula field check box..day 1 flag,day3,day5--whenever flag true -i have created
schedule process...apex class will insert survey type under traning survey object .i have created
workflow email alert -when will u insert survey type will send corresponding survey to corresponding records.

MY APEX LOGIC for schedule process.

global class MyTrainingSurveyProcess implements Schedulable
    global void execute(SchedulableContext SC)
       // Sweep training object for day 2 , 3 & 5th day survey
       List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
                 ts.Survey_Type__c = 'Day1';
             if(tx.day3surveyflag__c == true )
                 ts.Survey_Type__c = 'Day3';
             if(tx.day5surveyflag__c == true )
                 ts.Survey_Type__c = 'Day5';
                 ts.Survey_Type__c = 'Dropped';
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
        if(ts2 != null )
           insert ts2;  
My requirement :
A)In case a past training survey was not created for a person and it is no longer within the 
timeframes specified..- will send training survey -when click list button.
B)If a Survey record has already been created for the specific Day, we just need to resend the 
existing survey record link..(purpose:survey was not filled by person within the 
timeframes specified)
Here i need manual list view button on training object.i want to have 4 buttons that represent each survey.when i click list button(day1,day3,day5,drop) cover above(A&B) two logic.
i know list button creation.
How to Calling Apex Class from List Custom Button?.Please give ur idea for Calling Apex Class from List Custom Button and how to cover above (A&B)two logic using apex class.Please give one example..

  • December 14, 2013
  • Like
  • 0





Test 1: Microsoft Excel VLOOKUP Function (or Google Spreadsheet VLOOKUP Function)

I've attached a document labeled "Waypoint Test Using VLOOKUP.xlsx". This document can be opened in Microsoft excel or Google spreadsheets. The document contains two tabs.
 - The first tab is labeled "City List". The "City List" tab includes a "Property Code" column and "City" column. 
 - The second tab is labeled "Zip Code List". The "Zip Code List" tab includes a "Property Code" column and a "Zip Code" column.
Please update the "City List" tab by adding a new column called "Zip Code". Populate the new "Zip Code" column with the "Zip Code" values from the "Zip Code List" tab by using the VLOOKUP function to references the "Zip Code" value that matches the "Property Code" on both tabs. The "Property Code" is the primary key used to migrate data from the "Zip Code List" tab and the "City List" tab.
Note that there are more records on the "City List" tab than the "Zip Code List" tab. This means that some "Property Codes" will not have a zip code. This is expected.
Save and respond back with updated excel file. If you do not have Microsoft excel, you may use Google spreadsheets.




I get the following error when running my test class: 

Error Message System.NullPointerException: Attempt to de-reference a null object Stack Trace Class.CloseDuplicateOpportunities.closeDuplicateOpportunities: line 22, column 1
Class.CloseDuplicateOpportunitiesTest.test1: line 27, column 1


I have come across this error message several times in the past, bu t cannot understand why it happens here.

It looks like the Profile is not retrieved when my method is called by the test class.

I would like to point out that it works perfect when doing tests manually.



Test Class:


public class CloseDuplicateOpportunitiesTest {

    @isTest(SeeAllData=true) static void test1() {
        //User oppOwner = [SELECT Id FROM User WHERE Name='NA BS User']; 

        Profile p = [SELECT Id FROM Profile WHERE Name='NA Telesales Rep']; 
        User oppOwner = new User(LastName='NA BS User', ProfileID=p.Id, Alias = 'standt', Email='standarduser@testorg.com', 
          EmailEncodingKey='UTF-8', LanguageLocaleKey='en_US', 
          LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles', UserName='dwqwdwqdqwdwqdqwefewgfe@testorg.com');
        insert oppOwner;  
        User u = new User(ProfileId = p.Id,Alias = 'standt', Email='standarduser@testorg.com', 
          EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
          LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles', UserName='standarsafdewqfewfweFuser@testorg.com');
        Account a = new Account(Name='a',BillingCountry='IE');
        insert a;
        Opportunity o1 = new Opportunity(Name='o1',CloseDate=System.Today(),AccountId=a.Id,OwnerId=oppOwner.Id,StageName='Engaged',Product_Target__c='Advanced');
        Opportunity o2 = new Opportunity(Name='o2',CloseDate=System.Today(),AccountId=a.Id,OwnerId=oppOwner.Id,StageName='Engaged',Product_Target__c='Advanced');
        insert o1;
        insert o2;
        System.runAs(u) {
        String finalMessage = CloseDuplicateOpportunities.closeDuplicateOpportunities(o1.Id);
        System.assertEquals(finalMessage, '1 similar opportunities have been closed in addition to this one' );






global class CloseDuplicateOpportunities{

   webService static String closeDuplicateOpportunities(Id contextOppId) {
        Opportunity contextOpp;
        List<Opportunity> relevantOpps;
        String finalMessage;
        Profile userProfile = [SELECT Name FROM Profile WHERE Id = :Userinfo.getProfileId()];

        /*****************AUTHORIZED USER ************************/
        contextOpp = [SELECT Id,AccountId,Owner.Name FROM Opportunity WHERE Id=:contextOppId];
        } catch(Exception e){
        System.debug('The following exception has occurred while trying to get the context opp: ' + e.getMessage());
        if (   (userProfile.Name.equals('NA Telesales Rep') ||
                userProfile.Name.equals('NA Telesales Manager') ||
                userProfile.Name.equals('NA Territory Manager - Outbound')) && 
                contextOpp.Owner.Name == 'NA BS User' )
            List<Opportunity> oppsToUpdate = new List<Opportunity>();
            relevantOpps = [SELECT Id,StageName,Reason_For_Closed_Lost__c FROM Opportunity WHERE 
                AccountId = :contextOpp.AccountId AND
                IsClosed = false AND
                Owner.Name like 'NA BS User' AND
                Id != :contextOpp.Id AND 
                Product_Target__c INCLUDES ('Advanced','Express Checkout Shortcut (ECS)','Pro')];
            } catch(Exception e){
            finalMessage = 'No relevant opportunities have been closed because either none were found or an error has happened.';

            if(oppsToUpdate.size() > 0)
                for (Opportunity o : oppsToUpdate)
                 o.StageName = 'Closed Lost';
                 o.Reason_For_Closed_Lost__c = 'Close - TS Duplicate';

                System.debug('###########oppsToUpdate '+ oppsToUpdate);
                update oppsToUpdate;
                finalMessage = relevantOpps.size() + ' similar opportunities have been closed in addition to this one';
                } catch(Exception e){
                finalMessage = 'No relevant opportunities have been closed';

        /********************NON-AUTHORIZED USER *****************/
            finalMessage = 'No relevant opportunities have been closed because you do not have an authorized profile or the opportunity is not owned by NA BS User.';

     return finalMessage;





  • December 10, 2013
  • Like
  • 0



I want to get User level Salesforce Password policies fields such as


1) User password Expire in

2) Minimum password length. etc.


To enforce it on my custom password, whether it is following it or not? (In custom page with APEX and VF)


What objects are used for this, I have searched it, but couldn't found. Is there any API provided for this?


Thank you.


Warm Regards,

Amol Dixit.



I need to query records[soql] which starts with non-alphabet characters.


Please help me.


Suresh S

global class Integration {

 global class AllObjects {

     webservice string aName;
     webservice string aNum;

     webservice string cName

 global class Return {
     webservice string raName;

webservice static List<Return> Allobjectsmethod(List<AllObjects> a1List) {

 List<Account> accounts = new List<Account>();
 List<Contact> contacts = new List<Contact>();
 List<Return> returns = new List<Return);
 for(AllObjects a1 : a1List)
     Account a = new Account();
     a.Name = a1.aName;
     a.Number = a1.aNum;
     Contact c = new Contact();
     c.Name = a1.cName;
     Return r = new Return();
     r.raName = a.Name;

 // Bulk insert accounts
 insert accounts;

 // Assign contacts to accounts
 **for(Integer rowIdx = 0; rowIdx < accounts.size(); rowIdx++)** // error occur point
     contacts[rowIdx].AccountId = accounts[rowIdx].Id;      

 // Bulk insert contacts
 insert contacts;

 return returns;



I'm on a project together Trigger on Task SObject in this class Trigger a call must be made according to the DevelopperName.
I can not encode the current recovery DevelopperName.
And how to test the current DelopperName ?

Thank you.

Hi All,


I am new to Integration part in Salesforce.I want to do Salesforce to Java Integration simple applns.Pls explain below 


!) What are the basic  things to do while integrating with Java?pls give steps..

2)Just i want to insert records in salesforce then it will automatically insert records into Java appln?

3)Which API i have to use for this integration(SFDC to Java)   SOAP or REST API ?





SanthanaKumar A




global class MainClass
global class RequestClass
webservice String errorMessage;

//Account Releated Fields

global Class AccountWrapper // Line9
webservice String accName;
webservice Integer accNumber;
webservice Id AccountId;
webservice List<AccountWrapper> accounts;
webservice List<ContactWrapper>;
webservice List<OpportunityWrapper>;

//Contact Releated Fields
//webservice String contactName;
global class ContactWrapper
webservice String clName;
webservice String cfName;


// Opportunity Releated Fields
global class OpportunityWrapper
webservice String oName;
webservice String ocDate;
webservice String oStage;
webservice List<ProductWrapper>;
// Quote Realeted Fields
webservice String qName;

// Product fields
global class ProductWrapper
webservice String productcode;
webservice String productName;
// boolean active;
webservice Integer quantity;
webservice Integer unitprice;
// QuoteItem Fields

webservice String qitemName;


webservice static ResponseClass behaviourOfWebService(RequestClass req)

List<Account> accountList = new List<Account>();
Account a;
for(AccountWrapper wrapper: req.accounts){
a = new Account();
a.Name = wrapper.accName;
a.AccountNumber =String.valueOf(wrapper.accNumber);
insert AccountList;

ResponseClass res = new ResponseClass();
res.resId = a.Id;
res.resName = a.Name;
res.cresName = c.FirstName;
// res.respId = p.Id;
return res;
return res;


What is the purpsoe of custom settings & labels?

Hi all,

I want to display Account History as a related list in Visual force page. I am trying below syntax

<apex:page standardController="Account">
        <apex:relatedList list="AccountHistory"/>

But it is giving error as 'AccountHistory' is not a valid child relationship name for entity Account '

Please let me know the correct syntax of API name for account history to display it as a related list.



Diff between Enterprise WSDl and Partner WSDL ?When we will use these WSDLs?Pls Explain...






Csv Error Invalid Csv FileFormat Please select a different file
com.sforce.async.CSVReaders$CSVParseException:Excceded number of records:
10002.Number of records should be less than or equal to 10001


I am updating data using dataloader i was geting this error can anybody help me



I written test class and coverage is 91%, i am trying to see while lines are not covered but not able to see developer console. 


is it salesforce bug or  i missed something


Thanks ,