Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Greg Jenson 24 posts 157 karma points
    Feb 21, 2019 @ 17:25
    Greg  Jenson
    0

    Macro not returning the url to the pdf

    Not sure why I can't make this work...

    @foreach(var item in selection) {
                <tr>
                    <td><a href="@item.GetPropertyValue("policyFile")">@item.Name</a></td>
                    <td>@String.Format("{0:dd MMMM yyyy}", item.GetPropertyValue("approveDate"))</td>
                </tr>
            }
    

    Running a macro and I need to get the url to the pdf from 'policyFile', but instead I'm getting the nodeID (see image). This seems like it should be pretty simple and I'm not sure what I'm missing. The page otherwise loads correctly - just can't get the link to the pdf to work.

    Suggestions?

    enter image description here

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 21, 2019 @ 19:54
    Dirk De Grave
    100
    <td><a href="@Umbraco.TypedMedia(item.GetPropertyValue<int>("policyFile")).Url">@item.Name</a></td>
    

    should do the trick if your policyFile property is a media picker

    --Dirk

  • Greg Jenson 24 posts 157 karma points
    Feb 21, 2019 @ 20:22
    Greg  Jenson
    0

    Dirk, you are my hero! Perfect - thank you.

Please Sign in or register to post replies

Write your reply to:

Draft