What Are saveRefs and resolveRefs?

I’m trying to find the definition for saveRef and resolveRef. I’m seeing these attributes in my Json plan files. What do they mean?

Answer

The goal of the data commands are to import and export data. The problem with importing new records is that you don’t know what the ID values are beforehand. So, if you’re importing Accounts and Contacts, you need a way to associate the Contact to each Account, without an ID. You need a Plan. A Plan is a metadata file that explains how each JSON file is related to each other, and the order in which files should be imported. Each record in a JSON file needs to have a “referenceId”, a unique identifier within the entire Plan so you can reference the appropriate parent records later.

So, for each parent record, you need to save a reference to the record; after inserting, there will be a result object that says something like “accountRef123” equals “0015000000abcde”. Normally, these results are discarded (saveRefs: false), but if you need those ID values later, you’ll want to save them (saveRefs: true). Then, in the subsequent files, whenever a lookup field uses a value starting with an @ (e.g. “@accountRef123”), it can resolve the reference you previously saved (resolveRefs: true). Obviously, both saving and resolving references involve extra disk space and CPU time, so if you don’t need them, you don’t need to save/resolve them.

If you use force:data:tree:export with the -p option, a Plan is created for you, and these flags will be set for you automatically. If you’re constructing your data by hand, simply remember that if you need a referenceId to be used in a later JSON file, saveRefs must be true, and if you need to use @ references, then resolveRefs must be true.

Attribution
Source : Link , Question Author : Bethany , Answer Author : sfdcfox

Leave a Comment