Fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 10:14 PM
HI
I need to write a fix script to fix the backdated data for 18 months.
So the managers on the form are not in sync with the team members related list.
They dont match.
So I need to update the managers on the team members related list with the managers on the account table.
Can you please help me with the script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 11:55 PM
Can you share how your data is in the system? OOB there is no 'manager' on account level. And the 'team members' related list only allows for adding a user and the responsibility (OOB). It would help in knowing exactly what you are trying to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 12:10 AM
It is OOB customer_account table. The account managers on the table should match the user and responsibility on the team members related lists.
at the moment, they are not in synch. I need a script to fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 03:43 AM
Hi @Kanika4 You mean you want to sync Team Members Related List with Vendor Manager on a Account "customer_account" Table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 07:52 AM - edited 09-01-2024 07:54 AM
Please try below code as per your requirement
var MonthsAgo = new GlideDateTime();
MonthsAgo.addMonths(-18);
// Create a GlideRecord object for the required table
var MemberGR = new GlideRecord('team_member'); // Replace table name
MemberGR.addQuery('sys_created_on', '>=', eighteenMonthsAgo); // filter by creation date
MemberGR.query();
while (MemberGR.next()) {
// Create a GlideRecord object for the account table
var accountGR = new GlideRecord('account'); // your table name
if (accountGR.get(MemberGR.account)) {
// Check if the manager needs to be updated
if (MemberGR.manager != accountGR.manager) {
gs.info('Updating team member ' + MemberGR.sys_id + ' manager from ' + MemberGR.manager + ' to ' + accountGR.manager);
MemberGR.manager = accountGR.manager;
MemberGR.update(); // Update the record
}
}
}
Please mark helpful & correct answer its worthy for you.