You need to sign in to do that
Don't have an account?
lookup項目へのID値のset方法?
いかは、画面で入力されたデータを新規に
CustomObject1__c とCustomObject3__c
登録するプロセスですが
CustomObject1__c を登録したのち
CustomObject3__c のlink__cはCustomObject1__cへのlookup項目ですので
List<CustomObjec・・・
IDを取得後
CustomObject3__c のlink__cへ代入すると
f_new.link__c = idname;
Illegal assignment from LIST<oac__CustomObject1__c> to Id
というエラーが出ます
解決方法がわかりません
教えてください
public class new_kain {
CustomObject1__c k_new;
CustomObject3__c f_new;
public PageReference save() {
// Add the account to the database.
insert k_new;
List<CustomObject1__c>idname= [select id from CustomObject1__c where Name =: k_new.name LIMIT 1 ];
id.f_new.link__c = idname;
You could get the id from k_new -- it is automatically updated after the insert is executed:
id.f_new.link__c = k_new.id
Or, if you need to retain the SOQL query, you would have to reference the element in the list returned by the query:
id.f_new.link__c = idname[0]
For good coding style, you would want to handle the possibility that the result set is empty. In this case, since you ran the query right after the insert, it should be safe.
g.engelさん ありがとう
id.f_new.link__c = k_new.id
id.f_new.link__c = idname[0]
どちらに、しても
Variable does not exist: id.f_new.link__c
と
エラーが表示されます
id.f_new.link__c
は
修飾子が
idとf_newとなるからだと思います
でも解決法がわかりません
f_new.link__c = idname[0].id;
でOK!!
ありがとうございました