• Sonam Patil
  • NEWBIE
  • 59 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 10
    Replies
Hi,
I have Company as a custom object, and Company Name as a Salesforce Defined Field in that object.
Can anyone help me to write validation Rule to prevent the duplicate of Company Name

Thanks,
Varalaxmi
 
Hi,
I below trigger and trigger is active,
trigger UpdateAccount on Contact (before insert, before update) {
    Set<ID> accId = new Set<ID>();
    
    for(contact con:Trigger.New){
        accid.add(con.AccountId);
    }
    System.debug('AccID===='+accId);
    Map<ID,Account> accmap = new Map<ID,Account>([Select id, phone from Account where id in:accId]);
    for(contact ct:Trigger.New){
        ct.Phone = accmap.get(ct.AccountId).phone;
    }
    System.debug('accmap===='+accmap);
}
}
But when I am entering the phone value in contact the value is not getting saved in detail page when the trigger is active

User-added image
 
Hi,
In the code below, I could get all the records from the database, but I want to add the row. When I click on ADD button the row is not getting add.
The object is Custom Setting Object. Will addRow functionally work for Custom Settings?
Can anyone Please help me.
Thanks in Advance.


<apex:page controller="Setting">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!save}"/>
                 <apex:commandButton value="ADD" action="{!addRow}"/>
                 <apex:commandButton value="Fetch" action="{!fetch}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!codes}" var="c">
                <apex:column value="{!c.Name}"/>
                <apex:column value="{!c.Code__c}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>
-------------------------------------------------------------------------------------------------------------
public with sharing class Setting {
    public Integer x=0;
    countryCode__c ce = new CountryCode__c();

    public PageReference addRow() {
    CountryCode__c cd = new CountryCode__c();
    codes.add(cd);
     x++;
        return null;
    }


    public PageReference save() {
        return null;
    }


    public List<CountryCode__c> codes { get; set; }
    
        public Setting(){
          codes = new List<CountryCode__c>();
        codes.add(ce);
          
        }
        
        public void fetch(){
       // codes = new List<CountryCode__c>();
            Map<String,CountryCode__c> allcode = countryCode__c.getAll();
            codes = allcode.values();
        }
        
        
}
Hi,
In the below, there are two pageblock, in first block is to display the list of Account and second block is to insert the account.And inserted account in second block should be dynamicaly displayed in 1st block. when I click on Save button it's showing the below error.
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]
 
Please can anyone help me to solve this error.

<apex:page controller="multiAccountInsert">
    <apex:form >
        <apex:pageBlock >
         
            <apex:pageBlockTable value="{!accts}" var="a" reRender="display" >
                  <apex:column value="{!a.Name}"/>  
                  <apex:column value="{!a.Industry}"/>
                  <apex:column value="{!a.phone}"/>             
            </apex:pageBlockTable>
     </apex:pageBlock>
         <apex:pageBlock >
              <apex:pageBlockButtons location="top" >
                <apex:commandButton value="Save" action="{!Save}" id="display"/>
            </apex:pageBlockButtons>
                <apex:pageblocksection >
                    Enter Name: <apex:inputText value="{!at.Name}"/>
                </apex:pageblocksection>
         </apex:pageBlock>
    </apex:form>
</apex:page>
------------------------------------------
public class multiAccountInsert{

    public Account at { get; set; }

    public PageReference Save() {
    at = new Account();
    insert at;
        return null;
    }


    public List<Account> accts {get; set;}
        
        public multiAccountInsert(){
        accts = new List<Account>();
        accts = [Select id, Name, Industry, Phone from Account];
       }
}
Hi,
Below is my code, I am getting the error as:
System.NullPointerException: Argument cannot be null.
Error is in expression '{!Del}' in component <apex:commandButton> in page task9_10: Class.acad.del: line 37, column 1
Class.acad.del: line 37, column 1

