• ShivaKrishna(Freelancer)
  • 194 Points
  • Member since 2014
  • SFDC Freelancer || Developer || Administrator

  • Chatter
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 75
I have an requirement that i need to retrive both name and password data from sobjecct which are given in vf page . I have write a soql query in apex controller like this way but it is working please suggest me 
select Rum_Name__c,Password__c from Registartion__c where Rum_Name__c = :rname,Password__c=:pwd;

Thanks in advance
Please help me getting open Activity list on visuaforce page..Here is my code.
// Page

<apex:pageBlock title="Open Activity" >
<apex:pageBlockTable value="{!ActivityList}" var="a">
<apex:column value="{!a.OpenActivities }"/>
</apex:pageBlockTable> </apex:pageBlock>

//Controller method

public List<Lead_Inspector__c>getActivityList(){ List<Lead_Inspector__c> lst =[SELECT (SELECT ActivityDate, Description FROM OpenActivities ORDER BY ActivityDate ASC NULLS LAST, LastModifiedDate DESC      LIMIT 500)FROM Lead_Inspector__c WHERE id = :leadId ];
return lst; }
I have a requirement like hide/show custom button based on opportunity stagename.
1) Opportunity stagename is "Closed won" i want to enable cutom button while clicking this button it will redirect to vf page.
2)Not "Closed Won" hide the custom button like stand functionality

Any one suggest using on click java script

I am trying to create a trigger on the Task object that will allow me to pull the MobilePhone value from the associated Lead or Contact and populate a custom field on the Task.  I am using this article as a reference: citing source article

Here is the trigger as I currently have it in my sandbox:
Trigger TaskBefore on Task(before insert, before update){
    Map<Id, List<Task>> whoIds = new Map<Id, List<Task>>{};

    For (Task t : trigger.new)
        If(t.WhoId != null){
            List<Task> tasks = whoIds.get(t.WhoId); //this should be t.WhoId (not task.WhoId)
            If (tasks == null){
            tasks = new List<Task>{};
            whoIds.put(t.WhoId, tasks);

    For (Lead ld : [Select Id, Name, MobilePhone where Id in :whoIDs.keySet()])
        For(Task t : whoIds.get(ld.id))
            t.Mobile__c = ld.Mobile;

    For(Contact con : [Select Id, Name, MobilePhone where Id in :whoIds.keySet()])
        For(Task t : whoIds.get(con.id))
            t.Mobile__c = con.Mobile;


However it is yielding the error: Error: Compile Error: unexpected token: where at line 14 column 49

Have I misunderstood the syntax here?  I would really appreciate some help!


I had this working the other day, then yesterday I erased my work thinking the client wanted something else (rookie mistake). Now I need to put it back and I can't get it to work! I think my brain got its wires crossed in the last two days...

  • Visualforce page for the Order object
  • On the page, created a list with checkboxes displaying the names of the Assets related the the same Account as the Order
  • On save, upsert the Order with values in the Order form and for each selected Asset in the list, I am trying to create a record passing info from the Asset
What's happening:
  • Doesn't seem to be looping through all selected checkboxes. Looking at the debug logs, only one checkbox is ever picked up.
Visualforce Page:
<apex:page standardController="Order" showHeader="false" sidebar="false" extensions="TestExtension">   

    <apex:form id="theForm">
        <apex:pageBlock title="Service Request">
            <apex:pageBlockButtons location="both">
                <apex:commandButton action="{!processSelected}" value="Continue"/>                        
            <apex:pageBlockSection >
                <apex:inputField value="{!Order.BillToContactId}"/>
                <apex:outputField value="{!Order.OwnerId}"/>      
                <apex:inputField value="{!Order.Service_initiated_By__c}" style="width: 150px;"/>                
                <apex:outputField value="{!Order.Account.Name}"/>
                <apex:inputField value="{!Order.Description}" label="Problem Description"/>
                <apex:outputField value="{!Order.Sold_Order__c}"/>                                                
   <apex:pageBlockSection title="Select Installed Products" columns="1">
                <apex:pageBlockTable value="{!assets}" var="a" id="table" width="1000px;" >
                    <apex:column >
                        <!-- This is our selected Boolean property in our wrapper class -->
                        <apex:inputCheckbox value="{!a.selected}"/>
                    <apex:column value="{!a.asset.Name}"/>
                    <apex:column value="{!a.asset.Original_Order_Variant_Number__c}"/>
                    <apex:column value="{!a.asset.Install_Date__c}"/>
                    <apex:column value="{!a.asset.Location_Details__c}"/>
Apex Code: 
public with sharing class TestExtension {
    private final Order o;
    public List<aAsset> assetList {get; set;} 
    public TestExtension(ApexPages.StandardController stdController) {
        this.o = (Order)stdController.getRecord();       
    public List<aAsset> getAssets() {
        if(assetList == null) {
            assetList = new List<aAsset>();
            for(Asset a: [SELECT Id, Name, Product2Id, Original_Order_Variant_Number__c, Install_Date__c, Location_Details__c FROM Asset WHERE AccountId = :o.AccountId]) {
                assetList.add(new aAsset(a));
        return assetList;
<!--This is where I'm saving and trying to insert. I know I'm missing something obvious in making sure it loops through everything-->

    public PageReference processSelected() {
            List<Asset> selectedAssets = new List<Asset>();
            for(aAsset aAsst: getAssets()) {
                if(aAsst.selected == true) {
            System.debug('These are the selected Assets...');
            for(Asset asset: selectedAssets) {
                Service_Request_Configuration__c src = new Service_Request_Configuration__c ();
                src.Account__c = o.AccountId;
                src.Installed_Product_Asset__c = asset.Id;
                src.Installed_Product__c = asset.Product2Id;
                src.Order__c = o.id;
                insert src; 
                o.Service_Type__c = propPickValSelected;
                upsert o;
                PageReference pageRef = new PageReference('/apex/RMS_createServiceOrder4?id='+ o.Id + '&retUrl=' + o.Id);
                return pageRef;
        catch(Exception ex){
        return null;
    public class aAsset {
        public Asset asset {get; set;}
        public Boolean selected {get; set;}

        public aAsset(Asset a) {
            asset = a;
            selected = false;

Like I commented in the code, I'm fairly certain it's something obvious and simple I'm missing to get it looping through properly, but I have been staring at it too long and it's not jumping at me anymore. Any help would be much appreciated!


I'm working in the Reports & Dashboard module and got a little confused with regard to the 'Primary Object' and 'Related Object' as related to Record Type.  

In your example: 'Contacts and Accounts' which is the Primary Object and which is the Related Object?  The 'Getting Started with Reports and Dashboards' unit say one thing and the 'Using the Report Builder' say another.  They contradict each other.  Here are screenshots to help.

Getting Started with Reports & DashboardsUsing the Report Builder
Hello everyone,
I need to create a validation rule for this case,can i just use simple formule to solve this case.
Thank you

[Driving licence] Expiration date must be in future and a coherence control need to be done with [birthdate]
Hi Team,
I want To write This Trigger test class any one help me to how to write....
Approach:Write Custom Code in salesforce to stop deleting any event forcefully Through this event will not get deleted in salesforce even in outlook

- If someone need to really delete the event they need to click on extra checkbox and save then delete in salesforce
 pls tell me is it correct trigger to this Apporch

Note: Pls Test Class Should Be Bulkify........
trigger avoidDeletionEvent on Event (before delete) {
for(event e:trigger.old)
        e.addError('You do not have permission to delete this event');

  • August 08, 2017
  • Like
  • 0
Hi Expert

I have case , when i change the case status to CLOSE then , 
Date/Time Closed filed does not showing any cloase date of case. How to achive this.User-added image



I am in Setup>>Create>>Objects>>MyCustomObject>>PercentField(Value_c).

I have a validation set for this percent type field: Value_c< 0 ||  Value_c> 1.0 for which It displays error if this condition satisfies.

My Problem:

Whenever there is a 'blank' value sent to Value_c, it automatically reflects as 0%.
I want it to reflect as a simple blank in the field.

Please Guide!


Hi Guys,

Can you please help me with my test class I'm only achieving 39% as of now, please do comment on some line I am just new with test classes.
//Test CLASS
public class ProductImportController{

    public Blob csvFileBody { get; set; }
    public String csvFileName { get; set; }
    public Boolean showResults { get; set; }
    public Boolean showImport { get; set; }
    public Boolean isUploading { get; set; }
    public List<Product2> prdctList { get; set; }
    public List<PricebookEntry> pbeListStandard  { get; set; }
    public List<PricebookEntry> pbeListCustom { get; set; }
    public ProductImportController(){
        //Show/hide sections
        showResults = false;
        showImport = true;
        isUploading = false;
    public void upload(){
        if(isUploading){ return; }
        isUploading = true;
        //Show/hide sections
        showResults = true;
        showImport = false;
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage() ));
            //Show/hide sections
            showResults = false;
            showImport = true;
            isUploading = false;
                throw e;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Product import completed.'));
        isUploading = false;
    public void parseCsvInsertProductsPricebooks(){
        if(csvFileBody == null){
            throw new ProductImportException('No CSV found.');
        //Convert from blob to string
        String csvString = csvFileBody.toString();
        csvFileBody = null;
        csvFileName = null;
            throw new ProductImportException('Empty CSV found.');
        //Parse CSV into separate fields
        List<List<String>> allFields = parseCSV(csvString);
        if(allFields == null || allFields.isEmpty()){
            throw new ProductImportException('Empty CSV found.');
        //Use first line as header
        List<String> headerFields = allFields.remove(0);
        List<HeaderWrapper> headerList = parseHeaders(headerFields);
        List<LineWrapper> lineList = new List<LineWrapper>();
        //Parse remaining lines
        if(allFields == null || allFields.isEmpty()){
            throw new ProductImportException('No rows found.');
            for(List<String> line : allFields){
                lineList.add(new LineWrapper(line,headerList));
        //Get all products
        prdctList = new List<Product2>();
        for(LineWrapper line : lineList){
        //Insert products
            insert prdctList;
        }catch(Exception e){
            throw new ProductImportException('Could not insert products. ' + e.getMessage() ,e);
        //Insert standard pricebook entries
        pbeListStandard = new List<PricebookEntry>();
        for(LineWrapper line : lineList){
            List<PricebookEntry> l = line.getStandard();
            if(l != null){
                System.debug('* ** *** inserting standard pbe '  + pbeListStandard);
                insert pbeListStandard;
        }catch(Exception e){
            throw new ProductImportException('Could not insert pricebook entries. ' + e.getMessage() ,e);
        //Insert custom pricebook entries
        pbeListCustom = new List<PricebookEntry>();
        for(LineWrapper line : lineList){
            List<PricebookEntry> l = line.getCustom();
            if(l != null && !l.isEmpty()){
                System.debug('* ** *** inserting custom pbe ' + pbeListCustom);
                insert pbeListCustom;
        }catch(Exception e){
            throw new ProductImportException('Could not insert pricebook entries. ' + e.getMessage(),e);
    public static List<HeaderWrapper> parseHeaders(List<String> headerFields){
        //List of headers
        List<HeaderWrapper> headerList = new List<HeaderWrapper>();
        //Mapping setting
        Map<String,ProductImportMapping__mdt> pim = new Map<String,ProductImportMapping__mdt>();
        for(ProductImportMapping__mdt p : [SELECT MasterLabel, Field__c, isProductField__c, Pricebook__c, Isocode__c FROM ProductImportMapping__mdt]){
        //Field types
        Map<String, Schema.SObjectField> fieldMap  = Schema.SObjectType.Product2.fields.getMap();

        Map<Id,Pricebook2> pbMap = new Map<Id,Pricebook2>([SELECT Id FROM Pricebook2 WHERE IsStandard = false]);
        Id pbStandard;
            pbStandard = Test.getStandardPricebookId();
            List<Pricebook2> pbStandardList = [SELECT Id FROM Pricebook2 WHERE IsStandard = true];
            if(pbStandardList == null || pbStandardList.isEmpty()){
                throw new ProductImportException('Could not find standard pricebook.');
                pbStandard = pbStandardList.get(0).Id;
        //Map header
        for(String field : headerFields){
            //Get custom setting
            ProductImportMapping__mdt setting = pim.get(field);
            HeaderWrapper header;
            if(setting != null){
                    //check that field is valid and creatable
                    if(fieldMap.containsKey(setting.Field__c.toLowerCase()) && fieldMap.get(setting.Field__c.toLowerCase()).getDescribe().isCreateable()){                                        
                        //create header wrapper
                        header = new HeaderWrapper();
                        header.name = field;
                        header.field = setting.Field__c;
                        header.isProductField = true;
                        header.isSkip = false;
                        header.type = String.valueOf(fieldMap.get(setting.Field__c.toLowerCase()).getDescribe().getType());
                        //skip header wrapper if no field
                        header = new HeaderWrapper();
                        header.isSkip = true;
                    //check that pricebook is valid                    
                    Id pbId;
                        pbId = Id.valueOf(setting.Pricebook__c);
                    }catch(Exception e){
                        throw new ProductImportException('Could not convert pricebook Id.', e);
                        throw new ProductImportException('Id is not a custom pricebook Id');
                    //create header wrapper
                    header = new HeaderWrapper();
                    header.name = field;
                    header.isProductField = false;
                    header.pricebook = setting.Pricebook__c;
                    header.standard = pbStandard;
                    header.isocode = setting.Isocode__c;
                    header.isSkip = false;
                //skip header wrapper
                header = new HeaderWrapper();
                header.isSkip = true;
            //add to list

        return headerList;
    }//end parseHeaders
    //Parse CSV into separate fields
    public static List<List<String>> parseCSV(String contents) {
        List<List<String>> allFields = new List<List<String>>();
        contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
        contents = contents.replaceAll('""','DBLQT');
        List<String> lines = new List<String>();
        try {
            lines = contents.split('\n');
        } catch (Exception e) {
            throw new ProductImportException('Could not split CSV.', e);
        Integer num = 0;
        for(String line : lines) {
            // check for blank CSV lines (only commas)
            if (line.replaceAll(',','').trim().length() == 0) break;
            line = line.replaceAll('\r','').trim();
            List<String> fields = line.split(',');  
            List<String> cleanFields = new List<String>();
            String compositeField;
            Boolean makeCompositeField = false;
            for(String field : fields) {
                if (field.startsWith('"') && field.endsWith('"')) {
                } else if (field.startsWith('"')) {
                    makeCompositeField = true;
                    compositeField = field;
                } else if (field.endsWith('"')) {
                    compositeField += ',' + field;
                    makeCompositeField = false;
                } else if (makeCompositeField) {
                    compositeField +=  ',' + field;
                } else {
        return allFields;       
    }//end parseCSV
    //wrapper for line
    class LineWrapper{
        Product2 prdct;
        Map<String,PricebookEntry> pbeStandard = new Map<String,PricebookEntry>();
        List<PricebookEntry> pbeCustom = new List<PricebookEntry>();
        public LineWrapper(List<String> fields, List<HeaderWrapper> headerList){
            System.debug('* ** *** fieldsize: ' + fields.size() + '. headersize: ' + headerList.size());
            //Loop through every cell in row
            for(Integer ctr = 0; ctr < fields.size() && ctr < headerList.size(); ctr++){
                //Get value of cell and header
                String field = fields.get(ctr);
                HeaderWrapper header = headerList.get(ctr);
                System.debug('LineWrapper #' + ctr + ': "' + field + '" ' + header);
                if(header == null || header.isSkip){
                    //Do nothing
                    System.debug('* ** *** skip');
                }else if(header.isProductField && field == null){
                    //Field name is required
                    throw new ProductImportException('Could not identify field for line: ' + fields);
                }else if(header.isProductField && field != null){
                    //Create product
                    if(this.prdct == null){
                        this.prdct = new Product2();
                    //Set value of field depending on type
                        if(header.type == 'BOOLEAN'){
                        }else if(header.type == 'DATETIME'){
                        }else if(header.type == 'DOUBLE'){
                        }else if(header.type == 'BOOLEAN'){
                        }else if(header.type == 'REFERENCE'){
                    }catch(Exception e){
                        throw new ProductImportException('Could not populate field ' + header.field + ' with ' + field);
                }else if(String.isBlank(header.isocode) || header.pricebook == null){
                    //Pricebook and isocode mapping required
                    throw new ProductImportException('Could not identify pricebook and currency for line: ' + fields);
                    Decimal price = Decimal.valueOf(field);
                    //Create custom pricebook entry
                    PricebookEntry pbe = new PricebookEntry(Pricebook2Id = header.pricebook, UnitPrice = price, IsActive = true,CurrencyIsoCode=header.isocode);
                    //Create standard pricebook entry
                        pbeStandard.put(header.isocode,new PricebookEntry(Pricebook2Id = header.standard, UnitPrice = price, IsActive = true,CurrencyIsoCode=header.isocode));
                        //Set custom to use standard
                        pbe.UseStandardPrice = true;
                    //Add custom pricebook entry to list
                }//end if-else
            }//end for
        }//end constructor
        public List<PricebookEntry> getStandard(){
            for(PricebookEntry pbe : pbeStandard.values()){
                pbe.Product2Id = prdct.Id;
            return pbeStandard.values();
        public List<PricebookEntry> getCustom(){
            for(PricebookEntry pbe : pbeCustom){
                pbe.Product2Id = prdct.Id;
            return pbeCustom;
    }//end class

    //custom exception
    class ProductImportException extends Exception {}

    //wrapper for header
    class HeaderWrapper{
        String name;
        String field;
        String isocode;
        String type;
        Id pricebook;
        Id standard;
        boolean isProductField;
        boolean isSkip;
//Test CLASS
public class ProductImportController_Test {
    private static testMethod void testData()
        Product2 prdctlist = new Product2(Name = 'Test Product004', ProductCode = 'Test Product004');
        insert prdctlist;
        PricebookEntry pbeListStandard =  new PricebookEntry();
        PricebookEntry pbeListCustom =  new PricebookEntry();

        ProductImportController scontroller = new ProductImportController();

        scontroller.csvFileName = 'Test Product';
        scontroller.csvFileBody = Blob.valueOf('Test AttachmentBody');


I am in the process of creating a custom javascript that appears on a opportunity list view. However when I test the button, I recieve the following error: Error in Opportunity Creation = Type Error:sforce.connection.insert is not a function?

The code I am using, I found in the forum and I modified. I am not sure how to resolve the error. I am not a developer. I appeciate the help. 
var url = parent.location.href;
var records = {!GETRECORDIDS($ObjectType.Opportunity)};
var CreateNewRecords = []; 

if (records[0] == null)
	alert("Please select at least one record to update.");
	for (var a=0; a<records.length; a++) 
		var create_new_opportunity = new sforce.SObject("opportunity");
		create_new_opportunity.RecordTypeId = "012a0000001ZUXg"; 
		create_new_opportunity.AccountId = "{!Opportunity.Account}"; 
		create_new_opportunity.Closedate =new Date("{TODAYY()}");
		create_new_opportunity.OwnerId = "{!Opportunity.OwnerId}";   
		create_new_opportunity.StageName= "Info Gathering/Investigation";
                create_new_opportunity.Strategy_Type__c= "Full Launch Target";
var result = sforce.connection.insert(CreateNewRecords);
if (result[0].success=='false')

alert("Error In Opportunity creation  = "+error);

If we are updating the field in the account object which has 1,0001 records ,in which area those records get splitted how can process the query along with the dml operations and governer limits..? if the logic is processed  under execute method new thing is inistaniated where it will be stored ?again how it will take the batch and what is the batch size..if we cant mention the batch size it will takes it as 200 or any other to increase batch size?
 please give the solution i was stucked ..??
Hello Guys,

I want  to clear out unconverted leads in qualified status

There are leads that are not converted but their status is "qualified"  this is incorrect

Now What i want is that  There should not be any unconverted leads in qualified status.

Plz share the solution  and i am using professional edition.
I have created recurring tasks such as 'Occurs on day 10 of every 1 month'. The problem is when they fall on a week end. I could not figure it out how to make the task falls on the Friday preceding the week end if it falls on a Saturday or a Sunday. All tasks are already entered in the Salesforce. 
Any Idea?
Thank you.
Hi All,
I am looking for Salesforce Developer Job Support based in USA time zone and preferably from the USA. Need help with apex coding, triggers, workflows etc. Please reply back here or email me at mia.p827@gmail.com with the subject line: SFDC Job Support. 
  • September 19, 2015
  • Like
  • 0
Hi Everyone,
I am looking for Salesforce Developer Job Support based in USA time zone and preferably from the USA. Need help with apex coding, triggers, workflows etc. Please reply back here or email me at mia.p827@gmail.com with the subject line: SFDC Job Support
  • September 19, 2015
  • Like
  • 0
Need salesforce development job support.

I need Salesforce on job support. Please respond asap

My email - kmohanrm@gmail.com

Need salesforce job support for a project.

Anyone interested reply or send an email to salesfo401@gmail.com.

  • April 20, 2014
  • Like
  • 2

We are a team of salesforce.com consultants looking for a full time Salesforce Administrator/Consultant who can work virtually with our clients from their home office.  This person must have the ability to get on a call with a client and develop a quick understanding of client business issues.  You will need to be able to evaluate a business issue faced by the customer and determine how best to employ salesforce.com to solve it. 


Core skills would include:

  • All normal salesforce.com administration tasks and an understanding of all major functional areas of Salesforce.com
  • Including (but not limited to) reports and dashboards.
  • Data imports (using data loader or other tools).
  • General problem solving skills in Salesforce.com
  • Have a very good feel for where visualforce can be used to solve business problems - for example, where a trigger might be used due to workflow limitations, or where a visualforce page might be used in place of the standard user interface to make a complex business task easier for a user.
  • Ability to design the data model to support given business requirements and architect the various associated systems. 
  • You should be able to efficiently, effectively, and clearly coordinate and manage work with our development team while managing the client relationship from start to finish.  This would include some evening hours to work with our overseas developers to explain & manage project requirements.
  • Salesforce.com Certified Administrator

 You do not need to be a developer – other individuals in our company will do the actual development. 

Hi Friends I am looking for SFDC developer support if any one have information please forward me



need salesforce support in california timings