PaulS1

Displaying Taxonomy Data from a SubLibrary

Discussion created by PaulS1 on Mar 19, 2018
Latest reply on Mar 21, 2018 by PaulS1

I have the following script in a button link action which sends a formatted email and includes a list of associated documents:

var documentLinks = '<span style="font-size:1.8em;font-weight:400;color:#660033;">Business Entity | '+[[Entity]]+'</span><br><span style="font-size:1.4em;font-weight:400;color:#333;">Business Process | '+[[Department]]+'</span><br>Date | ' + [[MeetingDate]] +'<br><br>';
documentLinks += 'The documents are listed below are for the upcoming meeting on the '+[[Start_x0020_Time]]+'<br>Link to the documents <a href=\'https://intranet.ayaltis.com/sites/management/Pages/KeyDocsView.aspx?entity='+[[Entity]]+'&Department='+[[Department]]+'&TargetDate='+[[=([[Start_x0020_Time]].getFullYear()+'-'+([[Start_x0020_Time]].getMonth()+1)+'-'+([[Start_x0020_Time]].getDate()))]]+'\'>Meeting Documents List</a><br>Please review them.<br><br>';
var documents=[[@Site.QueryList('sites/management/KeyDocs','<Where><And><Eq><FieldRef Name=\'TargetDate\'></FieldRef><Value IncludeTimeValue=\'FALSE\' Type=\'DateTime\'>'+[[=([[Start_x0020_Time]].getFullYear()+'-'+([[Start_x0020_Time]].getMonth()+1)+'-'+([[Start_x0020_Time]].getDate()))]]+'</Value></Eq><Eq><FieldRef Name=\'Entity\' /><Value Type=\'TaxonomyFieldType\'>'+[[Entity]]+'</Value></Eq></And><And><Eq><FieldRef Name=\'Department12\' /><Value Type=\'Text\'>'+[[Department]]+'</Value></Eq></And><And><Neq><FieldRef Name=\'ApprovalStatus\' /><Value Type=\'ModStat\'>Draft</Value></Neq></And></Where>',100,'FileLeafRef,FileRef,Document_x0020_Type,Modified_x0020_By,Modified','Scope=\'Recursive\'')]];
var documentCount = documents.length;
documentLinks += '<table style="border: none;"><td>Type</td><td>Title</td><td>Modified</td><td>Modified By</td><td>Status</td>';

for (var i = 0; i < documentCount; i++) {
documentLinks +='<tr style="background-color:#eee;"><td style="margin: 12px 2px 2px 2px;">'+ documents[i].Document_x00200_Type +'</td><td><a href="https://intranet.ayaltis.com' + documents[i].FileRef + '"> ' + documents[i].FileLeafRef + '</a></td><td>'+ documents[i].Modified +'</td><td>'+ documents[i].Modified_x0020_By +'</td><td>'+documents[i].ApprovalStatus+'</td></tr>';
}
documentLinks += '</table>';
documentLinks += '<br>Best regards<br><br>'+ [[@User.Title]];
return documentLinks;

The problem is that some of the columns in the list are Taxonomy fields (Managed Metadata columns) and the result is as follows:

 

Type should return the "Document_x0020_Type" which can be Agenda, Minutes, etc.
Status should be Draft, Pending, Approved.

Modified By should have the users name i.e. Paul Shadwell and not the user's object name.
Modified should be a formatted date such as 06/11/2017

 

Any help to solve this would be greatly appreciated.

 

Best regards

 

Paul

Outcomes