You need to sign in to do that
Don't have an account?
mgonzalezbic
Adding Account ID to Wrapper of another Custom Object after account created
Hi all,
I am creating a VF wizard which will take information from a VFP and dump it into three objects ( Account, Application__c, and Management_Structure__c).
I have a wrapper for the Management_Structure__c that allows me to create a pageblock table with dynamic row adding/deleting. The fields for Account and App objects are pretty standard.
In my save I have it create the Account, then the application linking to the accountID. Once that is done, I then go to create the Management Structure records, which works properly, but I cannot add the created accountID into the wrapper before save. Accountids does show a ID in the debug log however, I just need to send it into the wrapper here's what the debug log shows:
Here is my save code:
my wrapper:
I am creating a VF wizard which will take information from a VFP and dump it into three objects ( Account, Application__c, and Management_Structure__c).
I have a wrapper for the Management_Structure__c that allows me to create a pageblock table with dynamic row adding/deleting. The fields for Account and App objects are pretty standard.
In my save I have it create the Account, then the application linking to the accountID. Once that is done, I then go to create the Management Structure records, which works properly, but I cannot add the created accountID into the wrapper before save. Accountids does show a ID in the debug log however, I just need to send it into the wrapper here's what the debug log shows:
21:04:40.321 (321447984)|USER_DEBUG|[169]|DEBUG| Accountwrapper:[account=Management_Structure__c:{Account__c=null, Position_Title__c=President, Compensation__c=20000.00, Board_of_Director_Member__c=false}, accountids=001J000001jJpQYIA0, counterWrap=1]
Here is my save code:
//Create Management records list<Management_Structure__c> updateAccountList; updateAccountList = new list<Management_Structure__c>(); if(!accountwrapperList.isEmpty()){ for(Accountwrapper accountWrapper:accountwrapperList){ accountid = acct.id; accountwrapper.accountids = accountid ; system.debug(accountWrapper); updateAccountList.add(accountWrapper.account); } } if(!updateAccountList.isEmpty()){ upsert updateAccountList; }
my wrapper:
public class Accountwrapper{ public Management_Structure__c account{get;set;} public Integer counterWrap{get;set;} public id accountids {get;set;} public Accountwrapper(Management_Structure__c act){ this.account = act; act.Account__c = accountids; } }
All Answers
Yeah I kept seeing it null in my debug and I was like :sadface:. I'm still wrapping my head (no pun intended) around wrappers.... but I appreciate the help!