• satish pal
  • NEWBIE
  • 10 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 7
    Replies
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
Hey guys,

I have object A.

I have let's say a PDF or a Word file I want to attach automatically. to each record of object A upon creation.

I don't see how process builder could do this, so is there a way to do this? Maybe in apex? Thanks
Here goes my Lightning component - 

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
    <aura:attribute name="accId" type="String" />
    <aura:attribute name="Con" type="Contact" 
                    default="{sObjectname: 'Contact',
                    FirstName:'Roza',
                    LastName:'Stalin',
                    Phone:'8981103780',
                    Email:'rozaStalin@cboard.com'}"/>
    <div class="slds-p-around_medium">
        <lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
        <lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
        <lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
        <lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
        <lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
    </div>
</aura:component>

Controller - 

public class cboard_seeContacts {
    
    @AuraEnabled
    public static List<Contact> ContactList(string accId){
        return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
    }
    
    @AuraEnabled
    public static Contact createContact(Contact c, Id AccountId){
        c.AccountId=AccountId;
        insert c;
        return c;
    }
}

JS-  
({
    doSave : function(component, event, helper) {
        var action = component.get('c.createContact');
        action.setParam({
            c : component.get('v.Con'),
            AccountId : component.get('v.accId')
        });
        action.setCallBack(this, function(response){
            var state= response.getState();
            if(state === 'SUCCESS' || state ==='DRAFT'){
                var reposneValue = response.getReturnvalue();
            }
        },'ALL');
        $A.enqueueAction(action);
    }
})


I am unable to figure out why the inputs and button is not working. Any help will be appreciated. 
 
<apex:page standardcontroller="Entity__c" extensions="wrapperclassTwo">
  <apex:form >
  <apex:pageBlock >
      <apex:outputText>  
      Trust Name
      </apex:outputText>
      <apex:inputfield label="name of trust" value="{!Entity__c.name}"/>
      <apex:inputfield label="name of trust" value="{!lnput}"/>
  <apex:pageBlockSection columns="1" title="Transactions1">


i want to use either {!Entity__c.name} or the {!lnput}
in the controller class.


controller
public with sharing class wrapperclassTwo {
    public wrapperclassTwo(apexpages.StandardController controller){}
 ///  public string input = entity__c.name;
    Public string input{get;set;}
    Public string lnput{get;set;}
    list<Tnetoutputtransaction__c> obl1= new list<Tnetoutputtransaction__c>();
    List<Account_Holdings_Tax_Lots__c> obl2 = new list<Account_Holdings_Tax_Lots__c>();

    public list<wrapperClass> wrapperClassList = new list<wrapperclass>();
    public list<wrapperClass>getListWrapperObjectMethod(){
        
        obl1 =[select name,id From Tnetoutputtransaction__c limit 15 where name={!input];/or {!Entity__c.name}
         obl2 =[select name,id From Account_Holdings_Tax_Lots__c limit 15];
      
i want to use the that to 
 
Hello,
I am new to salesforce and I would like to know how to create custom button to update record's field value on click.
Should I use lightning component + apex code or is it possible achieve it without code?
Example - what I am trying to achieve:
FieldName:  Times clicked
FieldValue = 0 + 1 time clicked // sObject_c.TimesClicked++
Hi folks,
    Can anyone tell me how to redirect one visualforce page to another visualforce page automatically ?
below is my visualforce page :
<apex:page standardController="Account" extensions="AccountDownload" 
contentType="application/msWord/#Test-{!NOW()}.doc"
   recordSetVar="accounts" sidebar="false"  cache="true"> 
    
    <html xmlns:w="urn:schemas-microsoft-com:office:word">
        <head>
            
        
        </head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
         
        <body>                       
            <apex:form >
                <apex:pageBlock title="Archiver For Account">
                     <div style="text-align:left" >          
                         <apex:pageBlockTable value="{!accounts}" var="ac" >
                             <apex:column headerValue="AccountName">
                                 <apex:outputText >{!ac.Name}</apex:outputText>
                             </apex:column>
                             <apex:column headerValue="Account Number">
                                 <apex:outputText >{!ac.AccountNumber}</apex:outputText>
                             </apex:column>
                             <apex:column headerValue="AccountType">
                                 <apex:outputText >{!ac.Type}</apex:outputText>
                             </apex:column>
                             <apex:column headerValue="Phone Number">
                                 <apex:outputText >{!ac.Phone}</apex:outputText>
                             </apex:column>                                       
                         </apex:pageBlockTable>  
                      </div>           
                    </apex:pageBlock>
    
               <apex:outputText value="hi dude,"/>
           </apex:form>
           
        </body>
        <script>
 
            function redirect(){
                window.location.href='https://c.ap1.visual.force.com/apex/AccountasTextfile'; 
            }
 
            window.onload = window.setTimeout(redirect(),5000);
 
        </script>
    </html>
</apex:page>

My question is once the document is downloaded then it will automatically redirect to another page as mentioned above.
I have tried using action attribute,calling redirect method from constructor. but nothing happen.
Finally I got the idea is using javascript we can redirect automatically.
but it dosent work for me.

Someone please tell me what I have to modify.



Thanks in advance
Karthick
Hello Everyone,

I got a email- You have one or more certificates in your Salesforce org that will expire soon. Review the list below and visit Certificate and Key Management from Setup to make an update.

I have resolve it using the steps:
There are few places where a sefl-signed certificate could be used, I identified those

1. Identify Provider - If you are using SFDC as IDP for Single Sign On. 
2. Single Sign-On Settings - If you are using SFDC as Consumer for Single Sign On.

Certificate is used in above 2 places, i edit this screen and replace the old certificate, with my newly created Certificate.

When i am doing this changes i have seen the warning msg  "If you change this certificate, users can't connect to service providers until you reconfigure each service provider to work with the new certificate", ANY OTHER PLACES WHERE I HAVE TO UPDATE MY THIS NEW CERTIFICATE?

ANY SUGGESTION HOW TO SOLVE THIS?

Thanks in advance.
Arpit Bajpai