• GauravGarg
  • PRO
  • 3163 Points
  • Member since 2015
  • Sr Technical Specialist
  • AXA Singapore


  • Chatter
    Feed
  • 100
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 10
    Questions
  • 1056
    Replies
I am VERY new to LWC development and having issue opening a previously created LWC from my Org using Visual Studio Code.   I do not have this code yet in any folder on my system just want to connect to the org and pull down the code for pre-existing LWCs.
I did install Salesforce in Visual Studio Code but not sure how to use it once it's installed

Any tips are appreciated.  
Most of my old experience was with Apex/VF and Eclipse IDE.
  • January 29, 2020
  • Like
  • 0
HI,
I want to create a lightning component where i need to pass the current account Id to the component and display all the quotes that are related to the account id.
 

I'm trying to embed a Visualforce Page onto my home page that allows users to select a report and filter it right there. 

When running I seem to be getting the following error:
caused by: System.NullPointerException: Attempt to de-reference a null object

Class.AnalyticsController.getSelectedFilters: line 69, column 1
Class.AnalyticsController.getChartFilter: line 64, column 1


Can anyone identify what's causing this issue? I notice this code was written for API Ver 29, while I'm on 48. 

Visualforce Page: 

<apex:page controller="AnalyticsController">
<style>
label {
    font-weight: bold;
}
#filters {
    overflow: hidden;
    width: 100%
}
#filterBox {
    float: left;
    align: center;
    padding: 5px 5px 5px 0px;
}
</style>
<apex:form >
    <apex:outputLabel value="Select Report"/> 
    <apex:selectList value="{!reportId}" multiselect="false" size="1">
        <apex:selectOptions value="{!availableReports}"/>
    </apex:selectList>
    <apex:commandButton action="{!getReportInfo}" value="Get Report Filters" reRender="report"/><br/>

    <apex:outputPanel id="report" layout="block">
        <apex:outputPanel rendered="{!reportId != null}">
            <div id="filters">
                <apex:repeat value="{!availableColumnFilters}" var="colFilter">
                    <div id="filterBox">
                        <apex:outputLabel >{!colFilter.label}</apex:outputLabel><br/>
                        <apex:selectList value="{!colFilter.operator}" size="1" multiselect="false" style="width: 100px;">
                            <apex:selectOption itemLabel="--None--" itemValue=""/>
                            <apex:selectOptions value="{!availableDataTypeFilterOperators[colFilter.dataType]}"/>
                        </apex:selectList>
                        <apex:inputText value="{!colFilter.value}"/>
                    </div>   
                </apex:repeat>
            </div>

            <apex:commandButton value="Get Chart with Filters" reRender="chart"/><br/>

            <apex:outputPanel layout="block" id="chart">
                <analytics:reportChart reportId="{!reportId}" filter="{!chartFilter}"/>
            </apex:outputPanel>
        </apex:outputPanel>
    </apex:outputPanel>
</apex:form>
</apex:page>

Controller:
 
