Javascript Snippet to Create a Pair of Related Records and Add One to a Table

I am trying to extend the (wonderful) solution found here: https://community.skuid.com/t/setting-default-values-for-quick-data-entry

I want to use a handy little button to give my users a faster way to create an Assignment record from a Project detail page. Projects are the Parent to child Assignments. 

It would be so easy (using the tutorial above) if I just needed to create the Assignment. Unfortunately, Assignments need to be connected via lookup to a Schedule record. All Assignments have a related Schedule record, and in normal Salesforce/FFPSA life, these two records are created at the same time (or almost nearly at the same time) on a clunky, ugly Visualforce page. 

What I would like to do is create a Global Action on an Assignment Table that will create both a new Schedule record and a new Assignment record, and then pass the newly created Schedule Name/ID (whatever) into the newly created Assignment’s “Schedule__c” lookup field. And then do some adding of default values and so forth, per the tutorial above. 

I just don’t know how to create two new rows (on separate objects) and then pass values from one to the other using Javascript.

Even though I asked nicely for zero arguments, (included var self = arguments[0];) the code is still arguing with me. 





Kaede. 

While the Javscript may be nice for adding default values. In this case you might want to have a global action connected to a “new Record” page.  This would trigger new record creation actions on two models - New Schedule and New Assignment.  These would need to be connected  via “field from another model” condition.   It might be another hop for your users,  but it will significantly simplify your development.