Copied to clipboard

Flag this post as spam?

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


  • Yanick Van Barneveld 27 posts 148 karma points
    Nov 03, 2016 @ 12:13
    Yanick Van Barneveld
    0

    UIOMaticListViewField

    Hi,

    I am trying to create a field that has te be shown at the listView. I am creating this field as following:

    [UIOMaticListViewField, Ignore]
    public string MemberName { get { return
    MemberRepository.ngetMember(MemberId).ToString(); } }
    

    This works perfectly at the listView but now, when I want to create a new item is gives the following error (logs are empty):

    Server error: Contact administrator, see log for full details.
    Failed to get scaffold
    

    I can not find any information about this on the internet or in the documentation. Am I missing something?

    Kind regards, Yanick

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Nov 03, 2016 @ 12:21
    Tim Geyssens
    0

    Hi Yanick,

    Hmm must say I haven't tried it with a getter that actually does anything :p so you might have hit a bug, will try to reproduce and come back to you.

    The scaffold method basically does the following

    public object GetScaffold(Type type)
        {
            var obj = Activator.CreateInstance(type);
    
            var a1 = new ObjectEventArgs(type, obj);
            UIOMaticObjectService.OnScaffoldingObject(a1);
    
            return a1.Object;
        }
    

    So don't see immediatly why it would fail

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Nov 03, 2016 @ 12:23
    Tim Geyssens
    0

    you MemberRepository when is that initialized ?

  • Yanick Van Barneveld 27 posts 148 karma points
    Nov 03, 2016 @ 12:24
    Yanick Van Barneveld
    0

    It is just a simple class with a static method that looks like this:

    public static Models.Member ngetMember(int id)
        {
            var db = ApplicationContext.Current.DatabaseContext.Database;
            return db.Single<Models.Member>(id);
        }
    
  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Nov 03, 2016 @ 12:24
    Tim Geyssens
    1

    Ok thanks for the details, will give it a go

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Nov 03, 2016 @ 12:29
    Tim Geyssens
    100

    It's probably because MemberId is still null, so try checking for that before calling the MemberRepository

    Something like

    [UIOMaticListViewField, Ignore]
    public string MemberName { 
      get { 
                if(MemberId == null)
                      return string.Empty;
    
                return MemberRepository.ngetMember(MemberId).ToString(); 
            }
    }
    

    Let me know if that does the trick

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Nov 03, 2016 @ 12:34
    Tim Geyssens
    1

    And I assume memberId is an int so the check will be

    if(MemberId == 0) return string.Empty;

  • Yanick Van Barneveld 27 posts 148 karma points
    Nov 03, 2016 @ 13:20
    Yanick Van Barneveld
    0

    Awesome that was the trick! You rock Tim!

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Nov 03, 2016 @ 13:23
    Tim Geyssens
    1

    No prob, hope the project is useful to you :)

  • 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