Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
To work with multiple records, loop through all records with a particular tag, collect their ItemIds, and edit them on an individual basis.
Suppose that all Northwest and Southwest tags need to be consolidated to a single West Coast tag. To remove the tags and replace them:
1. | Store the accounts that contain the tags you want to delete. You can execute the following in the AJAX Toolkit or your own client application: var westCoastAccounts = sforce.connection.query("SELECT ItemId,
Id
FROM AccountTag WHERE Name = 'Northwest' OR Name =
'Southwest'"); |
2. | Create the new West Coast tag. Add the ItemIds by looping through the records: var WestCoastTagArray = new Array();
for (var i = 0; i < westCoastAccounts.size; i++)
{
WestCoastTagArray[i] = new sforce.SObject('AccountTag');
WestCoastTagArray[i].Name = "West Coast";
WestCoastTagArray[i].Type = "Public";
WestCoastTagArray[i].ItemId =
westCoastAccounts.records[i].ItemId;
}
sforce.connection.create(WestCoastTagArray); |
3. |