public with sharing class AnalyticsController{
 
    public List<SelectOption> availableReports { get; set; }
    public Id reportId { get; set; }
    public Map<String, List<SelectOption>> availableDataTypeFilterOperators { get; set; }
    public List<ColumnFilter> availableColumnFilters { get; set; }
 
    public AnalyticsController() {
        availableReports = retrieveAvailableReports();
        availableDataTypeFilterOperators = retrieveAvailableDataTypeFilterOperators();
    }
 
    public List<SelectOption> retrieveAvailableReports() {
        List<SelectOption> reptOpts = new List<SelectOption>();
        for (Report r : [
             Select Id, Name
             From Report
             Where Format In ('Summary','Matrix')
             Order By Name
        ]) {
            reptOpts.add(new SelectOption(r.Id, r.Name));
        }
        return reptOpts;
    }
 
    public Map<String, List<SelectOption>> retrieveAvailableDataTypeFilterOperators() {
        Map<String, List<SelectOption>> dataTypeFilterOpts = new Map<String, List<SelectOption>>();
        Map<String, List<Reports.FilterOperator>> filterOperatorMap = Reports.ReportManager.getDataTypeFilterOperatorMap();
 
        for (String dataType : filterOperatorMap.keySet()) {
            List<SelectOption> operators = new List<SelectOption>();
 
            // Append _DATA to match ColumnDataType from ReportTypeColumn
            dataTypeFilterOpts.put(dataType.toUpperCase() + '_DATA', operators);
 
            for (Reports.FilterOperator fo : filterOperatorMap.get(dataType)) {
                operators.add(new SelectOption(fo.getName(), fo.getLabel()));
            }
        }        
        return dataTypeFilterOpts;
    }
 
    public PageReference getReportInfo() {
        Reports.ReportDescribeResult descRes = Reports.ReportManager.describeReport(reportId);
 
        availableColumnFilters = new List<ColumnFilter>();
 
        for (Reports.ReportTypeColumnCategory category : descRes.getReportTypeMetadata().getCategories()) {
            for (Reports.ReportTypeColumn col : category.getColumns().values()) {
                if (col.getFilterable()) {
                    ColumnFilter cf = new ColumnFilter(
                        col.getLabel(),
                        col.getName(),
                        col.getDataType().name()
                    );
                    availableColumnFilters.add(cf);
                }
            }
        }
        return null;
    }
 
    public String getChartFilter() {
        return JSON.serialize(getSelectedFilters());
    }
 
    private List<ColumnFilter> getSelectedFilters() {
        List<ColumnFilter> selectedFilters = new List<ColumnFilter>();
        for (ColumnFilter cf : availableColumnFilters) {
            if (String.isNotBlank(cf.operator)) {
                selectedFilters.add(cf);
            }
        }
        return selectedFilters;
    }
 
    public class ColumnFilter {
        public ColumnFilter(String lab, String col, String dt) {
            label = lab;
            column = col;
            dataType = dt;
        }
 
        // Values needed for apex:analytics component
        public String column { get; set; }
        public String operator { get; set; }
        public String value { get; set; }
 
        // Values need for display and operator select list
        public String label { get; set; }
        public String dataType { get; set; }
 
    }
}

Thanks for the help!! 
Hello, 



Recently I've been tasked with sending a questionnaire to customers related to specific orders with an e-mail with a questionnaire, when the user replies the InboundEmail class needs to save the information sended back (Evaluation from 0 to 10), plus any comentaries.

Is there a way to achieve this natively or trough Apex?

I've searched the boards but wasn't able to find any solution related to my problem, in any case if it's a duplicate topic sorry in advance!

Thank you!
Hello All,

I've got an interesting use case here.  I've got an approval process built out on Opportunities.  One of the managers wants an email anytime something is approved or rejected but only if the Oppty was created by one of the people on her team.  Otherwise she doesn't want an email at all.  

Any ideas on how to do this?  In the approval process itself, I don't see a way to send an email alert based on a criteria.   I know that I could create some formula field like a checkbox to return 'true' if the record was created by someone on her team, but I don't see a way to fire of an Approval Action based off a criteria. 

So maybe a trigger then on approval?  If so, what object would by trigger be on?  

Thanks in advance everyone!
George


 
how to iterate over map of Map<ID,List<String>>in apex
  • October 02, 2018
  • Like
  • 0
So if the output is blank or a default value I would like it to highlight, is this possible, if so how?
User-added image
visualforce page:
<apex:form >    
         <apex:pageBlock title="Your Carts:"> 
            
            <apex:pageblockTable value="{!MapProducts}" var="a"> 
                <apex:column >
                    <apex:image width="100" height="100" value="{!URLFOR($Resource.ProductImage, 'ProductImage/' & MapProducts[a]['ImageName__c'])}"></apex:image>
                </apex:column>
                
                <apex:column headerValue="Name" value="{!MapProducts[a]['Name']}"/> 
                <apex:column headerValue="Price" value="{!MapProducts[a]['Price__c']}"/> 
                <apex:column headerValue="Amount" > 
                    <apex:inputText style="text-align:right;width:100px;" value="{!MapProducts[a]['Amount']}"/>
                </apex:column>
                <apex:column headerValue="Money" value="{!MapProducts[a]['Total']}"/> 
                <apex:column >
                    <apex:commandLink action="{!deleteItem}" reRender="MapProducts" ><apex:param assignTo="{!iKey}" value="{!a}" name="assignvalue" /> Remove Row</apex:commandLink>
                </apex:column>
            </apex:pageblockTable>   
          <apex:pageBlock title="Total Money:"> 
             <apex:outputText >{!iTotalMoney}</apex:outputText> 
          </apex:pageBlock>
        </apex:pageBlock> 
   </apex:form>

