Is CreatedBy Propery on Note object readonly?

Discussions related to custom development with Select.
Post Reply
HariK
Posts: 25
Joined: Wed Feb 23, 2011 4:15 pm

Is CreatedBy Propery on Note object readonly?

Post by HariK »

Hi, I am able to add note using below code snippet

Code: Select all

            using (dynamic order = os.NewOrder(orderSpec))
            {
                .......
                IOrder o = order;
                dynamic spNote = o.CreateNew("Note");
                spNote.Text = "Howdy123";
                spNote.IsInternal = true;

                order.Notes.Add(spNote);
                os.ApplyChanges(order);

Question is, can I set CreatedBy property on the Note?
and if yes, is this (below code) the right way to get & set an identity?

Code: Select all

                ISecurityManager securityManager = (ISecurityManager)o.GetService(typeof(ISecurityManager));
                string username = "Hari Katukuri";
                ISecurityIdentity identity = securityManager.Identities.Where(i => !i.IsGroup && i.Enabled && !i.Deleted && !i.IsSystem && i.FullName == username).FirstOrDefault();
                if (identity != null)
                {
                    //ISecurityUser user = securityManager.GetUser(identity.ID);
                    spNote.CreatedBy = identity;
                }
Joni Hoffman
Posts: 18
Joined: Fri Oct 03, 2008 1:12 pm

Re: Is CreatedBy Propery on Note object readonly?

Post by Joni Hoffman »

The CreatedBy property on the Note object is ReadOnly. It will automatically be set to the user that created it.
Joni Hoffman
Software Developer
SoftPro
HariK
Posts: 25
Joined: Wed Feb 23, 2011 4:15 pm

Re: Is CreatedBy Propery on Note object readonly?

Post by HariK »

Thanks for the confirmation Joni, looks like its a change in 3.0

In 2.6 we were able to set the user our self

Code: Select all

            var newNote = order.Note.CreateNew();
            newNote.Content = note.Details;
            newNote.CreateDate = note.Date;
            newNote.Trustee = order.AllUsers.FirstOrDefault(t => string.Equals(t.FullName, "UserName", StringComparison.CurrentCultureIgnoreCase));
Post Reply