Imports Related to Parent Objects - I am testing a page which creates child records and parent records in one Skuid page. It would be cool if I could import child records in this process. Either that, or suggesting to avoid it in this scenario. Basically, the “Create Child Objects and Parent Objects” tutorial + “Use Import Wizard from Global Action Button” are not currently compatible. I conclude my effort to put square pegs into round holes.
This is not doable in “one step”, but it is possible to import child records related to a parent using the Skuid Import Wizard. The basic trick to know is that you can pass in additional URL Parameters to the Skuid Import Wizard that will be used to set values on all records imported via the Wizard, via the syntax: /apex/skuid__Import?obj=OBJECT_NAMEN&FIELD_API_NAME=VALUE] e.g. /apex/skuid__Import?obj=Contact&AccountId=00100000000CBAhAAB /apex/skuid__Import?obj=Case&Status=New&Priority=Low /apex/skuid__Import?obj=My_Object__c&My_Field__c=My+Value&Priority=Low For example, say that your parent object is Account, and your child object is Contact. So say you have a multi-step wizard. In Step 1, you create the parent object (an Account). In Step 2, after you’ve saved the Account, you take the user to a table of related Contacts. You have a Global Action on this Table that allows users to Import Contacts. The problem is that normally, with any Import Wizard, in order to link these new Contacts to a related record (here, to a parent Account, via the “AccountId” field) your users would have to have a column in their CSV file with header “AccountId” that contains the Id of the Account. But this would be really tedious for users — why should they have to copy the Id of the Account out of Salesforce, put it into their CSV, then Import? What would be great is to be able to just have the Id of the Account you are looking at be passed in to the Skuid Import Wizard and applied to all imported Contacts. Good news is, you can do this! All you have to do is adapt the URL for your Global Action to pass in the Id of the Account. How do you get this? Use Skuid Merge syntax to grab the Id of the first Account in your Account Model. So let’s say that your Account Model is called “MainAccount”. Here’s what your URL would be:
/apex/skuid__Import?obj=Contact&AccountId={{$Model.MainAccount.data.0.Id}}
This will make it so that all Contacts imported via the wizard would be associated to this particular Account, by populating the AccountId field with the Id of the first row in your MainAccount model. To make it so that the Import Wizard will prompt you to return back to a particular page, e.g. your Account detail page, all you have to do is pass in a “retURL” parameter that defines the URL the Wizard should return you to, like this:
/apex/skuid__Import?obj=Contact&AccountId={{$Model.MainAccount.data.0.Id}}&retURL=%2F{{$Model.MainAccount.data.0.Id}}
That’s gold, Zach. I can see so many potential uses. For one, we use a custom Batch object to track mass data actions with an audit trail. Using your technique, we can create the batch record under the hood in our wizard and apply its id to each incoming row.
This is good info Zach. It works well when I have one ID from a parent table to include on all imported records for the child table. However, what do I do when I’m importing a unique ID per child record?
If I use the values from the Salesforce ID(“Record ID”) field, I’m able to get the import to work on the child table. However, users won’t know the “Record ID” for Salesforce. Instead, they know a unique ID from an external system which is included as the Name field for the custom object. So how can I use the value of the Name field for the importer?
I’ve read that dataloader can be configured to do the correct look on the designated field. Can we do something like that?
Thanks.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.