I want to get parent term set id in SharePoint online using term_parent.get_id(); in below code.I am getting all terms but unable to get parent term id.It is giving me error as
Uncaught Error: Object reference not set to an instance of an object on server. The object is associated with property Parent.
Even loading Parent property is not working.
Please help.
var terms = termSet.getAllTerms();
context.load(terms, 'Include(IsRoot, Labels, TermsCount, CustomSortOrder, Id, IsAvailableForTagging, Name, PathOfTerm, Parent, TermSet.Name)');
context.executeQueryAsync(function(){
var termEnumerator = terms.getEnumerator();
while(termEnumerator.moveNext()){
var currentTerm = termEnumerator.get_current();
var term_name = currentTerm.get_name();
var term_id = currentTerm.get_id();
var term_customsortoder = currentTerm.get_customSortOrder();
var term_parent = currentTerm.get_parent();
var terms_count = currentTerm.get_termsCount();
var term_path = currentTerm.getPath();
var term_allterms = currentTerm.getTerms();
var parent_id = term_parent.get_id();
}