Hi Marco. The custom field can be filled in automatically by a JS workflow. In your case, this example code should work:
const entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
title: 'Fill in telephone number field based on user attribute',
guard: (ctx) => {
return ctx.issue.becomesReported && ctx.issue.reporter.attributes['Telefonnummer'];
},
action: (ctx) => {
const issue = ctx.issue;
issue.fields.Telefonnummer = issue.reporter.attributes['Telefonnummer'];
},
requirements: {
Telefonnummer: {
type: entities.Field.stringType,
name: "Telefonnummer"
}
}
});
After you attach this a workflow rule with this code, you'll also need to click the button to apply fixes in Workflows to have the Telefonnummer field added to the project. Overall, you may refer to JavaScript Workflow Quick Start Guide if you want to develop similar workflows in JS.
So, when I made this Workflow, will the telephone number visible in every ticket (old an newly made) of this reporter?
This depends on how you configure your workflow rule. In the example provided earlier, the telephone number will only be populated when a ticket is created. You can extend this by adding an on-schedule rule to update existing tickets if needed. The documentation linked before will give you more details on how to achieve this.
Can you explain your idea? I just want to show some of the Fields of the reporter in the grey box of the tickets. The reporter's telephone and the field “Firma" (aka company).
The approach Stanislav suggested does exactly this. If a reporter has a phone number in their profile attribute, the corresponding field will automatically populate when the reporter creates a ticket. You can apply the same approach to other profile attributes.
Hi Marco. The custom field can be filled in automatically by a JS workflow. In your case, this example code should work:
After you attach this a workflow rule with this code, you'll also need to click the button to apply fixes in Workflows to have the
Telefonnummer
field added to the project. Overall, you may refer to JavaScript Workflow Quick Start Guide if you want to develop similar workflows in JS.Thank you.
So, when I made this Workflow, will the telephone number visible in every ticket (old an newly made) of this reporter?
Hello,
can you explain your idea? I just want to show some of the Fields of the reporter in the grey box of the tickets.
The reporters telephone an the field “Firma" (aka company)
Hello Marco,
This depends on how you configure your workflow rule. In the example provided earlier, the telephone number will only be populated when a ticket is created. You can extend this by adding an on-schedule rule to update existing tickets if needed. The documentation linked before will give you more details on how to achieve this.
The approach Stanislav suggested does exactly this. If a reporter has a phone number in their profile attribute, the corresponding field will automatically populate when the reporter creates a ticket. You can apply the same approach to other profile attributes.
Sorry, I am confused.
First you wrote, I have to add something to the workflow, to get the phone number in any new ticket.
In the last paragraph, you wrote, that I will not have to do, and the approach will do everything.
Thanks for your response.
The suggested approach is to create a workflow that automatically takes data from the user profile and populates it in the ticket fields.