• Gauravendra
  • SMARTIE
  • 570 Points
  • Member since 2018
  • Salesforce Developer


  • Chatter
    Feed
  • 18
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 86
    Replies
help me with trigger code.
An object has FirstName and LastName field, if we try to create a record with same FristName and LastName, record should not create(throws error).
 
I have created an Aura component which is a table.
I wish to visualize it in the page of each contact, for example in the Details tab.
How can I do that?

Thanks
-we are currently sending all the Invoices from the Platform to Salesforce (via the famous web-service)
-by having those invoices in SF, we can create reports
-but could we report on those invoice by simply doing an “api call” or something similar to the Platform instead of storing the data in SF (ie instead of duplicating in SF the data that is in the Platform)?
  • June 28, 2019
  • Like
  • 0
I would like to keep track of the instance names of orgs I am the administrator for without having to manually handle instance refreshes. Periodically querying those orgs would allow me to access a reletively up-to-date list of clients that are affected by issues listed on trust.salesforce.com.

Is this possible?
Hello,
i dont see the option to manuallu share the lead to a user, how can i do it.
thansk for suggestion
HI Wondering if anyone can help a newbie here in trouble !  

I'm trying to write a test class for this class which uses an ivokable method callled by process builder. I'm getting the following error on the test class can anyone direct me as to where i'm going wrong ? 
: Compile Error: Method does not exist or incorrect signature: void invokeapexcallout(List<String>, List<Id>) from the type MakeApexCallout at line 29 column 28

Here is my class : 

public class MakeApexCallout {

  @InvocableMethod(label='callout')
   public static void invokeapexcallout(list<Account> acc) {
     Futureapexcallout.apexcallout(acc[0].Siret_Number__c,acc[0].Id);
   }
}


My Test Class 

@IsTest

public Class MakeApexCalloutTest {

static testMethod void CallOutTest() {

   

// Create Account
          
        Account acc = new Account();

        acc.Name = 'test Account';

        acc.Siret_Number__c = '42097142600035';
        
        insert acc;
            
           List<Id> AccountIds = new List<Id>(); 
           AccountIds.add(acc.Id);
           List<String> SiretNumbers= new List<String>();
          
          SiretNumbers.add(acc.Siret_Number__c);


            Test.startTest();

         
           MakeApexCallout.invokeapexcallout(SiretNumbers, AccountIds);
            Test.stopTest();

}}


 
Hi All,
      i want to develope a batch for my requirement is to Fetch All opportunities which  has recordtype =time rack , 
       and check if their name STARTS with  thier Related account's name then update name of opportunity  Should be in this format - {!Account.Name} : Opportunity Name and populate Opportunity's field Customer Type = 'End User' on opportunity.

Ex:  Opportunity name is ABC 1234 and account name is ABC  Than after running the batch OppName would become- ABC: 1234 and its customer type should become -'End User'
Im not sure how to get started unit test this method below.
private static double setAfterSave(Opportunity deal) { 
        double returnValue;
        if(deal.Restaurant__c) {            
          returnValue = deal.HVAC__c == null ? 0 : deal.HVAC__c;
        } else {
           returnValue = deal.HVAC__c == null ? 0 : deal.HVAC__c;
        }
        return returnValue;
    }
  • March 05, 2019
  • Like
  • 0
var action = component.get("c.fetchData");
   action.setCallback(this, function(response) {
                        var state = response.getState();
                        console.log("State " + state);
                        if (state === "SUCCESS") {
                            var storeResponse = response.getReturnValue();
                            component.set("v.Customer", storeResponse);
                            var Credit = storeResponse.field__c;
                            console.log("Credit  "+Credit);
                        } });
                    $A.enqueueAction(action);
                }

Not able to access "response.getReturnValue();" outside of setcallback, How to do that ?
  • June 08, 2018
  • Like
  • 0
Hi Guys - I have written a controller which is being used in an vf component. My issue is I need to display adresses comma seperated.
pls suggest 

controller
------------
public with sharing class DisplayList{ 
    public List<Address__c> Records {get; set;} 
    
    public DisplayList(){ 
    Records = [SELECT Name 
               FROM Address__c
               WHERE Billing_Account__c = :ApexPages.currentPage().getParameters().get('Id')];
    system.debug('record-->'+Records); 
    } 
 }
