dynamically getting page titles

davilu
Mega Sage

Hi Experts,

In the code for KB Category Page widget, there's a line of code that gets the display name for the chosen knowledge page:

data.kb_knowledge_page = $sp.getDisplayValue("kb_knowledge_page") || "kb_view";

How would I write the code to get the title (NOT id) of the page?   I've tried dot-walking and using a getRefRecord, but they don't work for me.

data.page_name = $sp.getDisplayValue('kb_knowledge_page.title');

var ref = $sp.kb_knowledge_page.getRefRecord();

data.page_name = ref.getDisplayValue('title');

Is this possible?   Thanks!

2 REPLIES 2

boatner
Tera Contributor

I'd like to know this, too


Did you solve your issue? In a case that someone would need a solution;


1 solution) in your widget client script you can use $scope.page.title


2 solution) in your widget Link Function


function(scope, element, attrs, ctrl){


if (!scope.data)


          return;


var yourNewTitile = 'new title';


if(scope.data.table == '[table name]'){// your condition


        document.title = yourNewTitile+' - '+scope.portal.title; // changes tab


        scope.page.title = yourNewTitile; // changes page titles


  }


}