1

When my page loads with a form, the query string contains a GUID of a property detail item. I want the URL of this property in the mail that triggers on submit button click of the form.

I created a model

 public class PropertyInfoViewModel : FieldViewModel
{
    public string PropertyUrl { get; set; }

    protected override void InitItemProperties(Item item)
    {
        base.InitItemProperties(item);
        try
        {
            if (Guid.TryParse(WebUtil.GetSafeQueryString("itemId"), out Guid propertyId))
            {
                var product = Sitecore.Context.Database.GetItem(WebUtil.GetSafeQueryString("itemId"));  // get product with the id
                var options = LinkManager.GetDefaultUrlOptions();
                options.AlwaysIncludeServerUrl = true;
                PropertyUrl = LinkManager.GetItemUrl(product, options);
            }
        }
        catch (Exception ex)
        {
            Log.Error("Error occured while processing customised form fields.", ex.StackTrace);
        }
    }
}

and a view

<div class="component col-md-12 link common-link common-breadcrumb">
<div class="component-content">
    <div class="field-link">
        @{
            <a href="@Model.PropertyUrl" class="">Property</a>
        }
    </div>
</div>

Now, I added a field type at the path /sitecore/system/Settings/Forms/Field Types/Basic enter image description here

And dragged and dropped it onto my form.enter image description here

Finally, On the submit click added a send mail submit action. The email campaign selected reads this value as a token $form_PropertyLink$. But this value is not getting replaced in the mail, it is coming as it is. The form values like firstname, surname are getting replaced. Am I missing something? Any help would be highly appreciated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.