vf component snippet
=----------------------------
 </apex:repeat>
        <apex:repeat value="{!Records}" var="Record">
         <div><span>Service Addresses:</span><span><apex:outputText value="{!Record.Name}" escape="false"/></span></div>
    </apex:repeat>
 
Hi,
I am trying to display the opportunitycontactroles list on an object (Deal_Desk_Request__c) related to the opportunity.  I am not getting errors when saving the code, but nothing is appearing in the visualforce page other than the headers.  I am new to apex/visualforce development and not sure what I am doing wrong.  Can someone please help?

Here is the visualforce page:
<apex:page standardcontroller="deal_desk_request__c" extensions="dealdeskcontactrole" >
  <apex:pageblock >
      <apex:pageblocktable value="{!roles}" var="role">
          <apex:column headervalue="Contact" >
                      <apex:outputfield value="{!role.contactid}"/>
                      </apex:column>     
          <apex:column headervalue="Role" >
                      <apex:outputfield value="{!role.role}"/>
                      </apex:column>           
          <apex:column headervalue="Primary" >
                      <apex:outputfield value="{!role.isprimary}"/>
                      </apex:column>           


      </apex:pageblocktable>
  </apex:pageblock>
</apex:page>

Here is the extension class:
public with sharing class dealdeskcontactrole {
list<opportunitycontactrole> roles;
 public final Deal_Desk_Request__c DDR;
    public dealdeskcontactrole(ApexPages.StandardController controller) {
   
        this.DDR = (Deal_Desk_Request__c)controller.getRecord();
    }

    public list<opportunitycontactrole> getroles() {
        try{
        list<opportunitycontactrole> roles = [select id, contactID, Role, Isprimary from opportunitycontactrole where Opportunityid =: DDR.Opportunity__r.id];
         return roles;
        }
        catch(system.exception e){
        return null;
        }     
    }
   }

 
Hi Team,

I have amount__c in both contact and account . if account has many contacts  and i need to update highest amount of contacts and update that into account amount field ?

Ex : ABC account   Amount__c  =

       Contact1 :  T -- Amount__c = 500$
       Contact2 :  A -- Amount__c = 700$
       Contact3 :  B -- Amount__c =300$

now account amount__c need to update with 700$ . how can i acheive it using trigger
I have a requirement for PAN Number field should include 5 text, 4 Number and 1 Text characters should include for that i wrote validation rule.
Rule passed succesfully, but record is not saving in any formates. Can you please let me know the my mistake.

NOT(AND( 
(REGEX( PAN_Number__c , "[A-Z][a-z]{5}[0-9]{4}[A-Z][a-z]{1}") ), 
LEN( PAN_Number__c) <> 10))

User-added image
Thanks in Advance!
SyamReddy.
Hi Guys,

I have a requirement ..i  need to create a visualforce page which will display all account names in custom picklist.
Please help me on this.

Thanks in Advance.
Smitha
Hi, 
I want to develop a page which has two radio button as options : radio1  and radio2 . on click of radio1 a form of account should be avaialble and on click of radio2 a form of contact should be available. 

I have my code but on click of both radio button it is redirecting to contact page only. can u help me to solve my issue

<apex:page controller="AccController">
 <apex:form >
 <apex:pageBlock id="pgblk"> 
 <apex:selectRadio id="radioid" layout="pageDirection">
 <apex:selectOption  itemLabel="radio1" itemValue="1"></apex:selectOption>
 <apex:actionSupport event="onclick" action="{!AccForm}">
 </apex:actionSupport>
 
 <apex:selectOption itemLabel="radio2" itemValue="2"></apex:selectOption>
 <apex:actionSupport event="onclick" action="{!ContForm}">
 </apex:actionSupport>
 </apex:selectRadio>
 
 </apex:pageBlock>
 </apex:form>
</apex:page>

Here is my controller
public class AccController 
{
 public PageReference AccForm()
 {
 PageReference Page = new PageReference('/apex/CreateAcc');
 Page.setRedirect(true);
 return Page;
 }
 
 public PageReference ContForm()
 {
 PageReference Page = new PageReference('/apex/CreateContact');
 Page.setRedirect(true);
 return Page;
 }
}
while saving 11th  record it should show an error while saving that limit had exceeded

