Saturday 4 June 2011

Moving an existing field with data to another object (Salesforce Data Loader)

OK, so you have to move an existing field on one of your objects to another object, but the existing field values are sensitive data that cannot be lost.

Well, so far, saleforce has not come up with a feature to "move" the field with it's values... But these are the nessicary steps to preform the action, so I'm going to show you how it's done.


NOTE The original objects Records must be related to the other objects Records with a custom relationship field (EX: Accounts with Contacts) in order for this to work. Unless, you want the values from the field to be enterd as record names for an object, otherwise there is no way for salesforce to recocnize/map out where to put your data.

Overall Explanation: (Step 1) First we are going to create a new field on the object we want to "move" this field over to, and typically name it the same as the existing field were moving (to keep it simple), but you can rename it.

(Step 2) Then we are going to run a report of all existing field values for that field and the related objects ID (The object that you wish to move the field to). Export the report to Microsoft Excel, and put it in the correct format.

(Step 3) Then use the salesforce "Data Loader" to import(update) the data on the new field you created, mapping it by the desired objects ID. Once we have done this we will have accomplished our goal of moving the field.

(Step 4) is deleting the old field.

SO! here we go... Just as an example this time we are going to be moving a field from a custom object, which records are related to the records of the opportunities, to the opportunity page.

[Step 1]

Create the new field on the desired object you wish to move this field to, typicly to keep it simple you could name it the same as the existing field on the object were moving it from. In my case, the field on my custom object called "PV to client" which is a Picklist (drop-down), will be moved to the opportunity page, so im going to create a new Picklist field on my opportunity page called "PV to Client", same field type.
[Step 2]

Now we need to run a report, to gather all of the Data needed for this transfer. Reffering back to my example, Each opportunity in my system is related to one of my custom objects Records, the object i wish to transfer this feild from, which is named Successor borrower(s). You need to select the report type that includes the two related objects. This shouldn't be a problem if the objects records are related with a custom relationship field, and should also show up as a Report type, maybe in "Other" reports.

Now all i need to pull into my report are two fields...


Field #1 being: Opportunity Object: "Opportunity ID"



Field#2 being: Successor Borrower Object: "PV To Client"



NOTE On step #5 of making the report I selected the (Successor Borrower Object) field: PV to Client = Not equal to Null (blank). This insures that we will only pull in "PV to CLient" fields that are NOT blank. It's Cleaner...





Once you have run your report, this is what it should look like. Now i cut it short, but this report actually had 487 values in "PV to Client" that I need to transfer. If you notice, my field "PV to Client" is a picklist Field type, but note this process works for all data types weather it be dates, currencies, percentages, ect...





(SAVE THE REPORT)

Ok, so just one more step on step #2, exporting this report to Excel, which is very simple. Simply click "Export Details on the top of your report page.

Salesforce Will then prompt you to select the file format, you can either choose: "Comma Delimited.csv" -or- "Excel Format.xls".

If you have some manual editing you would like to preform before the import on the field values I would suggest choosing the "Excel Format.xls". After you have made any modifications to the values, save the Excel file as a "Comma Delimited.csv". I suggest renaming it upon saving as a csv, for example "temp_import1", this way if you made a mistake you can always go back to the original XLS file and make your changes, instead of overwriting the file. In our next step of importing these values back into salesforce were going to use a program made by salesforce called the "data Loader", which only accepts CSV files.


If the report and values look fine, just how you would like to move them, I suggest choosing "Comma Delimited", because in our next step as i mentioned above, in using the data loader, it requires the File to be a CSV, so it makes things a tad bit easier.


NOTE Reference the picture above of the Salesforce report, remove the old object name from the field name on the report, but only once it is in excel, so in my case it would only read the field name "PV To Client", not "Successor Borrower: PV To Client"


[Step 3]

Using the Salesforce Data Loader to import the field values into our newly created field

note The Salesforce "Data Loader" is FREE. To get it, log into Salesforce.com and go to Setup. There, go to Data Management->AppExchange Data Loader and click the Download link.

Click HERE for the "Data Loader User Guide", the best page reference for what were doing now would be page #7.

OK, now that you have the Data Loader we can begin with the importing process, step 3. when you open data loader you will be prompted with these options... [View 1]

If you have already seen this view upon downloading the application and exploring it you might see another view, that would look like this: [View2]


Either way, we are going to "update" the records on the object, since the new field we created already exists. I wont get to much into using the Data loader on this tutorial, just what we need it for right now.

NOTE This is a salesforce Application, built by Salesforce, it is safe, but be aware that any changes made by the data loader cannot be reversed, they are permenant.

If you are prompted with the first screen view, select update and provide it with your login information.

If you are prompted with the second view, go to [file->Update->Provide Login Info->Next

Ok, So now we are all on the same view, [view 2]

From there go to: File->Update-> (Select the object which you created the new field in.)

Then Browse for the CSV format file you have prepared->Click next. The Data Loader will then make you aware the exact amount of records you will be effecting. ->click "OK"

Now for the mapping, this part tells Salesforce where to put these field values, that's why our report contained the new object records Id's, and the value of the field we wish to "transfer" over. If you have followed my instructions and read everything in this tutorial so far, this process will be very easy otherwise errors may occur.

From this screen click "create or Edit a Map"




Once you have done that it will take you to the "mapping Dialog" screen with will allow you to map out the fields so salesforce Data Loader Knows what to do with your data. You can either click and drag the correct salesforce fields down to match your spreadsheet values, or click "Auto-Match Fields to Columns", and again, if you have followed the tutorial clicking auto match will automatically match the fields you intended on matching, for you.



If your with me at this point, great, we're almost finished.
Click "OK" once you approve of the fields that are shown to be mapped.
Click Next if everything looks OK
Click Finish if everything looks OK

Now the update is in progress, depending on the amount of records this can take anywhwere from 5 seconds to 10 minutes.

Go to the new field you wished to populate with those existing values from the related object to see if everything looks good, which I'm sure it does. This is to ensure the update went smoothly, the data has been properly "moved".

That's it, congratulations, there is also so much more you can do with the Salesforce Data Loader, play around with it a little bit, but remember, nothing is reversable.

I hope this tutorial was helpful to you, and I look forward to making more tutorials for common sales force administrator requests and issues. After all, there is always something new to learn bout Salesforce, on all levels.

Any questions or comments are greatly appreciated!

No comments:

Post a Comment