Page 1 of 1

Use Document Custom Fields in a Wiki Content

Posted: Tue Jun 20, 2017 12:05 pm
by jejahner
Hello,

I want to insert a document custom field to a wiki content of the same document.

The ID of my custom field is documentAuthor and I'm looking for a code similar to "$document.getAllWorkitems()" and instead of workitems I need the information of the custom field.

Does anybody know how to solve my problem?

Kind regards!

Re: Use Document Custom Fields in a Wiki Content

Posted: Thu Jun 22, 2017 8:08 am
by jejahner
I just figured it out on my own:

I used the following code and it worked:

#set($customFieldID = "documentAuthor")
$document.getCustomField($customFieldID)

The ID is configured in the custom field configuration and $document automatically points to the document in which I'm adding the wiki content.

Re: Use Document Custom Fields in a Wiki Content

Posted: Mon Jul 10, 2017 5:29 am
by micdal
Hi,

Code: Select all

#set( $project = $trackerService.getProjectsService().getProject($trackerService.projectsService.getProject($page.getProject()).getId()) )
#set( $module = $trackerService.getModuleManager().getModule($project, $project.location.getLocation("myDocument")) )
#set( $cfContent = $module.getCustomField($cfBranchedFrom) )


worked for me (after replacing "myDocument" with the name of the document to work with, of course).

Regards,
Michaeƶ