Forum Discussion
Redirecting document citation URLs in Microsoft Copilot Studio Code Editor
hc452 I also want to do this. Can you share more info about the steps you use to get to the code editor?
I pasted your entire post into ChatGPT, and this is what she said:
To correctly embed the variable `Name` into your record call within the citation URL, you need to adjust the syntax so that it dynamically accesses the record's key using the `Name` variable. In your current setup, it treats the entire expression as a string, which is why it's returning the literal text.
Here’s the correct approach:
Instead of this:
("&Topic.source_mapping_record.'doc1.docx'&")
You should use a dynamic reference, ensuring the key is interpreted as a variable, like this:
"(" & Topic.source_mapping_record[Name] & ")"
Here’s how the modified section of your code should look:
type: "Container",
items: ForAll(Topic.Answer.Text.CitationSources,
{
type: "TextBlock",
text: "[" & Id & "]: [" & Name & "](" & Topic.source_mapping_record[Name] & ")",
wrap: true,
size: "Small",
weight: "Lighter"
}
)
### Explanation:
- `Topic.source_mapping_record[Name]` dynamically retrieves the value from your record based on the current `Name` variable.
- `Name` is used as the key to access the corresponding SharePoint URL from `source_mapping_record`.
This way, the URLs will point to the correct SharePoint document based on the document's name dynamically, rather than being hardcoded.