apex function:
public void deleteItem()
  {
      System.Debug('deleteItem') ;
      iTotalMoney=0;      
      System.Debug(iKey) ;
      MapProducts.remove(iKey);
      for (Integer key : MapProducts.keySet()) {     
        iTotalMoney +=Double.valueOf(MapProducts.get(key).get('Total'));
      }
  }

Log debug output
43.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
03:14:43.0 (94306)|USER_INFO|[EXTERNAL]|0057F000002yTNz|daitb@vnitsolutions.com|Pacific Standard Time|GMT-07:00
03:14:43.0 (138242)|EXECUTION_STARTED
03:14:43.0 (143358)|CODE_UNIT_STARTED|[EXTERNAL]|0667F000009PMhv|VF: /apex/carts
03:14:43.0 (360015)|VF_DESERIALIZE_VIEWSTATE_BEGIN|0667F000009PMhv
03:14:43.0 (7435075)|VF_DESERIALIZE_VIEWSTATE_END
03:14:43.0 (9840462)|SYSTEM_MODE_ENTER|true
03:14:43.0 (14743313)|SYSTEM_MODE_ENTER|true
03:14:43.0 (15488240)|VF_SERIALIZE_VIEWSTATE_BEGIN|0667F000009PMhv
03:14:43.0 (17250235)|VF_SERIALIZE_VIEWSTATE_END
03:14:43.20 (20160362)|CUMULATIVE_LIMIT_USAGE
03:14:43.20 (20160362)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 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
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

03:14:43.20 (20160362)|CUMULATIVE_LIMIT_USAGE_END

03:14:43.0 (20198901)|CODE_UNIT_FINISHED|VF: /apex/carts
03:14:43.0 (21042239)|EXECUTION_FINISHED
log not exist text: deleteItem
Why delete row action not call apex function?

Hi,

How to get the record type name in before insert.

Requiremnet is need to check in if condition for record type name 
Ex : if(record type name= 'A' ) 

We have a custom EmailService for inbound messages written in apex, which is processing Inbound email messages and then showing them in a lightning component.
The type od the received email object is EmailMessage. On the production org, when the system administrator is logged in, he sees all the needed incoming emails (the component is showing them as it should be, querying also works). It all worked well in our sandbox though.
The problem is when the user is logged in. The component does not show any emails and they are not visible also by querying. The problem is I suppose with some permissions, but the EmailMessage object in our org is not customizable when it comes to permissions (everything is set to default and is not changeable). The user has a company community licence. Any help or suggestion would be greatly appreciated.
HI All,

can anyone provide me a solution on how to update the ownerId field in the ContentDocument object. i have tried doing this with a trigger on ContentDocument object but it does not seems to work
Hi,

I have this trigger that I would like to convert to an apex class and I would like to add some code to the class.  The trigger changes contacts to the account owner id when the account owner is changed.  What I would like to add is something that also changes the contact owner when a contact is created or added to the account.

Here is the trigger I have.

trigger AlignContactownertoAccountOwner on Account (after insert,after update) {
      Set<Id> accountIds = new Set<Id>();
      Map<Id, String> oldOwnerIds = new Map<Id, String>();
      Map<Id, String> newOwnerIds = new Map<Id, String>();
      List<Contact> contactUpdates = new List<Contact>();
      for (Account a : Trigger.new)
      {
         if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
         {
            oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId);
            newOwnerIds.put(a.Id, a.OwnerId);
            accountIds.add(a.Id);

         }

      }

        if (!accountIds.isEmpty()) {

         for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])

            {

            String newOwnerId = newOwnerIds.get(acc.Id);
            String oldOwnerId = oldOwnerIds.get(acc.Id);

            for (Contact c : acc.Contacts)

            {

               if (c.OwnerId == oldOwnerId)
               {

               Contact updatedContact = new Contact(Id = c.Id, OwnerId = newOwnerId);

               contactUpdates.add(updatedContact);

               }

            }

             

            }

       }
            update contactUpdates;

}

Any help would be great.

Thanks,

Michael 
Hello Devs, I have the following Trigger and Class that was working fine until this morning when I received the following error of Too Many future calls: 51. 

Any idea how to alleviate gettign this error?  Here is my trigger and class code....thank you all for any help you can provide....

