Ran into the issue where I have clientName in the package which gets merged into the content. Later programName gets added to the package which happens to have the same value as clientName. There is a C# frag which removes registered trademark from the clientName. It is removing the programName because it finds that value first and adds a duplicate clientName. Is there any way to remove item by name?
<%@Import Namespace="Tridion.ContentManager.ContentManagement.Fields"%>
Item outputItem = package.GetByName("client.name");
if(outputItem != null){
string outputString = outputItem.GetAsString();
outputString = outputString.Replace("\u00AE", "");
outputString = outputString.Replace("\u24C7", "");
outputString = outputString.Replace("®", "");
package.Remove(outputItem);
outputItem.SetAsString(outputString);
package.PushItem("client.name", outputItem);
}
Item newOutputItem = package.CreateStringItem(ContentType.Text, outputString );
and thenpackage.PushItem("client.name", newOutputItem );
. I was checking some of our TBBs and this seems to be working. Couldn't recollect why we have it this way, but may be we hit the same issue and worked around this way...SetAsString
. This will in fact overwrite the old value. Additionally it might be worth checking if the dot (.) in the item name (client.name) is not causing this effect... Remember, dot is special in DWT syntax :)