Copied to clipboard

Flag this post as spam?

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


  • Christian Schmidt 7 posts 47 karma points
    16 days ago
    Christian Schmidt
    0

    Accessing record data in Razor view

    Use case:

    User uploads data through a form, a custom workflow fires and redirects the user to a page with the record's uniqueId as a url param. On this page I want to display some of the data from the form record - how do I do this? I can't seem to find anything in the documentation that allows me to access a record directly from the unique ID.

    In Umbraco 7 we could use the RecordStorage to do this

  • Christian Schmidt 7 posts 47 karma points
    1 week ago
    Christian Schmidt
    100

    If anyone has the same issue as I did: I managed to work around this by doing a dependency injection in a surface controller:

    public class SubscriberSurfaceController : SurfaceController {

        private IRecordStorage _recordStorage;
        private IFormStorage _formStorage;
    
        private Guid formGuid = new Guid("Form GUID here");
    
        public SubscriberSurfaceController(IRecordStorage recordStorage, IFormStorage formStorage)
        {
            _recordStorage = recordStorage;
            _formStorage = formStorage;
        }
    
        public void GetRecordData(string recordId)
        {
    
            Form form = _formStorage.GetForm(formGuid);
            Record record = _recordStorage.GetRecordByUniqueId(new Guid(recordId), form);
    
    
            //Do stuff with record here
        }
    
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft