How to Overwrite existing Taxonomy term and nested terms programmatically

Hi,
I have created Taxonomy term (Term A) and nested terms(Subterm1, Subterm2, SubTerm3, etc) programmatically.
Now I want to update sub terms(SubTerm1, SubTerm3, SubTerm4, SubTerm5, etc) programmatically.There are more than 100 sub terms, so I want to update sub terms programmatically.
Here is my code:
var site = properties.Feature.Parent as SPSite;
var taxonomySession = new TaxonomySession(site);
if (taxonomySession.TermStores.Count != 0)
var termStore = taxonomySession.TermStores["Managed Metadata Service"];
var group = termStore.Groups["Group A"];
var termSet = group.TermSets["TermSet A"];
var TermA = termSet.CreateTerm("Term A", CultureInfo.CurrentCulture.LCID);
TermA .CreateTerm("SubTerm1",CultureInfo.CurrentCulture.LCID);TermA.CreateTerm("SubTerm2", CultureInfo.CurrentCulture.LCID);
TermA.CreateTerm("SubTerm3", CultureInfo.CurrentCulture.LCID);
Can anybody let me know how to update the nested terms?
Any help would be appreciated.
Thank you,
AA.

Hi,
The following code for your reference:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace ConsoleApplication
class Program
static void Main(string[] args)
using (SPSite site = new SPSite("http://sp:5000/"))
TaxonomySession taxonomySession = new TaxonomySession(site);
TermStore termStore=taxonomySession.TermStores["Managed Metadata Service"];
var group=termStore.Groups["Group A"];
var termSet=group.TermSets["TermSet A"];
var topTerm = termSet.Terms["Term A"];
var subTerms = topTerm.Terms;
foreach (Term term in subTerms)
if (term.Name.Equals("SubTerm1"))
term.Name = "SubTerm-1";
if (term.Name.Equals("SubTerm2"))
term.Name = "SubTerm-2";
if (term.Name.Equals("SubTerm3"))
term.Name = "SubTerm-3";
termStore.CommitAll();
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support