Code:
<apex:page standardController="Account" extensions="acad">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Add" action="{!add}" reRender="pb1"/>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
            <apex:pageBlock id="pb1">
            <apex:repeat value="{!lisin}" var="e1">
            
                <apex:panelGrid columns="5">
                    
                    <apex:panelGrid headerClass="name">
                        <apex:facet name="header">Del</apex:facet>
                        <apex:commandButton value="Delete" action="{!Del}"/>
                        <apex:param name="DeleteRow" assignTo="{!SelectedRowIndex}" value="{!e1.recCount}"/>
                    </apex:panelGrid>
                        
                        <apex:panelGrid title="SPD">
                            <apex:facet name="header">Country</apex:facet>
                            <apex:inputField value="{!e1.acc.ShippingCountry}"/>
                        </apex:panelGrid>
                        
                         <apex:panelGrid title="SPD">
                            <apex:facet name="header">Name</apex:facet>
                            <apex:inputField value="{!e1.acc.Name}"/>
                        </apex:panelGrid>
                    
                </apex:panelGrid>
            </apex:repeat>
            </apex:pageBlock>
    </apex:form>
</apex:page>


public with sharing class acad {

    List<Account> lisacc = new List<Account>();
   public List<innercls> lisin{get; set;}
    public String selectedRowIndex;
    public Integer count = 1;
    
    public acad(ApexPages.StandardController controller) {
    lisin = new List<innercls>();
    addmore();
   // selectedRowIndex=1;
    }
    
    public PageReference add(){
    addmore();
    count++;
    return null;
    }
    
    public PageReference Save(){
    PageReference pr = new PageReference('apex/Paginate2');
    for(Integer i=0;i<lisin.size();i++){
    lisacc.add(lisin[i].acc);
    }
    insert lisacc;
    pr.setRedirect(True);
    return pr;
    }
    
    public void addmore(){
    innercls objin = new innercls(count);
    lisin.add(objin);
    
    }
    
    public void del(){
    lisin.remove(Integer.valueof(selectedRowIndex)-1);
    count--;
    }
    
    public class innercls{
    public String recCount{get; set;}
    public Account acc{get;set;}
    
    public innercls(Integer stcount){
    reccount= String.valueof(stcount);
    acc=new Account();
    }
    }

}
Hi,
I am new to integration, I want to prepare for the integration in Salesforce. So please can anyone suggest me the websites for integration preparation, or can share me the links.

Thanks.
Hi,
for the code below I am getting the error as: Error: InsertLead Compile Error: Constructor not defined: [SelectOption].<Constructor>(String, String) at line 15 column 17.
Please Anyone help me in this issue.
code:
<apex:page controller="InsertLead" >
    
        <script type="text/javaScript">
        function Validate(){
        if(document.getElementById('{$component.LF.LDB.LName}').value==''||document.getElementById('{$component.LF.LDB.comp}').value==''){
        alert('Last Name and Company are the required fields');
        }
        else{
         callSubmitted();
         alert('Successfully Inserted');
        }
        }
        </script>
        <apex:form id="LF">
        <apex:actionFunction action="{!submitLead}" name="callSubmitted" reRender="LDB"/>
        <apex:pageBlock id="LDB">
       
        <table>
        <tr>
        <td><apex:outputText value="First Name"></apex:outputtext></td>
        <td><apex:inputText value="{!firstName}"/></td>
        </tr>
         <tr>
        <td><apex:outputText value="Last Name"></apex:outputtext></td>
        <td><apex:inputText value="{!lastName}" id="LName"/></td>
        </tr>
        <tr>
        <td><apex:outputText value="Company"></apex:outputtext></td>
        <td><apex:inputText value="{!company}" id="comp"/></td>
        </tr>
        <tr>
        <td><apex:outputText value="Lead Status"></apex:outputtext></td>
        <td><apex:selectList value="{!statusOption}">
        <apex:selectOptions value="{!items}"/>
        </apex:selectList></td>
        </tr>
        </table>
        <apex:commandButton value="Save" onclick="Validate();"/>
   
    </apex:pageBlock>
    </apex:form>
</apex:page>
------------------------------------------------
Controller Class:
public with sharing class InsertLead {

   // public String items { get; set; }

    public String statusOption { get; set; }

    public String company { get; set; }

    public String lastName { get; set; }

    public String firstName { get; set; }
    
    public Lead l = new Lead();
    public List<selectOption>  getItems(){
    List<selectOption> options= new List<selectOption>();
    options.add(new selectOption('Open- Not Contracted','Open-Not Contracted'));
    options.add(new SelectOption('Working-Contracted','Working-Contracted'));
    return options;
    }

    public PageReference submitLead() {
    l.FirstName=firstname;
    l.LastName=lastname;
    l.Company=company;
    l.Status=statusOption;
        return null;
    }

}
Hi,
Below is my formula, please can anyone help me how to avoide the hard coding in hyperlink.