Trigger:
 
trigger DeleteExtraBookingsTrigger on Opportunity (after insert) {

    For(Opportunity opps : Trigger.new){
        If(opps.Auto_Bookings__c == True){
            
            
        DeleteExtraBookingsClass.deleteRecords(Trigger.newMap.keySet());    
            
        }
    }
    
    
}

Class code:
 
public class DeleteExtraBookingsClass {

    @future
    public static void deleteRecords(Set<ID> oppIdsToDelete){
        List<Opportunity> opp = [SELECT ID, Armor_Product_Category__c From Opportunity WHERE ID IN : oppIdsToDelete AND Auto_Bookings__c = True
                                AND (Armor_Product_Category__c = null or Armor_Product_Category__c = 'Armor | null')];
        
        If(opp.size()>0){
        delete opp;
        database.emptyRecycleBin(opp);
        }
    }
    
}

Hello everyone.
I have a requirement to store information from different Contacts in Google Drive. My problem is that I would like to create a directory dynamically for each new contact and I have not found much information on how to do it from apex. Has anyone had success performing this functionality?

Greetings thank you!
Hi,

The below trigger was fired after updating the field twice, but it was not fired before update.
 
trigger age on Account (before update) {

  Map<Id,Account> ageMap = new Map<Id,Account>(); 
  Account[] acct = [SELECT Id,Age__c FROM Account WHERE Id IN : Trigger.newMap.keySet()];
    
     for(Account a : trigger.new){
           

            if(a.age__c != null){
             
                ageMap.get(a.Id);
                a.Is_Age_Updated__c = true;
               
            }
            else{
                
             ageMap.get(a.Id);
             a.Is_Age_Updated__c = false;
            }                  
    }

}


 
  • February 02, 2018
  • Like
  • 0
Hi All,
          I have two objects called product and product details. Product field is lookup on product details.
          In product details object, if I have a product detail record pd1 with product p1, I shouldn't be able to create or update 
          another product detail pd2 with product p1.
         
           How can I achieve this?
Hi,

    I have written a trigger .I want this trigger to be executed when clicked on a custom button in a VF page. Can anyone help me out with this?
Thanks.
What happens to the secondary master detail relationship if the primary master detail relationship is changed to lookup?
Hello,
I'm new to triggers and struggling with this. I need a trigger that pulls the Opportunity name and creates a new record in my custom object, AE Opp. I do not need it to create a lookup or link it to the opp, i just need it to create a whole new record so that I can create a task on it.. Is this feasible?
Hi all,

I'm new to Salesforce and would like to ask for more information about different salesforce editions and versions. Our team wants to use an organization, with Force.com account to be used as PaaS for custom application development. This means without the standard CRM features, which Salesforce.com provides like Campaigns, Leads, Opportunities, or Cases. But to get access to the “Core” functionality of Accounts and Contacts, Reports, Dashboards, Documents, and Activities and Custom Objects.  I know the Salesforce platform (https://www.salesforce.com/products/platform/lightning/?d=70130000000f27V&internal=true) can be used for this case. I have a free trial to test it out but still, it provides me features for Salesforce standard license, not for Salesforce platform license. Would please tell me which edition and licenses are best to be used when I want to use Force.com as a platform.
Hi All, 

I have a requirement to send out 50000 email to a un-verified email address every day, but due to 5000 email limit, we cannot. 

Do you have any solution which can be implemented?

Background: 
We are using a custom VF page to filter out records which need to send an email. 

An ideal solution would be a button over the VF page which can send email just like Salesforce button using some tool. 


Thanks in Advance. 
I am working on lightning flow for a month. My flow, there are about 5 screens and on every screen has 1 or 2 pick-list / radio buttons which are marked as mandatory.
The problem I am facing here is, the customer selects the choice values and navigates forward (next) but in-case if he returns back to the screen, the selected value is reset to default i.e. the choice has been reset.

 Can you please provide an optimal solution out-of-the-box to fix this issue. Thanks
Can we convert List<account> to Map<String, String> i.e. Map<FieldLabel, FieldValue> pair. 


Thanks in advance. 
I am able to upload documents in Lightning Flow using Standard lightnign component "forceContent:fileUpload" and attached related record to "current user id". 

My Requirement is to display the "files name" of uploaded document. I have attribute "Uploaded file names" and store into a collection variable, but when I choose this option, my flow screen is showing blank. 

I want to display all the file name that are uploaded. 

Any idea?

Thanks in advance. 
 
Hi All,

I am new to lightning. My requirement is to load external Minify javascript file which will run a demo or walkthru over the object records, Dashboard to enlight customer to use Lightning. 

Currently, the same has been working in salesforce classic, but in lightning it is not allowed and throwing error. 

Do anyone facing the same issue? 
My client require to have two way integration between Salesforce - Siebel. 

Is there any third party (app exchange) tool. 
Or we should go with customized code. 

Please suggest. 
I want to create Opportunity Share records for two custom fields "Manager" and "Senior Manager"  lookup to User on Opportunity object. 

My Batch job is working as expected and creating those record perfectly. 

But, the issue is in Test Class:
  • I have created one createOpportunity() method, and create two Opportunities. 
  • Both the opportunities have Manager / Senior Manager field populated with User. 
  • Now, when I run this method, It will cover my Batch job and create sharing records ( that I can debug in batch job).
  • If I am trying to query those sharing record in Test Class using below query, it is giving 0 records. 
  • SELECT Id, manager__c, senior_manager__c, rowcause from Opportunity. 
Any ideas please. 
We have some VF page, that we visible as Public Site on my client website. The VF page are working fine but due to salesforce Standard Javascripts. The website perform is quite down. 

Can you please provide me some idea to avoid running these standard Javascript libraries. 

 
Hi All,

I have completed my Lightning Superbadge two months ago and since then it is showing in active module. Please help me out how can I fix this. I already had contacted with salesforce trailhead but they are providing no help. 

Thanks,
Gaurav
Hi All,

Today I have completed my Lightning super badge module, still it is showing under Active module.

User-added image

Please suggest how can I fix this. 

Thanks,
Gaurav
Hello,
I was wondering.  What is the best way to get the record from a list based on the currecnt record.
For example I have this list where I am grabbing all the records where the ProjectT Name is 'Closed Templates'
cprojects = [SELECT Id, ProjectT__r.Name, Cand_Project__c,Cand__c 
                FROM Project__c WHERE  ProjectT__r.Name =: 'Closed Templates'];
In a nother method how can I grab the the record/field from the list based on the current record.  What I am trying to go is query all of the records that meet the criteria so that I only have to query it once in the class but need to be able to get a record from list based on the current record being updated.
Thanks,
P
how to compare this 2 fields
if they are equal no. then I want to update status of my job.in apex trigger.
I'm looking for some guidance after days of searching SF, forums, tralblazer, etc. I haven't worked in SF in a very long time.
In my mind what I need to do is simple, but everything I seem to find leads me down a path of complex development. Maybe I'm searching on the wrong terms. 

Here is what I'm trying to do. 
Use case - User needs to click a button(action, etc.) in a record to open to an externally hosted site to perform a task that ties to the SF record they're working in. On click, it would automatically authenticate to the site, pass initial values, and then open the web page in an iframe (preferable), or in a new browser window/tab with the initial values populated. 

Basic logic - (at least in JSON)
1. Authenticate - grant type is client credentials, returns a bearer token
2. Initialise a session - bearer token in header, returns a web sessionid
3. Display that session - bearer token in the header, sessionid appended to the end of a static external URL

The primary issue for me is the structure of this. Writing the code itself isn't really an issue. It's where to put it all and bring it all together.

I had thought this could all be in done in a VF page, but that doesn't seem to be the case. Some people recommend using Canvas, but that seems to be way over the top. 

Any help, guidance is greatly appreciated.

 
Hello,

insert cloneQuoteList; 

I am inserting the list of quote.
How can i get the Opportunity Id and Inserted qute id after the insert.

I want to use the Ids to insert the cloned quote line items

thank you

I have configured my salesforce org with JOT form. My lead assignment rule is also active. But due to some reason it is not working. Can any one suggest me why it is not working and hot to run it.

Thank you  

Hi All, 
When Updating Contact Email Through Import Wizard, i tried using  two approaches 
1. contact name, account name
2. contact email id,contact id
Both work fine,but when there are duplicate contacts under account then only one of them gets updated . Hence i assume option 2 is the right way to go.Can someone confirm?

Not able to use case comment object.Initially we write few lines of code on case comment object and it was working. But, now when we are trying to change the code its is showing invalid variable commentbody error message. Then i  reverted all the changes and just tried to save the method as earlier. But now also im not able to save that class. Same code is not giving errors in UAT but getting error in Dev sandbox. 

   public static void UpdateCaseComment(string Id, string comment ){
        casecomment cc=new casecomment();
        cc.Id=Id;
        cc.commentbody=comment;
        try{
            update cc;
        }catch(Exception e){
            System.debug('er->'+e);
        }
    } 

This is my code 
Please let me know what is causing this issue.

So due to business requirements, I'm using a wrapper to sum daily target data into a single "record" displayed in a lightning:datatable in an aura component.   Those summarized records are editable and when saved were divided by seven for the week.  

Now the start of the "week" is changeable.  In other words some weeks can be seven days long, others can be five depending on the start date.  I'm able to get things working fine, creation of new records, extra except for the division part when updating previous records.  

Essentially using the "Power of One," I'm summing up the number of days in the "weekly record" and displaying it in the consolidated view for users.  I would like to pass that number back to SFDC so the updated values are divided by that summed "Power of One" value.  

Hoping some one can help me figure out how to force the component to return the sum even though it hasn't changed, kind of like the ID value.   If that value is rreturned, I don't have to do a SOQL query to find the number of daily records for the various "weekly" records.

Thanks.
Hi all, 
I have a 'Text Area (Long)'  Field called  All_Products_List__c  wich will be populate by a trigger. To avoid error, i want to limit the number of caracter sto the max vaklue of Text Area (Long). 
The code  save well but when i run  the test class, The error is: "Ending position out of bounds: 131072".  
 
trigger DeliveryNotification on Item_Distributed__c (after update, after insert, after delete, after undelete){

    List <Item_Distributed__c> deliveryItems = (Trigger.isInsert|| Trigger.isUnDelete) ? Trigger.new : Trigger.old;
    
    List <Id> delveryId = new List<Id> ();
    String fullProduct;
    
    for (Item_Distributed__c allDeliveryItems : deliveryItems) {
           delveryId.add(allDeliveryItems.Delivery__c);
   }
   
   List< Delivery__c> deliveryList = [ SELECT id, All_Products_List__c, (SELECT Product_With_UOM__c  from  Items_Distributed__r ) From Delivery__c 
                                    Where id in:delveryId];
                                    
    for (Delivery__c del: deliveryList){
        if (del.Items_Distributed__r.size()>0){
            //camp.Product_With_UOM__c = string.valueOf(del.Items_Distributed [0].Product_With_UOM__c);
            del.All_Products_List__c = '';
            for(Item_Distributed__c member : del.Items_Distributed__r )
               fullProduct = del.All_Products_List__c + member.Product_With_UOM__c + ' ,';
                del.All_Products_List__c = fullProduct.substring(131072);
        }
            else
            del.All_Products_List__c = null;
        }   
                    update deliveryList;

 
Hello,

I have a custom object (Warehouse Visit) that is the child record of Contact. I'd like to click a button on the Warehouse Visit tab where multiple records can be created on one Visualforce page. Basically, I'd like staff to be able to log multiple visits on one page rather than add them one by phone.

On the VF page, I'd like a link that says "add" to allow staff to add multiple rows for each record (3-4 fields). At the end of each row, I want a Remove or X link to remove that row if it was created in error. Then, on save, I'd like it to redirect back to the Warehouse Visit tab. 

I haven't started building the VF page yet, but I'd like to enter about 4 fields, including a lookup to the Contact, a couple of date/time fields, and maybe a checkbox or picklist. 

I have started with this Apex class code, based on a previous button I had help developing, but I'm getting an error. Can anyone help fix this code?

public class WarehouseVisitController {
    public List<Warehouse_Visit__c> wvRecord{get; set;}
    public Integer wvIndex {get; set;}

    public WarehouseVisitController  (){
        wvRecord = new List<Warehouse_Visit__c>();
        wvRecord.add(new Warehouse_Visit__c);
    } #this is where the error is happening
    public void addWarehouseVisit () {
        wvRecord.add(new Warehouse_Visit__c);
    }
    public void removeWarehouseVisit() {
        wvIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('wvIndex'));
        wvRecord.remove(wvIndex);
    }
    public PageReference save() {
        upsert wvRecord;
        PageReference page = new PageReference('/');
        return page;
    }
    public PageReference cancel() {
        PageReference page = new PageReference('/' );
        return page;
    }
}

 
Hi, 

Is it possible to join two unrelated objects (Account with Custom Object) using SOQL? 

Basically I need to update the Account object with a field from the unrelated custom object. Where Account.custom_field == Customobject.custom_Field.

The update can be done in bulk, hence governor limits (SOQL -100) should be respected.

Thanks!


 
I am a long time Salesforce admin/developer but I am still getting started with actually writing Apex code so this is probably a simple error on my part.

I am trying to use batch apex to call the google maps api to avoid limits on @future calls. We have a custom Property__c object and we need to be able load hundreds of records at a time and have them get geocoded.

I can tell from the debug statements that I am successfully passing a set of Ids to the batch apex class. However the database.querlocator does not appear to be getting called. Here is the code:
 
public class batchPropertyGeocode implements Database.Batchable <sObject>, 
Database.AllowsCallouts, Database.Stateful 
{
    Set<Id> propsToGeocode = new Set<Id>();
    //Constructor will take a set of Property Ids
    public batchPropertyGeocode(Set<Id> propsToGeocode) {
        this.propsToGeocode = propsToGeocode;
        System.debug('Creating list of Properties to Geocode: '+this.propsToGeocode);
    }
    
    public Database.QueryLocator start(Database.BatchableContext BC) 
    {
        //Query Properties passed from Trigger
        System.debug('Querying to get Property addresses');
        return Database.getQueryLocator([SELECT Property_City__c,PropertyState__c,
                                         Property_Street_Address__c,PropertyZipCode__c 
                                         FROM Property__c 
                                         WHERE Id IN :propsToGeocode]);
    }
    
    public void execute(Database.BatchableContext BC, List <Property__c> Propertyupdate) 
    {

        List < Property__c > modifiedProps = new list <Property__c> ();
        for (Property__c prop: Propertyupdate) 
        {
            //create a string for the address to pass to Google Geocoding API
            String geoAddress = '';
            if(prop.Property_Street_Address__c!= null)
                geoAddress+= prop.Property_Street_Address__c+ ', ';
            if(prop.Property_City__c != null)
                geoAddress+= prop.Property_City__c+ ', ';
            if(prop.PropertyState__c!= null)
                geoAddress+= prop.PropertyState__c+ ', ';
            if(prop.PropertyZipCode__c!= null)
                geoAddress+= prop.PropertyZipCode__c;
            geoAddress = EncodingUtil.urlEncode(geoAddress, 'UTF-8');
            System.debug('Url Encoded address: '+ geoAddress);
            
            try{
                googleMapsJson gro = callGoogleApex(geoAddress);
                System.Debug(gro.results.size());
                if(gro.results.size() > 0)
                {
                    double lat = gro.results[0].geometry.location.lat;
                    double lon = gro.results[0].geometry.location.lng;
                    
                    if (lat != null) 
                    {
                        system.debug('lat is not null');
                        prop.Geolocation__Latitude__s = lat;
                        prop.Geolocation__Latitude__s = lon;
                        modifiedProps.add(prop);
                        system.debug('Property Location: ' + Prop.Geolocation__Latitude__s );
                    }
                }
                else
                {
                    System.Debug('nothing in list. what am i going to do?');
                }
            } 
            catch (Exception e) {}
            update modifiedProps;
        }
    }
    
    
    
    public static googleMapsJson callGoogleApex(string geoAddress)
    {
        // Key for Google Maps Geocoding API
  		String geocodingKey = 'Actual Google API Key Here';
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        googleMapsJson gro = new googleMapsJson();
        if (geoAddress != null)
        {
            req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address=' + geoAddress +'&key='+ geocodingKey+ '&sensor=false');
            req.setMethod('GET');
            req.setTimeout(6000);
            
            HttpResponse res = h.send(req);
            JSONParser parser = JSON.createParser(res.getBody());
            while(parser.nextToken() != null)
            {
                if(parser.getCurrentToken()==JSONToken.START_OBJECT){
                    gro = (googleMapsJson) parser.readValueAs(googleMapsJson.class);
                }    
            }    
        }
        return gro;
        
    }
    public void finish(Database.BatchableContext BC) { }
}
I would really appreciate some help to get me over the hump.
 
Hi,
Below is my code for the trigger for  duplicate prevention on the account . It works well, but if I have 50k records this impacts scalability and not feasible.
So please any one can help to code in better way.
thanks in advance.
trigger AccountDuplicate on Account (before insert) {
 List<Account> dup = new List<Account>();
 dup = [Select id, Name from Account];
 for(Account a:Trigger.New){
 for(Account a1:dup){
 if(a.Name==a1.Name){
 a.Name.addError('Name already Exist ');
 }
 }
 }   
 }
Hi,
I have a problem with Opportunity related list Quotes.
I can't see the button "New Quote", I  try to modify quote settings in the opportunity layout (like that https://success.salesforce.com/answers?id=90630000000D5QRAA0) but there's no button header, just the column one is visible. How can I do to solve my issue?
 
Has any one heard of Marketing Cloud Lite?
 

Hey Guys,

i am looking for a "best practice" solution, to create a conditionally url button. The button should be placed on the standard page layout.
Related to a value of the object, the button button should redirect the user to a page.

For example, if the status is x, redirect to a new task.
if the status is y, redirect to the homepage.
if the status is z, redirect to an external page.

Unfortunately, a javascript button is not a soultion for lightning.

I have created a controller and a methode to create a conditionally PageReference for each case. I dont think that this solution is best practice. Moreover, i used simply urls like
1new PageReference('https://...............+lead.id');
what is definitely not best practise.  So my button opens the page which is fireing the action methode automatically.

Conclusion, i am looking for : 
- a solution for lightning and classic
- a button placed on the standard page layout
- the button should redirect to different pages related to a value of the object
- a more best practice solution than mine 

I appreciate your help ! 

Cheers, 
Marry
I was planning to bring in data from an external database and found that it will cost us 13+GB of storage. The data has more than 7 million records across 4 tables, so at 2kb per record, the total cost would be 7000000*2/(1024*1024) = 13.4 GB. We would like to search and report on the data and add associated contacts and accounts to campaigns. What are our options?  
Hello Everyone, Hope all are doing good i have some information for you all go through it and give me a reply for that!

Amazon EC2 (AWS Certified)is an Infrastructure as a Service which offers pay-by-hour servers (EC2), storage (S3) etc. You bring your own software to the table – OS (Red Hat, Windows, whatever), Database (MySQL, Oracle, DB2, whatever), Search (your pick), Business Intelligence (Cognos, Oracle BI, whatever) – and then you piece it together and get it all to work. The benefits are that you can do whatever you want – and the con is you have to manage complexity yourself.

Force.com, by contrast, is a Platform as a Service that provides a pre-integrated offering that already has a database, search, BI Reports, identity/security etc. all built in – that you program using a Java-like language (Apex). With the newly announced VMforce, a VMware and Salesforce.com offering, you will be able to use Java soon. Force.com automatically backs up your data, manages upgrades (your apps don’t need to know if Force.com is running on database version 11i or 11g, Dell boxes or Sun boxes, Linux or Windows etc.)

Regards
Sarahjohn
{!REQUIRESCRIPT("/xdomain/xdomain.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
{!REQUIRESCRIPT("/support/console/39.0/integration.js")}

var Program='{!Program_Member_MVN__c.Program_Name__c}';
var Pname=sforce.connection.query("Select Program__c from Program_Names__c");
var rec16 = Pname.getArray('records');
var status='{!Program_Member_MVN__c.Status_MVN__c}';
var PmId='{!JSENCODE(Program_Member_MVN__c.Id)}'; 
var PName='{!Program_Member_MVN__c.Program_Name__c}'; 
var url;
if (sforce.console.isInConsole()) {
if(Program == rec16){
alert("You are on the wrong Program")
} 

else if(status == 'On Therapy')
{
url = "/apex/Milestone_skip?id="+PmId;
window.open(url,'_blank','toolbar=0,location=0,menubar=0,width=800,scrollbars'); 
}  
else
{
alert("Patient must be ‘On-Therapy’ before skipping to a milestone");
}
}

This is my java script on click button code.In this i am querying  custom setting here:var Pname=sforce.connection.query("Select Program__c from Program_Names__c");
And i want to compare to field to show a alert.So i have to multiple values in custom setting.So how can i access all the values given in the custom setting in the java script code?