Similar Messages

  • How to overwrite existing DB's in SQL 2008?

    I use Maintenance Plan of SQL 2008 Server for Backup some DB's. As a result i need to keep, only one set of Backup Up's and not more. So actually i can use Maintenance Plan Clean Up wizard, but i need something like Overwrite. That mean
    i don't want do delete DB's after i finish Backup UP, but i want to overwrite existing backups?
    Thanks.

    Maintenance Plans are great as a base starting point for, "maintenance".  They provide quick, easy setup and just get something in when in some cases, a fulltime DBA is not around.
    Uri's recommendation on avoiding Maintenance Plans probably should have come with an explanation with such a strong statement.  I'm guessing with the following, there will be an agreement...
    Maintenance Plans, like I said, offer quick development of maintenance tasks.  However, you can find yourself being restricted if you only use them for all of your maintenance tasks.  This proves to make it difficult when you start getting further
    into truly managing your database servers as they grow.  Now, WITH INIT is an option form memory in the BACKUP Task but given the task, the conversion to calling the BACKUP DATABASE [db] TO DISK=N'filepath' WITH INT is a pretty quick change (at this point). 
    It will allow you to better understand the tasks you are refining as well.  But, you do have the ability to leave it there.
    I'm also not fully agreeing that WITH INIT is your best option if you want to retain backup history.  If you do not, then by all means, INIT it all day.  You may want to consider bringing this into SSIS or even a more structure TSQL statement to
    dynamically create backup files by timestamps so you can at least retain some historic recovery abilities.  Possible this is something of a secondary backup so that is based on my assumptions
    Ted Krueger
    Blog on lessthandot.com @onpnt on twitter

  • How to overwrite existing report using RE SDK?

    Hi,
    I want to overwrite the report while saving it in  the folder and personal category.
    How can i do that?
    Please help me?
    Thanks in Advance
    Amol Mali

    Hi Amol,
    Did you want to "download" a WebI document in a specific format using the Report Engine SDK?
    Basically, you can view the WebI document in a specific format.
    Please refer to the following samples on the SDN ([https://www.sdn.sap.com/irj/boc/businessobjects-samples]):
    NET-CS2005_RENet_BE115_View_Webi-Excel: [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b08ed111-dd66-2b10-c4b7-9e79a464c93b]
    NET-CS2005_RENet_BE115_View_Webi-Pdf: [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30775fd4-dd66-2b10-2dbc-98ac87baa3ad]
    These were created using XI R2 but should also work for XI 3.1.
    Also, the samples will display the document (Excel or PDF) on the browser.
    You can just modify this to save as instead.
    Hope this helps.
    Regards,
    Dan

  • How do I open a vi and run it programmatically from vb6

    The following code opens the dialog box but not the vi and I also need to run the vi from this app.
    Dim LV As LabVIEW.Application
    Private Sub Form_Load()
    Set LV = New LabVIEW.Application
    Debug.Print LV.ApplicationDirectory = "C:\LabViewProgs"
    Debug.Print LV.AppName = "BeadSorting.vi"
    End Sub

    Hello,
    Check out the attached Excel file, which contains a "LoadData" macro that passes parameters to a LabVIEW VI and runs it. (This excel file is probably also in your ...National Instruments\LabVIEW\examples\comm directory).
    Once you open the freqresp.xls file, select Enable Macros when prompted, then select Tools >>Macro>>Macros, select the LoadData macro, then click the Edit button. (or just open the VB editor from the Tools>>Macro menu, depending on your version of Excel). You can then see the code. If you double-click LoadData, the VI will open and run (if you have LabVIEW 7.1).
    This code is a great example of calling and running a LabVIEW VI from Visual Basic.
    Hope this helps!
    Liz F
    National Instruments
    Attachments:
    freqresp.xls ‏49 KB

  • How does one overwrite existing text?

    One can do plenty of clever formatting in drafting Thunderbird correspondence. But I am unable to find how one overwrites existing text. Can someone help, please?

    please I am having trouble understanding. But here goes what I think your asking.
    When you reply in an interleaved fashion as you did with my email, you need to break the previous message by pressing enter to get your own text area to type in. I saw a discussion on one of the develop0er list the other day where they were suggesting that some of the font information is bleeding back and forth in these situation and brainstorming what to actually do about it. That is just a discussion as yet. See https://groups.google.com/forum/#!topic/tb-planning/ZYusepcRj-k
    One of the best option in my opinion is to use the quote and compose managerhttps://freeshell.de/~kaosmos/quoteandcomposemanager-en.html as it preserves the vertical lines Thunderbird shows while editing in the outgoing message to make it clear where the interleaved information is located. It also has a stabilize font option that has helped many. (The author is Italian, so Italian locales of his add-ons are always available)
    Instruction on installing add-ons here http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html

  • How to create a service order and check the internal order in R/3

    Required Solution:
    1. How to copy existing service order and create new one and check the internal order in R/3, whether the certain service order is correctly created in r/3, can you polease explain the steps plz.
    2. If i am creating service order by service template finally the service order is getting created but it is not showing me in the table iaom_crm_aufk, how to check this.
    can any one help me in this issues as soon as possible.

    Hello Zita,
    Try to restart your portal after creating <b>ServiceUser</b> in both UME and KM.
    One more major difference between ServiceUser and normal portal user is that a ServiceUser does not have a UserAccount (IUserAccount)
    Object serviceContext = null;
            try {
                serviceContext = AccessController.doPrivileged(new PrivilegedExceptionAction() {
                    public Object run() throws WcmException {
                        return ResourceFactory.getInstance().getServiceContext(CONTRACT_SERVICE_USER);
            } catch (PrivilegedActionException e) {
                logger.severe(e, "ResourceContext for the technical " + serviceUser +
                     " user could not be retrieved.");
    IResourceContext resCtx = (IResourceContext) serviceContext;
    So I modify all KM resources with this resCtx.
    Hope this helps ...
    Greetings,
    Praveen Gudapati
    p.s. Points are always welcome for helpful answers

  • Existing content area as a portlet programmatically?

    Does anyone know how to expose existing content area as a portlet programmatically?
    I have to write a script that would need to create and "expose" existing content areas as portlets.
    Thanks in advance,
    Alex.

    Did you try refreshing your portlet repository? What release of Portal are you currently using? Which version of the PDK? On which platform?
    Thanks,
    Harry
    testing ignore below!
    http://portalstudio.oracle.com

  • How to copy and overwrite existing folder that is created under KM

    I have about 500 store folders created in KM and under each of those folders I have a subfolder called Reports.  I had created a new Reports folder that I want to copy to all of the 500 store folders but, when I tried doing it I see it creates another copy of the Reports folders and doesn't overwrite the existing one which I really want it to do.   Is there way to overwrite, rather then manuelly going into each 500 folders, removing the existing Reports folder and then copying over the update Reports folder.

    Hi,
    there is no way to overwrite with a "copy". If you need this functionality more often, you could develop your own report.
    The existing "copy" report has no overwrite function.
    Instead of manually deleting the existing folder, you could use the delete report.
    Go to Content Administration > KM Content > Toolbox > Reports > Mass Operations
    Regards,
    Sascha

  • How do you configure AME CS5.5 to overwrite existing output files?

    How do you configure AME CS5.5 to overwrite existing output files?  So far the only options I have found are to increment the output file name or fail.  From the explaination of file increment I would have expected overwrite to be the alternative.  We work daily with the same file(s) on an hourly basis and convert via watch folder to over a dozen file types and network mapped destinations.  Re-using the same file name is critical to the final project (updating website content). Does anyone have any suggestions?

    Has there been any updates on overwriting output files in CS6? This would be extremely helpful.

  • I have bought an used Iphone 5. I dont have the password for the existing login id of the old owner. How do i use the phone and change the log in id?

    I have bought an used Iphone 5. I dont have the password for the existing login id of the old owner. How do i use the phone and change the log in id?

    Unfortunatly the only way that you can get it off is to get the old user to input the password.  You may need to contact that old user and see if he can put the old password in.  hope this helps.

  • 1. I have an iPod which has purchases synced with I tunes with an apple ID. I now have an iPad with a new ID for cloud. I have cloud storage capacity of 5gb which came with the iPad. How can I use one ID and store my existing music in cloud?

    1. I have an iPod which has purchases synced with I tunes with an apple ID. I now have an iPad with a new ID for cloud. I have cloud storage capacity of 5gb which came with the iPad. How can I use one ID and store my existing music in cloud?

    HI Frostyfrog
    CHeck out iTunes Match which has an annual fee of £21 or thereabouts. You can store a maximum of 25,000 songs there and they all become available on your other kit, iPhone, iPad and iPod. I know it works as I have over 23000 songs uploaded of which only a few we're bought through iTunes.
    it works by comparing your music to the whole iTunes music dadata base so you access the same tunes that you could get from iTunes. If you have obscure stuff, it uploads your own music to the cloud as a copy.
    I Find it incredible that on my iPhone with its 16gb memory I can view almost 200 gb of music (ie my 23000 songs) and play any of them. Anything I add to iTunes becomes available via the cloud fairly quickly from a few minutes or a little longer if adding a lot.
    The first time you use it it will take quite a while to match your music if you have a lot, but after that it is all automatic. Read the stuff on the apple site. Your PC needs to be at least running Vista. I recommend it and at less than 50p a week it's good value.
    Good luck

  • I need to know how to edit a drawing - basically remove the arrows and text but at the same time match the background of the existing pic. then re add new text. how do i erase the arrows and text and arrows but match current background of pic. step by ste

    i need to know how to edit a drawing - basically remove the arrows and text but at the same time match the background of the existing pic. then re add new text. how do i erase the arrows and text and arrows but match current background of pic. step by step explanation please beginner

    Please post (a relevant section of) it right on this Forum.

  • How do I check if section and subdivision exist inside object's xml?

    My function is working but not as I expect it to. The problem is that when Section and Subvision are not found in the object aobjXmlGetStatuteRequestNode xml, I get an error NullReference Exception was unhandled by user code. Object reference not set
    to an instance of an object. 
    For that reason, because the two elements are optional, I would like to check if they exist before adding their value into the xml inside the object objXmlRequestMessageDoc.
    The if statement I used in my function did not work. When it found Section element, it did not check for Subdivision. 
    How do I check for both and add them if they exist. If they do not exist, I do not need to do anything and should not throw an error since they are optional.
     Object aobjXmlGetStatuteRequestNode has this xml
    <ns:GetStatutesRequest xmlns:ns="http://www.courts.state.mn.us/StatuteService/1.0">
    <ns:Statute>
    <ns:Chapter>169</ns:Chapter>
    <!--Optional:-->
    <ns:Section>191</ns:Section>
    <!--Optional:-->
    <ns:Subdivision>a</ns:Subdivision>
    </ns:Statute>
    The following output in the objXmlRequestMessageDoc object is correct but this does not work when Section and or Subdivision are not found in the object aobjXmlGetStatuteRequestNode.
    <ns:BasicSearchQueryRequest xmlns:ns="http://crimnet.state.mn.us/mnjustice/statute/service/4.0">
    <ns1:BasicSearchCriteria xmlns:ns1="http://crimnet.state.mn.us/mnjustice/statute/messages/4.0">
    <ns2:Chapter xmlns:ns2="http://crimnet.state.mn.us/mnjustice/statute/4.0"/169</ns2:Chapter>>
    <ns2:Section xmlns:ns2="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>191</ns2:Chapter>
    <ns2:Subdivision xmlns:ns2="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>a</ns2:Chapter>
    </ns1:BasicSearchCriteria>
    </ns:BasicSearchQueryRequest>
    My Function
    Function GetStatutesByChapter(ByVal aobjXmlGetStatuteRequestNode As XmlNode, ByVal aobjXMLNameSpaceManager As XmlNamespaceManager, ByVal aobjBroker As ServiceCatalog.Library.v4.Broker) As XmlDocument
    Dim objXmlRequestMessageDoc As XmlDocument
    Dim objXmlResponseMessageDoc As XmlDocument
    Dim intCount As Integer
    aobjBroker.PostMessageWarehouseInformationalMessage("Chapter found.", 1)
    objXmlResponseMessageDoc = New XmlDocument
    'Add the first element into the document GetStatuteByChapter with its namespace
    objXmlResponseMessageDoc.AppendChild(objXmlResponseMessageDoc.CreateElement("BasicSearchQueryResponse", "http://crimnet.state.mn.us/mnjustice/statute/service/4.0"))
    'Create the BCA request message
    objXmlRequestMessageDoc = New XmlDocument
    objXmlRequestMessageDoc.AppendChild(objXmlRequestMessageDoc.CreateElement("ns:BasicSearchQueryRequest", aobjXMLNameSpaceManager.LookupNamespace("ns")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns1:BasicSearchCriteria", aobjXMLNameSpaceManager.LookupNamespace("ns1")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Chapter", aobjXMLNameSpaceManager.LookupNamespace("st")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Section", aobjXMLNameSpaceManager.LookupNamespace("st")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Subdivision", aobjXMLNameSpaceManager.LookupNamespace("st")))
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Chapter", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Chapter", aobjXMLNameSpaceManager).InnerText
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Subdivision", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager).InnerText
    'check if there is a section and or subdivision if it is there then set the value
    'If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText) Is Nothing Then
    ' objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
    'End If
    'check if there is a section and or subdivision if it is there then set the value
    aobjBroker.PostMessageWarehouseSnapshot(objXmlRequestMessageDoc.OuterXml, "Request Message", 1)
    'Call the BCA service
    intCount = 0
    'Count how many Statute node found
    CType(objXmlResponseMessageDoc.SelectSingleNode("ss:GetStatutesResponse/ss:StatutesXml/ss:Statutes", aobjXMLNameSpaceManager), System.Xml.XmlElement).SetAttribute("totalCount", CStr(intCount))
    Return objXmlResponseMessageDoc
    End Function

    I have resolved this issue by using two if statements as follows
    'check if there is a section and or subdivision if it is there then set the value
    If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager) Is Nothing) Then
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
    End If
    If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager) Is Nothing) Then
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Subdivision", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager).InnerText
    End If

  • How do I get past terms and  conditions on my iphone 4

    How do I get past terms and conditions on my iphone 4?

    Hey melba ann,
    Thanks for the question. I understand you are having issues accepting the Terms & Conditions. If you have not already done so, you may want to restart your iPhone:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    You may also want to make sure cookies are not blocked and private browsing is turned off in Settings > Safari (you can also take this opportunity to Clear Cookies and Data):
    Safari settings - iPhone User Guide
    http://help.apple.com/iphone/7/#/iph3d7aa74dc
    Thanks,
    Matt M.

  • I cannot reactivate my e-reader with my existing Adobe ID and password which are both correct. I alwayss get the message "activation server error, Code: E_AUTH_NOT_READY" What kind of problem is this and what is most important, how can I solve it quickly.

    I cannot reactivate my e-reader with my existing Adobe ID and password which are both correct. I alwayss get the message "activation server error, Code: E_AUTH_NOT_READY" What kind of problem is this and what is most important, how can I solve it quickly. I am on holiday and want to read. Thanks for speedy reply.

    Yes, actually I talk about Digital editions. Do you know how to solve the problem as described in my first mail for Digital Editions? Thanks for your  kind assistance.

Maybe you are looking for

  • PASSING A TABLE TO ANOTHER PROGRAM

    HII FRNDS CAN WE PASS A TABLE TO ANOTHER PROGRAM . I AM CALING THAT PROGRAM USING SUBMIT COMMAND. tHANKX ROHIT

  • Regarding-Copying from sales document type

    Hi Friends, I am trying to create Good Stock return with reference of sales invoice. While entering the reference number system is giving a error message which says u201CCopying from sales document type ZEXP to RE is not Supportedu201D. How to resolv

  • Purchase from High Sea Sales

    Hi SAP Fans, Can any one help to map Purchase from High Sea Sales in SAP.

  • #2 screen or monitor won't come into focus!

    #2 screen or monitor won't come into focus! Have gone from 1:3, 1:2, 1:1....none will come into focus. Lightroom 5 on Mac Pro. 24 gigs of ram. Use it as I have on LR#2,3,and 4 to view faces up close (on same monitor) while viewing full image in main

  • Why won't Mail.app rules won't migrate, System Tiger to System Leopard?

    Hi, Mail.app rules won't migrate from System Tiger to System Leopard. Here's what I did: -- Clean install of System Leopard 10.5.6 onto a new Mac Pro. -- Used Migration Assistment to move files from System Tiger to System Leopard 10.5.6. -- Mail.app'