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 10 posts 51 karma points
    Jul 16, 2021 @ 10:30
    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 10 posts 51 karma points
    Jul 19, 2021 @ 08:39
    Christian Schmidt
    101

    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
        }
    
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies