お気に入りNejib Essouri (Tunisia International Technology) が「#Visualforce」で質問2015年4月16日 10:57Insert a row in a custom objectMy page bloc section :<apex:pageblockSection title="Organisme audité"> <apex:pageblockSection > <apex:pageblockSection > <apex:inputField value="{!customObj1.Name}"/> </apex:pageblockSection> <apex:pageblockSection > <apex:inputField value="{!customObj1.Date_debut__c}"/> </apex:pageblockSection> <apex:pageblockSection > <apex:inputField value="{!customObj1.Date_fin__c}"/> </apex:pageblockSection> <apex:pageblockSection > <apex:commandButton value="save" action="{!save}"/> </apex:pageblockSection> my controller :public with sharing class controller_audit { public Mission__c customObj1 {get;set;}public controller_audit(){ customObj1= [select Name, Date_debut__c, Date_fin__c from Mission__c LIMIT 1];}public void save(){ insert customObj1; }}Error: System.DmlException: Insert failed. First exception on row 0 with id a0P24000000GPkhEAG; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]help ?表示件数を増やす8 件の回答並び替え日付で並び替え役に立った順で並び替え日付で並び替えコメントをさらに読み込む...承認された回答sandeep sankhla (GE Healthcare)2015年4月16日 11:51Hi,As an best practise we should always initalize all the variables before using..so in your case please initalize it in constructor..customObj1 = new Mission__c();ThanksSandeep 表示件数を増やすコメントを追加回答を記入...太字斜体下線取り消し線箇条書き番号付きリストリンクを追加コードブロック画像を挿入ファイルを添付リンク URLキャンセル保存0/9000返信
承認された回答sandeep sankhla (GE Healthcare)2015年4月16日 11:51Hi,As an best practise we should always initalize all the variables before using..so in your case please initalize it in constructor..customObj1 = new Mission__c();ThanksSandeep 表示件数を増やす