• vishal yadav 86
  • NEWBIE
  • 40 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 14
    Replies
I want to create lightning components one to display case comments and one for adding a new case comment. Once case commnet added using event show new case comment.
Can this be achieved using out of box or should go for customization?
I need to display accounts and related contacts using single SOQL query on pagebock table.
How to acheive this?
Can we customize standard error message for duplicate rule using apex.
Few scenarios where we create components, event and lightning data table instead of
of Flows and Process Builder.
I have one requirement to create a custom-sidebar component on lead standard page
I want to write a trigger to convert lead after updating the status field to "working-contacted".
Review the errors on this page.
VishalYadav.LeadTrigger: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, convertedStatus is required.: [Status] Trigger.VishalYadav.LeadTrigger: line 8, column 1

TRIGGER:
----------
Trigger LeadTrigger on Lead (after update) {
    For(Lead l: Trigger.new)
    {
        if(l.IsConverted == false)
        {
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(l.id);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            System.assert(lcr.isSuccess());
        } }
}
Created web to lead but couldn't capture leads.
ERROR:
Lead Convert Page not available.
Also how to apply validation rules to lead conversion web page.
Visualforce Error Help for this Page  System.EmailException: SendEmail failed. First exception on row 5; first error: SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: [] Error is in expression '{!sendEmail}' in component <apex:commandButton> in page acnt
I am displaying accounts and related contacts using map(inner query).
Now when I click the remove button on contact record that record should be removed from the Vf page.
Upon selecting the checkbox value of account records I am displaying related contact records in same page with two pageblocktables.
My requirement is, Upon selecting the next checkbox next related contacts should be displayed along with the previous contact also.
If there are no contacts it should display string value in the contacts table.
VF RAMEWORK ==>
<apex:page showheader="false" tabstyle="Opportunity" controller="Acnt_Rltd_CntctClass1">
<apex:sectionHeader title="RECORDS DISPLY" subtitle="ACCOUNTS DISPLAY"/>
<apex:form >
<apex:pageblock title="MAIN BLOCK">
<apex:PageBlockTable value="{!acclist}" var="a">
<apex:column headerValue="ACCOUNT NAME">
<apex:commandlink >
{!a.name}
</apex:commandlink>
</apex:column>
<apex:column headerValue="PHONE">
{!a.phone}
</apex:column>
<apex:column headerValue="RATING">
{!a.rating}
</apex:column>
</apex:PageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
VF CONTROLLER==>
public class Acnt_Rltd_CntctClass1 
{
    public List<Account> acclist{set;get;}
    public Acnt_Rltd_CntctClass1()
    {
      acclist = new List<Account>();
      acclist = [select name, phone, rating from account];
    }
}
ERROR :
This page has an error. You might just need to refresh it. Unable to find action 'ShowDetails' on the controller of VishalYadav: Revision_Component Failing descriptor: {VishalYadav: Revision_Component}
Visualforce Error
Help for this Page
System.DmlException: Insert failed. First exception on row 0 with id 0012v00002kVoWWAA0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Error is in expression '{!InsertSelectedRecords}' in component <apex:commandButton> in page selectedpage: Class.Acc_Dynamic.InsertSelectedRecords: line 30, column 1
Class.Acc_Dynamic.InsertSelectedRecords: line 30, column 1
public class Acc_Dynamic 
{
   Public List<AccAll> acl{set;get;}
   Public Acc_Dynamic()
    {
      acl=new List<AccAll>();
        for(Integer i=0;i<10;i++)
        {
          Account acc=new Account();
          acl.add(new AccAll(acc,false));
        }        
    }
    public class AccAll
    {
        Public Account accs{set;get;}
        Public Boolean flag{set;get;}
        public AccAll(Account acs,Boolean flg)
        {
          accs=acs;
          flag=flg;
        }   
    }
}
CAN WE ACHIEVE THE ABOVE REQUIREMENT BY USING WRAPPER CLASS?
I MEAN WITHOUT GIVING 10 VARIABLES TO STORE THE VALUES OF INPUT TEXT BOXES [DYNAMICALLY].

 
VF PAGE CODE :
<apex:page controller="InsertAcc_Con" sidebar="False" tabstyle="Campaign">
<apex:sectionHeader title="Main Section" subtitle="Recrd Insertion"/>
<apex:form >
<apex:PageBlock title="Record Insert Block">
<apex:PageblockSection title="New Account Section" id="Accblock">
<apex:inputText label="Name" value="{!Nval}"/>
<apex:inputText label="Phone" value="{!Pval}"/>
<apex:inputText label="Website" value="{!Wval}"/>
<apex:commandButton value="Insert" action="{!InsertAccount}" rerender="Accblock"/>
</apex:PageblockSection>
<apex:PageblockSection title="New Contact Section" id="ConBlock">
<apex:inputText label="First Name" value="{!Fval}"/>
<apex:inputText label="Last Name" value="{!Lval}"/>
<apex:inputText label="Phone" value="{!CPval}"/>
<apex:inputText label="Fax" value="{!CFval}"/>
<apex:commandButton value="Insert" action="{!InsertContact}" rerender="ConBlock"/>
</apex:PageblockSection>
</apex:PageBlock>
</apex:form>
</apex:page>

