{"action":"created","issue":{"url":"https://api.github.com/repos/volkanceylan/Serenity/issues/1247","repository_url":"https://api.github.com/repos/volkanceylan/Serenity","labels_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/1247/labels{/name}","comments_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/1247/comments","events_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/1247/events","html_url":"https://github.com/volkanceylan/Serenity/issues/1247","id":179776610,"number":1247,"title":"User Lookup","user":{"login":"mayatstafford","id":20777925,"avatar_url":"https://avatars.githubusercontent.com/u/20777925?v=3","gravatar_id":"","url":"https://api.github.com/users/mayatstafford","html_url":"https://github.com/mayatstafford","followers_url":"https://api.github.com/users/mayatstafford/followers","following_url":"https://api.github.com/users/mayatstafford/following{/other_user}","gists_url":"https://api.github.com/users/mayatstafford/gists{/gist_id}","starred_url":"https://api.github.com/users/mayatstafford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mayatstafford/subscriptions","organizations_url":"https://api.github.com/users/mayatstafford/orgs","repos_url":"https://api.github.com/users/mayatstafford/repos","events_url":"https://api.github.com/users/mayatstafford/events{/privacy}","received_events_url":"https://api.github.com/users/mayatstafford/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-28T13:42:51Z","updated_at":"2016-09-28T14:48:48Z","closed_at":null,"body":"I'm trying to create a lookup script that excludes that admin user (UserId 1) and shoes the DisplayName rather than the Username.\r\nI'm getting an error: \"Can't load script data\"\r\nTIA for any help!  Here's what I have:\r\n\r\nUser/UserLookupNotAdmin.cs\r\n\r\n    namespace EventManager.Administration.User.Scripts\r\n    {\r\n    using Entities;\r\n    using Serenity.ComponentModel;\r\n    using Serenity.Data;\r\n    using Serenity.Web;\r\n\r\n    [LookupScript(\"Administration.UserLookupNotAdmin\")]\r\n    public class UserLookupNotAdmin : RowLookupScript<UserRow>\r\n    {\r\n        public UserLookupNotAdmin()\r\n        {\r\n            IdField = UserRow.Fields.UserId.PropertyName;\r\n            TextField = UserRow.Fields.DisplayName.PropertyName;\r\n        }\r\n\r\n        protected override void PrepareQuery(SqlQuery query)\r\n        {\r\n            var fld = UserRow.Fields;\r\n            query.Distinct(true)\r\n                .Select(fld.UserId)\r\n                .Select(fld.DisplayName)\r\n        .Where(\r\n            new Criteria(fld.UserId) != 1\r\n            );\r\n        }\r\n    }\r\n}\r\n\r\nLoan/LoanRow.cs\r\nThe table Loan has a \"UserId\" column.\r\n\r\n            [DisplayName(\"Staff\"), NotNull, ForeignKey(\"[dbo].[Users]\", \"UserId\"), LeftJoin(\"jUser\"), TextualField(\"StaffDisplayName\")]\r\n        public Int32? UserId\r\n        {\r\n            get { return Fields.UserId[this]; }\r\n            set { Fields.UserId[this] = value; }\r\n        }\r\n\r\n        [DisplayName(\"Staff\"), Expression(\"jUser.[DisplayName]\")]\r\n        public String StaffDisplayName\r\n        {\r\n            get { return Fields.StaffDisplayName[this]; }\r\n            set { Fields.StaffDisplayName[this] = value; }\r\n        }\r\n\r\nLoanForm.cs\r\n\r\n    [LookupEditor(typeof(Administration.User.Scripts.UserLookupNotAdmin))]\r\n        public Int32 UserId { get; set; }\r\n"},"comment":{"url":"https://api.github.com/repos/volkanceylan/Serenity/issues/comments/250189141","html_url":"https://github.com/volkanceylan/Serenity/issues/1247#issuecomment-250189141","issue_url":"https://api.github.com/repos/volkanceylan/Serenity/issues/1247","id":250189141,"user":{"login":"mayatstafford","id":20777925,"avatar_url":"https://avatars.githubusercontent.com/u/20777925?v=3","gravatar_id":"","url":"https://api.github.com/users/mayatstafford","html_url":"https://github.com/mayatstafford","followers_url":"https://api.github.com/users/mayatstafford/followers","following_url":"https://api.github.com/users/mayatstafford/following{/other_user}","gists_url":"https://api.github.com/users/mayatstafford/gists{/gist_id}","starred_url":"https://api.github.com/users/mayatstafford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mayatstafford/subscriptions","organizations_url":"https://api.github.com/users/mayatstafford/orgs","repos_url":"https://api.github.com/users/mayatstafford/repos","events_url":"https://api.github.com/users/mayatstafford/events{/privacy}","received_events_url":"https://api.github.com/users/mayatstafford/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T14:48:48Z","updated_at":"2016-09-28T14:48:48Z","body":"Thank you.   This is what worked:\r\n    \r\n    namespace EventManager.Administration.User.Scripts{\r\n    using Entities;\r\n    using Serenity.ComponentModel;\r\n    using Serenity.Data;\r\n    using Serenity.Web;\r\n\r\n    [LookupScript(\"Administration.UserLookupNotAdmin\")]\r\n    public class UserLookupNotAdmin : RowLookupScript<UserRow>\r\n    {\r\n        public UserLookupNotAdmin()\r\n        {\r\n            IdField = UserRow.Fields.UserId.PropertyName;\r\n            TextField = UserRow.Fields.DisplayName.PropertyName;\r\n        }\r\n\r\n\r\n        protected override void PrepareQuery(SqlQuery query)\r\n        {\r\n            base.PrepareQuery(query);\r\n            var fld = UserRow.Fields;\r\n            query.Distinct(true)\r\n                .Select(fld.UserId)\r\n                .Select(fld.DisplayName)\r\n        .Where(\r\n            new Criteria(fld.UserId) != 1\r\n            );\r\n        }\r\n    }\r\n}\r\n\r\n\r\nand in LoanForm.cs:\r\n\r\n    [LookupEditor(\"Administration.UserLookupNotAdmin\")]\r\n        public Int32 UserId { get; set; }\r\n\r\n\r\n"}}
{"actor":{"display_login":"mayatstafford"}}