How to create a record and multiple related records at once
I would like to know how to create a record and multiple related records at once.
Our model is as follows:
A record of an application (called 'Project') cross-refers multiple records of another application (called 'Assessment'). An 'Assessment' record refers to one record of another application ('Procedure').
'Projects' and 'Assessments' are considered to be transaction data, while 'Procedures' are master data.
What I would like to do is:
Since both 'Projects' and 'Assessments' are transaction data, when a new 'Project' is created, related 'Assessment' records (that refer to appropriate 'Procedure') should be created.
Ideally this would be done under the hood when a project is created, but something like 'Populate Assessments' button would be OK.
My guess was that the custom object may be able to do something like this, since 'Compliance Project' and 'Cardholder Data Environment' applications of 'PCI Management' solution have 'Generate Control Set' and 'Populate Scope Automatically?' buttons respectively, but I cannot find how to use (code) custom objects.
Can anyone give me a clue?
Tomoyasu the buttons in the PCI application just really automate clicking the Apply button. The data feeds do the heavy lifting in regards to creating records.
So there's two approaches to do what you're looking for
First approach and possibly the simplistic is to create data feeds to create the records you need. Granted it would require knowledge on how to create the XSLT to create and populate the necessary records you need. Plus the data feeds would be on schedule or you can look to using a custom object to kick off the feed. The only side effect is that if the user is still in the record at the time the data feed runs the user will receive a record conflict warning when saving the record.
Second approach and much more complex is to create a custom object using the REST APIs () to create the necessary records and update the parent record with the linkages. The reason this approach is much more complex endeavor than using data feeds is that you need to perform multiple REST API calls to create and update the necessary records along with developing error handling if issues arise.
Thank you for the advice.
Regarding the first approach which creates a custom object to kick off the feed, is there some kind of sample code for the custom object which I can use as a reference?
Tomoyasu you can use this one, https://community.rsa.com/message/896219#comment-896303
In the custom object you'll need to update the datafeedGUID variable with the data feed GUID; which you can find on the right hand side when first viewing a data feed configuration.
Also you will need to grant read access via a role to the data feeds.