- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 03:17 PM
I've created a new text field on my Account table called 'Account Friendly Name'. The default for this new field on all new Accounts created moving forward will be the actual value of the 'Account Name'. For all current Accounts, I need to update the Account Friendly Name with the current Account name. I'm assuming I would need to run a script of some sort, but don't have the ability to do that. Anyone provide sample code to use to update all current Accounts?
Account Friendly Name = u_account_friendly_name
Table / Account [customer_account]
Account Name = name
Table / Company [core_company]
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 04:14 PM
You need to run a fix script or background script to update the existing accounts.
var ca = new GlideRecord('customer_account');
ca.setLimit(2);
ca.query();
while (ca.next())
{
ca.u_account_friendly_name = ca.<account name field>;
ca.update();
}
Above is an example script. I have limit it to two, so that you test if works
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 04:14 PM
You need to run a fix script or background script to update the existing accounts.
var ca = new GlideRecord('customer_account');
ca.setLimit(2);
ca.query();
while (ca.next())
{
ca.u_account_friendly_name = ca.<account name field>;
ca.update();
}
Above is an example script. I have limit it to two, so that you test if works
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 05:43 PM
I'm getting the following:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 06:17 PM
OK. I got it to work. I changed line 7 to show:
ca.u_account_friendly_name = ca.name;
So, I would just remove line 2 from the code, and just run that to update all Accounts I would assume?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 08:28 AM
Right. Try it on a Dev Instance just to make sure it is working as expected.
Please mark this response as correct or helpful if it assisted you with your question.