I am using 2 models (ModelA, ModelB) referencing the same SF Object. ModelA is used with a field editor to create new records and ModelB is used with a table to show all of the records that were created. The Adopt Rows into Model action is being called from a button.
This works as expected with all of the new records showing up in my table. However when I save ModelB nothing happens.
Do I need to do something to ModelB after I adopt the rows so it will save?
Are you trying to clone the rows? Adopt rows is a weird animal. It doesn’t clone rows. It brings them as is into a different model including the Salesfore ID. So adopting 10 rows into a model then saving the model does nothing because it is just saving the rows exactly as they were when they were adopted into the model. You might want to use a model with the advanced setting of Clone data returned by model query set to “Yes, Always”. Then you set your model conditions to display only the rows you want cloned. Upon query of the clone model, all the rows that are returned in the query will be cloned as new rows. Then you can save the model and you will now have a duplicate set of rows
Hi Raymond,
I don’t believe cloning will work because the records from modelA are never being committed to the DB. I’m using the adopt rows to “copy” the data into modelB so they can all be saved at once. So based on what your saying shouldn’t the copied rows in modelB save?
Something is telling me that adopt rows doesn’t work for unsaved data. I remember looking at adopt rows quite a bit and discussing it in a post on the community. If you search the community for adopt rows, you’ll come across a few posts that may answer your questions.
Ok, I searched a lot before I posted and I didn’t find anything on adopt rows and unsaved data.
I looked at that but didn’t think it was the same issue… I will have to go the “create new row” route for now.
Hey Brian as far as i can see, your only Problem is you do not requery your model B when model A is saved.
Since both models belong to the same SF object, when you save something in Model A, it is also existing for Model B in the Background. But Model B will not listen for changes in the Background on its own. You need to have a Action on your Button (After the Save) which simply requerys your Model B)
Here would be a quick sample i put together. Hope i got the topic right:
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true"> <models> <model id="AccountB" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="Account"> <fields> <field id="Name"/> <field id="Description"/> </fields> <conditions/> <actions/> </model> <model id="AccountA" limit="20" query="false" createrowifnonefound="true" adapter="" type="" sobject="Account" doclone="" unloadwarningifunsavedchanges="false"> <fields> <field id="Name"/> <field id="Description"/> </fields> <conditions/> <actions/> </model> </models> <components> <grid uniqueid="sk-3BVE1--63"> <divisions> <division behavior="flex" minwidth="100px" ratio="1" verticalalign="top"> <components> <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" buttonposition="" mode="read" uniqueid="sk-3BVGHA-71" model="AccountB"> <fields> <field id="Name"/> <field id="Description"/> </fields> <rowactions> <action type="edit"/> <action type="delete"/> </rowactions> <massactions usefirstitemasdefault="true"> <action type="massupdate"/> <action type="massdelete"/> </massactions> <views> <view type="standard"/> </views> </skootable> </components> </division> <division behavior="flex" verticalalign="top" minwidth="100px" ratio="1"> <components> <pagetitle model="AccountA" uniqueid="sk-3BYB17-200"> <actions> <action type="multi" label="Save"> <actions> <action type="blockUI" message="Saving.."/> <action type="save"> <models> <model>AccountA</model> </models> <onerroractions> <action type="blockUI" message="There was an error" timeout="3000"/> </onerroractions> </action> <action type="emptyModelData"> <models> <model>AccountA</model> </models> </action> <action type="createRow" model="AccountA" appendorprepend="prepend" defaultmodefornewitems="edit"/> <action type="requeryModel" model="AccountB" behavior="loadmore"/> <action type="unblockUI"/> </actions> </action> <action type="multi" label="Cancel" window="self"> <actions> <action type="cancel"> <models> <model>AccountA</model> </models> </action> <action type="createRow" model="AccountA" appendorprepend="prepend" defaultmodefornewitems="edit"/> </actions> </action> </actions> </pagetitle> <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" buttonposition="" uniqueid="sk-3BVHfX-83" mode="edit" model="AccountA"> <columns> <column width="100%"> <sections> <section title="Section A" collapsible="no"> <fields> <field id="Name"/> <field id="Description" valuehalign="" type=""/> </fields> </section> </sections> </column> </columns> </basicfieldeditor> </components> </division> </divisions> <styles> <styleitem type="background" bgtype="none"/> </styles> </grid> </components> <resources> <labels/> <javascript/> <css/> </resources> <styles> <styleitem type="background" bgtype="none"/> </styles> </skuidpage>
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.