I am trying to display a selectList in a visualforce page using a custom controller i built.

I get an "List has no rows for assignment to SObject" error when trying to preview the page, but running the query in the developer console, returns the rows.

here is my page:
 

<apex:page Controller="BpmIcountPayment">
    <apex:param name="first_name" value="Account.FirstName"/>
    <apex:param name="last_name" value="Account.LastName"/>
    <apex:param name="id" value="Account.idnumber__c"/>
    <apex:param name="address" value="Account.Address"/>
    <apex:form >
        <apex:selectList value="{!productsTitle}" multiselect="false">
            <apex:selectOptions value="{!ProductsLov}"></apex:selectOptions>
        </apex:selectList>
        </apex:form>
</apex:page>

and my controller:

public class BpmIcountPayment{

    private final Account account;

    public String productsTitle {
      get { return 'products for sale'; }
      set;
    }
 
    public BpmIcountPayment() {
        account = [SELECT Id, Name, Site FROM Account
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getAccount() {
        return account;
    }

    public List<SelectOption> getProductsLov() {
        List<SelectOption> products = new List<SelectOption>();
        List<Product2> productsList = [SELECT Id, Name, Family 
                                      FROM Product2 
                                      WHERE (Family = 'ShopProduct') 
                                      OR (Family = 'CourseParent') 
                                      OR (Family = 'SFCourseProgram')];

        system.debug(productsList);
        for (Product2 currProduct : productsList) {
            products.add(new SelectOption(currProduct.Id, currProduct.Name));
        }

        return products;
    }
}
Am, using the concept of Wrapper class. I want to delete recently created contact record from pageBlockTable.
I am facing Unknown property 'SingleRecordDelete.ContactWrp.id' Error
Here is What I did--

VF page

<apex:page controller="SingleRecordDelete">
  <apex:form >
     <apex:pageBlock title="Contacts">
          <apex:pageBlockSection title="New Contact" columns="2" id="fresh">
              <apex:inputText label="FirstName" value="{!fname}" />
              <apex:inputText label="LastName" value="{!lname}"/>
              <apex:commandButton action="{!save}" value="Save" reRender="lab,fresh"/>
          </apex:pageBlockSection> 
         
          <apex:pageBlockSection title="ContactList" id="lab">
              <apex:pageBlockTable value="{!crp}" var="cy" id="update">
                  <apex:column headerValue="FirstName">
                      <apex:outputLabel value="{!cy.cn.firstname}"/>
                  </apex:column>
                  <apex:column headerValue="LastName">
                      <apex:outputLabel value="{!cy.cn.lastname}"/>
                  </apex:column>
                  <apex:column >
                         <apex:commandLink value="Delete" action="{!doDelete}" style="color:Red" reRender="lab">
                             <apex:param name="did" value="{!cy.id}" assignTo="{!did}"/>
                         </apex:commandLink>
                  </apex:column>
                  
              </apex:pageBlockTable>
                  
          </apex:pageBlockSection> 
               
     </apex:pageBlock>
  </apex:form>
</apex:page>

ApexClass
public with sharing class SingleRecordDelete {

    public String fname {get;set;}
    public String lname {get;set;}
    public String did {get;set;}
    
    public List<ContactWrp> crp {get;set;}
    
    public SingleRecordDelete(){
        crp = new List<ContactWrp>();
        
    }
    
    public void save(){
      Contact c = new Contact();
      c.firstname = fname;
      c.lastname = lname;
      insert c;
      crp.add(new ContactWrp(c));
      fname='';
      lname='';
    }
    
    public void doDelete()
    {
        List<Contact> contactToBeDelete = new List<Contact>();
        Contact cod = [select id from Contact where id =: did];
        contactToBeDelete.add(cod);
        delete contactToBeDelete;
    }
    
     public class ContactWrp{
    
      public Contact cn {get;set;}
      
        public ContactWrp(Contact cs){
            this.cn = cs;                   
        }
    }
}
help me with trigger code.
An object has FirstName and LastName field, if we try to create a record with same FristName and LastName, record should not create(throws error).
 
I have written process builder flow for an email alert. The first set of criteria is met to send an email alert the first time the criteria is met. The second set of criteria is met to send an email any time the fields change after the initial criteria being sent. Right now it is skipping the initial criteria alert and only sending the ischanged criteria. Not sure what to do to correct this.

Initial Criteria to be Met to Send Initial Email
User-added image
Initial Crtieria Above defined
Initial Criteria:
 
  1. Stage Name equals Closed Won
  2. Foot Traffic Reports equals DAP
  3. Foot Traffic Reports equals DAP2
  4. Foot Traffic Reports equals DAP3
  5. Cross-Channel Reports Is Null False
  6. MTA Reports Is Null False
  7. TV Reports equals Grace
  8. TV Reports equals Tune
  9. Measurement Reports Offered equals Yes
  10. Record Type Name equals Viant MS
  11. Last Modified Profile ID equals xxxxx1
  12. Last Modified Profile ID equals xxxxx2
Filter Logic
(1 AND 9 AND 10 AND (11 OR 12)) AND (2 OR 3 OR 4 OR 5 OR 6 OR 7 OR 8)

Advanced is checked as yes

IsChanged Criteria after Initial Criteria being met
User-added image
Hi All,

If we have 2 record types with different fields and If we insert or update the records using data loader with specific record type like record type A.

Will it insert in that record type only or both? or If we give data to that both fields in both records irrespective of record type we give it will insert both fields in both records.

Thanks,
Sirisha
Hello all, I am trying to create a user with User License "Salesforce"..but I could only find  "Chatter external", "Chatter free" and  "Salesforce Platform" only. Please help me  why I couldnt find "Salesforce" under user license..
Appreciate your help, thanks in advance
What is wrong with my code?

Description: The purpose of this code is to create multiple records based on two conditions
  1. Custom Picklist: Value = Yes (condition set in process builder)
  2. (Number Field) Contract Term (Number of years) =
So whatever is the value entered in the contract term custom field, those many child record would be created.
Parent Object: Opportunity Contract
Child Object: Annual Maintenance
Error in Production
This code is working fine in Developer Sandbox, after I installed in Production, this program is working as expected with the opportunity contract records which were previously created (before deploying this code)
However, this code does not work with opportunity contract records which are created after the deployment.
The error I am geting is “dereference a null object”
Where am I going wrong? Why this behaviour of working for existing records and not working with new records in Production?

Finally i have recomplied all Apex Classes in Production, but the result is the same

Any Help is highly appreciated!


Below is the code
public class OppConAMInvocableClass {
    @InvocableMethod(label='Insert Child Records for Opportunity Contracts' description='Inserts the child records based on number of contract years.')
  public static void insertChildRecords(List<Opportunity_Contract__c> parentList) {
      List<Annual_Maintenance__c> childrecords = new List<Annual_Maintenance__c>();       
      for(Opportunity_Contract__c parent : parentList) {
        Integer numberYears = Integer.valueOf(parent.Contract_Years__c);
        for(Integer i=1;i<numberYears;i++) {
        //Account acct = [SELECT Id FROM Account where Id = :e.WhatId];
        Integer j = i + 1;         
        Annual_Maintenance__c child = new Annual_Maintenance__c();
           
         
            Child.Anniversary_Date__c=Parent.Annual_Renewal_Date__c.addYears(i); 
            Child.Name=Parent.Name+'-'+Child.Anniversary_Date__c.year();
            Child.Number_of_sites__c=Parent.Number_of_Sites__c;
            Child.Opportunity_Department__c =Parent.Opportunity_Department__c;
            Child.Account__c=Parent.Account_Name__c;
            Child.Primary_Contact__c=Parent.Primary_Contact__c;
            Child.Annual_Maintenance_Start_Date__c=Parent.Contract_Start_Date__c;
            Child.Annual_Maintenance_End_Date__c=Parent.Contract_End_Date__c;
            Child.Opportunity_Name__c=Parent.Opportunity_Name__c;
          Child.Anniversary_Date__c=Parent.Annual_Renewal_Date__c;
            Child.Sales_Territory__c=Parent.Sales_Territory__c;
     Child.Annual_Maintenance_Amount__c=Parent.SMS_Maintenance_Amount__c;
        child.Opportunity_Contract__c=parent.Id;
        childrecords.add(child);
        }
      }   
    Database.SaveResult[] results = Database.insert(childrecords);
    /*
    List<ID> itemIds = new List<ID>();
    for (Database.SaveResult result : results) {
      if (result.isSuccess()) {
        itemIds.add(result.getId());
      }
    }
    return itemIds;
    */
  }
}






 
 
I have created an Aura component which is a table.
I wish to visualize it in the page of each contact, for example in the Details tab.
How can I do that?

Thanks
-we are currently sending all the Invoices from the Platform to Salesforce (via the famous web-service)
-by having those invoices in SF, we can create reports
-but could we report on those invoice by simply doing an “api call” or something similar to the Platform instead of storing the data in SF (ie instead of duplicating in SF the data that is in the Platform)?
  • June 28, 2019
  • Like
  • 0
I would like to keep track of the instance names of orgs I am the administrator for without having to manually handle instance refreshes. Periodically querying those orgs would allow me to access a reletively up-to-date list of clients that are affected by issues listed on trust.salesforce.com.

Is this possible?
I have an external app that I would like to use to create records of a custom object through the rest API. I can create Accounts just fine, but have not been able to replicate that functionality for any custom object.

I took a look at workbench.developerforce.com, and found that the rest explorer is not returning information about any custom objects.

I am logged in as a system administrator, so I should have access to everything. What am I doing wrong?
Hello,
i dont see the option to manuallu share the lead to a user, how can i do it.
thansk for suggestion
Hi Team,

Batch Apex Mass Upload Issue ?
Requirement : Need to Update Account fileds from Custom object based on condition.For 1 record we need to update around 5000 Account records with some value.
How can we achieve this request ?
I have tried with trigger and batch apex, for 1 record it is working. But mass upload it is not working.

Please advise any one.

Thanks,
Lakshmi S.
Hello friends,
This query returns results when I run it developer console's Query Editor and the Workbench's Query Editor.
 
select Id, Name, Campaign_Name__c, RecordType.Name from Campaign__c where Campaign_Name__c LIKE '%\_%'


However, when I try to use it in Execute Anonymous it returns nothing. I've also tried using // instead of / . 

 

Has anybody else run into this?

I have the following class that is hitting cpu time limit exception. still learning so help very much appreciated!!  When its working I'll put it in a schedulable class. 
 
public class test1 {
 public static void test1() {
      
     Map<id,account> aMap = new Map<id,account>([Select Id,Name, Total_number_of_open_opportunities__c,Total_number_of_open_Upsel_opportunities__c, No_of_days_since_last_AE_activity__c
                        FROM ACCOUNT WHERE Assigned_AE__c != null AND (Assigned_AE__r.profile.Name = 'Sales Executive' OR 
   Assigned_AE__r.profile.Name = 'Premier Account Executive') AND No_of_days_since_AE_assigned__c >=60]);
     List<account> acc =  aMap.values() ;
   
   system.debug(acc.size());
   
   List<Opportunity> opps = new List<Opportunity>();    //list of all open opps
   List<account> acc1 = new List<account>();  
 
   
     
  if(acc.size() > 0)
   {
  // Query to get all open opportunites with no stage change in over 60 days 
   Map<id,opportunity> aMap2 = new Map<id,opportunity>([SELECT Id,accountid FROM Opportunity 
                                     WHERE AccountId IN :acc AND ISCLOSED = FALSE AND days_since_last_stage_change__c > 60 AND (RecordType.Name= 'New Business' OR RecordType.Name= 'Upsell')]);
       
       opps = aMap2.values() ;
   
  
     for (account a : acc )
     {
       
         
       If((a.Total_number_of_open_opportunities__c == 0 && a.Total_number_of_open_Upsel_opportunities__c == 0) || (a.No_of_days_since_last_AE_activity__c > 30 || a.No_of_days_since_last_AE_activity__c == 0) || opps.size()>0)
        { 
           
            a.Assigned_AE__c = null;
            acc1.add(a);
        }
       
     }
     update acc1;
   }
}
}


 
Hi, 

   Like ISNEW() function is there any methods or way to identify a record a deleted please suggest. 

  I want to avoid users deleting from quotelines when quote is approved or pending 

Thanks
Sudhir
My SOQL: [SELECT ID,Name, Status FROM Lead WHERE CreatedDateNotEqualToLastModified__c = TRUE AND LastModifiedDate >= LAST_N_DAYS:2];

Can anyone help with this URGENT?????