IF (OR(AND(ISPICKVAL(Apttus__Status_Category__c,"In Effect"),NOT(ISPICKVAL(Apttus__Status__c,"Being Amended")), NOT(ISPICKVAL(Apttus__Status__c,"Being Renewed")))), HYPERLINK("/apex/Apttus__AgreementAmend?id=" &Id, IMAGE("/resource/Apttus__Button_Amend", "Amend"),"_self"),NULL)

Thank You.
Hi,
Can Please anyone help me to deploy the package in the Sandbox using ANT tool.
This Package Contains classes, email, Object, Profole, triggers, workflows, destructiveChangesPost.xml, destructiveChangesPre.xml, Package.xml.
These 9 items  in a package should be deployed.
Anyone please help.

Thanks in advance
 
Hi,

Can anyone please, tell me, in the Sandbox, how to prepare the package.XML so that we can grab all profiles, apex pages, classes, apex components. And also grep for references of classes from pages/triggers and further qualify if classes are in use. And grep for pages in profiles etc and see if it's aligned to any profile to use and/or called from formula fields like hyperlinks.
 
Thanks in advance
Hi,
Can anyone help me with the below requirement, Please


when account activity is captured
store this to dropbox and get the file id
store file id and activity Id to new custom object. ( Activity Drop Box Store )

write first apex batch
For each record in Activity Drop Box Store object
check that there is drop box file present, if not tag the record as delete.

write the second batch
for each file in Drop Box Store object
verify there is activity drop box store if not create activity and related activity drop box record.
 
write scheduler to configure only one of the batch.   The configured batch will invoke the second batch when complete.
 
thanks in advance
Hi,
I want to integrate Salesforce with Drop box.
Please any one help me to do that. or can anyone share any dropbox integration link Document link
Thank you
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 2 object, Phamaceutical company and Drugs, where drug object is in look up relationship with Phamaceutical Company. I have Amount field in drugs and Total Amount in Pharamaceutical Company. Drug which is in lookup relationship with company, Amount of drugs should add up and get populated in total amount of pharmaceutical company.

Please can anyone help me to write formula
Thanks in advance
Hi,
Below is the code of wrapper class of to display the Contacts of selected Accounts and also delete the selected Accounts.
It is displayind the contacts but Account is not getting deleted.
Can anyone help me to solve this problem?

<apex:page controller="charantest">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Select" action="{!selected}"  />
            <apex:commandButton value="Delete" action="{!del}" reRender="pg"/>
        </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!ch}" var="ct">
                <apex:column headerValue="Select" >
                    <apex:inputCheckbox value="{!ct.isSelected}" />
                </apex:column>
                    <apex:column value="{!ct.act.Name}"/>
                    <apex:column value="{!ct.act.Industry}"/>
            </apex:pageBlockTable>
            
            <apex:pageBlockTable value="{!con}" var="c" id="pg">
                <apex:column value="{!c.lastName}"/>
            </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>

</apex:page>

public class charantest {

   
    public List<charnwrap> ch{get;set;}
    public List<ID> acc;
    public List<Contact> con{get;set;}
    
    public Charantest(){
        ch= new List<Charnwrap>();
        for(Account c:[Select id,name,industry from Account limit 5 offset 10]){
        ch.add(new charnwrap(c));
            
        }
        }
        
        public void selected(){
        acc= new List<Id>();
        for(charnwrap cw: ch){
        if(cw.isSelected==true){
        acc.add(cw.act.Id); 
        }
        }
    con=new List<contact>();
    con=[Select Id, lastName from Contact where AccountId=:acc];
    }

 public PageReference del() {
    for(charnwrap wp:ch){
    if(wp.isSelected==true){
    Delete wp.act;
    }
    }
        return null;
    }

    
    
    public class charnwrap{
        public Account act{get;set;}
        public boolean isSelected{get; set;}
        public charnwrap(Account a){
            this.act=a;
            isSelected=false;
        }
    }

}
Hi,
Here is my testClass code.
I am getting error as Assertion failed.
Please Can anyone help me to solve this'

@isTest public class BookTest {
public static @isTest void btest(){
Book__c b = new Book__c(Name='Kcloud', price__c=100);
System.debug('The price of a book before insert is:'+b.Price__c);
 insert b;
b=[Select id,Name,price__c from Book__c where id=:b.id];
System.debug('The price of the book after thr trigger is fired:'+b.Price__c); System.assertEquals(90,b.price__c);
}
}
Hi,
Below is my code for the test class.
I am getting this Exception,
System.sObjectException:sObject row was retrieved via SOQL without querying the required field:Book__c.Price__c.
 
Please, can anyone help me?

@isTest
public class BookTest {
    public static @isTest void btest(){
        Book__c b = new Book__c(Name='Kcloud', 
                                price__c=100);
        System.debug('The price of a book before insert is:'+b.Price__c);
        insert b;
        
        b=[Select id,Name from Book__c where id=:b.id];
        System.debug('The price of the book after thr trigger is fired:'+b.Price__c);
        System.assertEquals(90,b.price__c);
    }  

}​
 
 
Hi,
Can anyone help me.
Below is my code, this is a trailhead challenge.
I am getting this error:Executing the insertNewMethod failed. Either the method does not exist, or not static or doesn't insert a proper method.
public class AccountHandler {
    public static Account insertNewAccount(String abc){
        Account a = new Account();
        if(abc==''){
            try{
                a.Name='abc';
                insert a;
            }
            catch(Exception e){
               // a.Name='abc';
                return null;
            }
        }
            else{
                a.Name='abc';
                insert a;
            }
        
            return a;
        }
  
}
Hi,
Can anyone help me with this scenario?
What Exactly,  if( a.phone!= trigger.oldmap.get(a.id).phone) line does in the below scenario. What does it mean?


trigger contactUpdate_acc on Account (after update) {
    list<contact> ctc =new list<contact>();
    list<account> acc = new list<Account>();
    for(Account a:trigger.new){
        if( a.phone!= trigger.oldmap.get(a.id).phone){
            acc.add(a);
        }
    }
}
Hi,
I am new to SFDC development.

Can anyone explain to me how to write a trigger, if we inserting data in one object and should get updated in another object.
Hi,
Can anyone help me with the below requirement, Please


when account activity is captured
store this to dropbox and get the file id
store file id and activity Id to new custom object. ( Activity Drop Box Store )

write first apex batch
For each record in Activity Drop Box Store object
check that there is drop box file present, if not tag the record as delete.

write the second batch
for each file in Drop Box Store object
verify there is activity drop box store if not create activity and related activity drop box record.
 
write scheduler to configure only one of the batch.   The configured batch will invoke the second batch when complete.
 
thanks in advance
Hi,
I below trigger and trigger is active,
trigger UpdateAccount on Contact (before insert, before update) {
    Set<ID> accId = new Set<ID>();
    
    for(contact con:Trigger.New){
        accid.add(con.AccountId);
    }
    System.debug('AccID===='+accId);
    Map<ID,Account> accmap = new Map<ID,Account>([Select id, phone from Account where id in:accId]);
    for(contact ct:Trigger.New){
        ct.Phone = accmap.get(ct.AccountId).phone;
    }
    System.debug('accmap===='+accmap);
}
}
But when I am entering the phone value in contact the value is not getting saved in detail page when the trigger is active

User-added image
 
Hi,
In the below, there are two pageblock, in first block is to display the list of Account and second block is to insert the account.And inserted account in second block should be dynamicaly displayed in 1st block. when I click on Save button it's showing the below error.
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account Name]: [Account Name]
 
Please can anyone help me to solve this error.

<apex:page controller="multiAccountInsert">
    <apex:form >
        <apex:pageBlock >
         
            <apex:pageBlockTable value="{!accts}" var="a" reRender="display" >
                  <apex:column value="{!a.Name}"/>  
                  <apex:column value="{!a.Industry}"/>
                  <apex:column value="{!a.phone}"/>             
            </apex:pageBlockTable>
     </apex:pageBlock>
         <apex:pageBlock >
              <apex:pageBlockButtons location="top" >
                <apex:commandButton value="Save" action="{!Save}" id="display"/>
            </apex:pageBlockButtons>
                <apex:pageblocksection >
                    Enter Name: <apex:inputText value="{!at.Name}"/>
                </apex:pageblocksection>
         </apex:pageBlock>
    </apex:form>