VF CONTROLLER CLASS :
public class InsertAcc_Con
{
    public string Nval{get;set;}
    public string Pval{get;set;}
    public string Wval{get;set;}
    public void InsertAccount()
    {
        account acc = new account();
        acc.name = Nval;
        acc.phone = Pval;
        acc.website = Wval;
        insert acc;
    }
    public string Fval{get;set;}
    public string Lval{get;set;}
    public string CPval{get;set;}
    public string CFval{get;set;}
    Public void InsertContact()
    {
        contact con = new contact();
        con.firstname = Fval;
        con.lastname = Lval;
        con.phone = CPval;
        con.fax= CFval;
        insert con;
    }
Hi,
Can anyone help me out with few Coding questions related to salesforce.
Why the name is not displaying in hyperlink format.
Any erro rin the code? 

<apex:page sidebar="false" controller="accountsControler">
<apex:sectionheader title="List" subtitle="Contacts List">
<apex:form >
<apex:pageBlock title="List Of Contacts" >
<apex:pageBlockTable value="{!conlst}" var="con">
<apex:column value="{!con.name}"/>
<apex:column value="{!con.phone}"/>
<apex:outputLink value="/{!con.id}" target="_blank">
{!con.name}
</apex:outputLink>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>>
</apex:sectionheader>
</apex:page>
I need to display accounts and related contacts using single SOQL query on pagebock table.
How to acheive this?
Can we customize standard error message for duplicate rule using apex.
I want to write a trigger to convert lead after updating the status field to "working-contacted".
Review the errors on this page.
VishalYadav.LeadTrigger: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, convertedStatus is required.: [Status] Trigger.VishalYadav.LeadTrigger: line 8, column 1

TRIGGER:
----------
Trigger LeadTrigger on Lead (after update) {
    For(Lead l: Trigger.new)
    {
        if(l.IsConverted == false)
        {
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(l.id);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            System.assert(lcr.isSuccess());
        } }
}
Created web to lead but couldn't capture leads.
ERROR:
Lead Convert Page not available.
Also how to apply validation rules to lead conversion web page.
VF RAMEWORK ==>
<apex:page showheader="false" tabstyle="Opportunity" controller="Acnt_Rltd_CntctClass1">
<apex:sectionHeader title="RECORDS DISPLY" subtitle="ACCOUNTS DISPLAY"/>
<apex:form >
<apex:pageblock title="MAIN BLOCK">
<apex:PageBlockTable value="{!acclist}" var="a">
<apex:column headerValue="ACCOUNT NAME">
<apex:commandlink >
{!a.name}
</apex:commandlink>
</apex:column>
<apex:column headerValue="PHONE">
{!a.phone}
</apex:column>
<apex:column headerValue="RATING">
{!a.rating}
</apex:column>
</apex:PageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
VF CONTROLLER==>
public class Acnt_Rltd_CntctClass1 
{
    public List<Account> acclist{set;get;}
    public Acnt_Rltd_CntctClass1()
    {
      acclist = new List<Account>();
      acclist = [select name, phone, rating from account];
    }
}
ERROR :
This page has an error. You might just need to refresh it. Unable to find action 'ShowDetails' on the controller of VishalYadav: Revision_Component Failing descriptor: {VishalYadav: Revision_Component}
public class Acc_Dynamic 
{
   Public List<AccAll> acl{set;get;}
   Public Acc_Dynamic()
    {
      acl=new List<AccAll>();
        for(Integer i=0;i<10;i++)
        {
          Account acc=new Account();
          acl.add(new AccAll(acc,false));
        }        
    }
    public class AccAll
    {
        Public Account accs{set;get;}
        Public Boolean flag{set;get;}
        public AccAll(Account acs,Boolean flg)
        {
          accs=acs;
          flag=flg;
        }   
    }
}
CAN WE ACHIEVE THE ABOVE REQUIREMENT BY USING WRAPPER CLASS?
I MEAN WITHOUT GIVING 10 VARIABLES TO STORE THE VALUES OF INPUT TEXT BOXES [DYNAMICALLY].

 
Why the name is not displaying in hyperlink format.
Any erro rin the code? 

<apex:page sidebar="false" controller="accountsControler">
<apex:sectionheader title="List" subtitle="Contacts List">
<apex:form >
<apex:pageBlock title="List Of Contacts" >
<apex:pageBlockTable value="{!conlst}" var="con">
<apex:column value="{!con.name}"/>
<apex:column value="{!con.phone}"/>
<apex:outputLink value="/{!con.id}" target="_blank">
{!con.name}
</apex:outputLink>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>>
</apex:sectionheader>
</apex:page>
My task is when opportunity is "closed won"  automaticlly it should create order(populate opportunity fields) and orderitems(all opportunitylineitem products should be created in it).

I am pretty new to Salesforce development. Can anyone give me suggestion to do this.
trigger name on Opportunity (after update) {
set<id> ids = new set<id>();
for(opportunity O:trigger.new) {
if(O.StageName =='ClosedWon'){
ids.add(O.id);
}}
orderItem orl = new orderItem(); 
Opportunity opp = [select id,AccountId,CloseDate,(select Name,ProductCode,Quantity,OpportunityId 
                                  from OpportunityLineItems)
                           from Opportunity 
                           where  id in:Trigger.NewMap.keySet() AND Opportunity.StageName =: 'Closed Won'];


Order ord = new Order();
  ord.OpportunityId=opp.id;
  ord.AccountId =opp.AccountId;
  ord.EffectiveDate = opp.CloseDate;
  ord.Status= 'Draft'; 
  insert ord;
for(OpportunityLineItem opl : opp.OpportunityLineItems){
   orl.Order= ord; 
  orl.Quantity=opl.Quantity;

  
  }
  
  insert orl;
  
                                              
}