</apex:page>
------------------------------------------
public class multiAccountInsert{

    public Account at { get; set; }

    public PageReference Save() {
    at = new Account();
    insert at;
        return null;
    }


    public List<Account> accts {get; set;}
        
        public multiAccountInsert(){
        accts = new List<Account>();
        accts = [Select id, Name, Industry, Phone from Account];
       }
}
Hi,
I want to work on below task, Can anyone please help me in that task

Create a visual force page with two page blocks, one showing the existing Accounts and another for inserting new accounts. The inserted account also needs to be dynamically displayed in the existing Account list.

Thanks in Advance.
Hi,
for the code below I am getting the error as: Error: InsertLead Compile Error: Constructor not defined: [SelectOption].<Constructor>(String, String) at line 15 column 17.
Please Anyone help me in this issue.
code:
<apex:page controller="InsertLead" >
    
        <script type="text/javaScript">
        function Validate(){
        if(document.getElementById('{$component.LF.LDB.LName}').value==''||document.getElementById('{$component.LF.LDB.comp}').value==''){
        alert('Last Name and Company are the required fields');
        }
        else{
         callSubmitted();
         alert('Successfully Inserted');
        }
        }
        </script>
        <apex:form id="LF">
        <apex:actionFunction action="{!submitLead}" name="callSubmitted" reRender="LDB"/>
        <apex:pageBlock id="LDB">
       
        <table>
        <tr>
        <td><apex:outputText value="First Name"></apex:outputtext></td>
        <td><apex:inputText value="{!firstName}"/></td>
        </tr>
         <tr>
        <td><apex:outputText value="Last Name"></apex:outputtext></td>
        <td><apex:inputText value="{!lastName}" id="LName"/></td>
        </tr>
        <tr>
        <td><apex:outputText value="Company"></apex:outputtext></td>
        <td><apex:inputText value="{!company}" id="comp"/></td>
        </tr>
        <tr>
        <td><apex:outputText value="Lead Status"></apex:outputtext></td>
        <td><apex:selectList value="{!statusOption}">
        <apex:selectOptions value="{!items}"/>
        </apex:selectList></td>
        </tr>
        </table>
        <apex:commandButton value="Save" onclick="Validate();"/>
   
    </apex:pageBlock>
    </apex:form>
</apex:page>
------------------------------------------------
Controller Class:
public with sharing class InsertLead {

   // public String items { get; set; }

    public String statusOption { get; set; }

    public String company { get; set; }

    public String lastName { get; set; }

    public String firstName { get; set; }
    
    public Lead l = new Lead();
    public List<selectOption>  getItems(){
    List<selectOption> options= new List<selectOption>();
    options.add(new selectOption('Open- Not Contracted','Open-Not Contracted'));
    options.add(new SelectOption('Working-Contracted','Working-Contracted'));
    return options;
    }

    public PageReference submitLead() {
    l.FirstName=firstname;
    l.LastName=lastname;
    l.Company=company;
    l.Status=statusOption;
        return null;
    }

}
Hi,
I want to integrate Salesforce with Drop box.
Please any one help me to do that. or can anyone share any dropbox integration link Document link
Thank you
Hi,
I have a 2 object, Phamaceutical company and Drugs, where drug object is in look up relationship with Phamaceutical Company. I have Amount field in drugs and Total Amount in Pharamaceutical Company. Drug which is in lookup relationship with company, Amount of drugs should add up and get populated in total amount of pharmaceutical company.

Please can anyone help me to write formula
Thanks in advance
Hi,
Below is my code for the test class.
I am getting this Exception,
System.sObjectException:sObject row was retrieved via SOQL without querying the required field:Book__c.Price__c.
 
Please, can anyone help me?

@isTest
public class BookTest {
    public static @isTest void btest(){
        Book__c b = new Book__c(Name='Kcloud', 
                                price__c=100);
        System.debug('The price of a book before insert is:'+b.Price__c);
        insert b;
        
        b=[Select id,Name from Book__c where id=:b.id];
        System.debug('The price of the book after thr trigger is fired:'+b.Price__c);
        System.assertEquals(90,b.price__c);
    }  

}​
 
 
Hi,
I am new to SFDC development.

Can anyone explain to me how to write a trigger, if we inserting data in one object and should get updated in another object.