How to add a Comment field to the User page

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
Post Reply
User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

How to add a Comment field to the User page

Post by AbleMods » Wed Mar 19, 2008 4:38 pm

Introduction
I have seen a few requests from folks who would like a way to store comments for a particular user. It may be something like "What a swell guy" or it could even be "Problem customer: high RMA rate".
Regardless of your reasons, it would be nice to have such a feature. Fortunately, the field exists in the database. It's just been left off the Edit User page for some reason. This modification describes how to easily add the field to the screen.

I know I said I was going to be away for a while. Well, I wound up with some spare time and needed this particular change. Once I realized how simple it was, I recalled others wanted it too, so I decided to document it.

As always, make a backup of the files involved in case something bad happens.

HTML Changes
The file we're going to change is ~/Admin/People/Users/EditUser.aspx. There is no code-behind file, so all the changes will occur in the same file.

Edit the file and find this section of code in the HTML section towards the end of the file:

Code: Select all

                            <asp:DropDownList ID="Residence" runat="server">
                                <asp:ListItem Text="This is a residence" Value="1"></asp:ListItem>
                                <asp:ListItem Text="This is a business" Value="0"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
and replace all of it with this code:

Code: Select all

                            <asp:DropDownList ID="Residence" runat="server">
                                <asp:ListItem Text="This is a residence" Value="1"></asp:ListItem>
                                <asp:ListItem Text="This is a business" Value="0"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th class="rowHeader">
                            Comment:</th>
                        <td colspan="3">
                            <asp:TextBox ID="Comment" runat="server" Height="95px" TextMode="MultiLine" Width="445px"></asp:TextBox></td>
                    </tr>
We've changed the screen display but the page doesn't know how to save or load the actual field contents. Let's do that next....

Code Changes
There are two changes to made in the code. One reads the existing Comment field value into the page. The other writes it back to the User record before the record is saved.

First, find this line of code in the InitializeForm function near the beginning:

Code: Select all

            Residence.SelectedIndex = (address.Residence ? 0 : 1);
and add this line immediately below it:

Code: Select all

            Comment.Text = _User.Comment;
Now, find this line of code further down in the SaveUser() function:

Code: Select all

            address.Residence = (Residence.SelectedIndex == 0);
and add this line immediately below it:

Code: Select all

            _User.Comment = Comment.Text;
Save the page.

Testing
Go ahead and pull up your User page and edit any user. You should now see a large, unlimited text box below the address area. Try it out and type something into it, then Save the user. Return to your Dashboard, then again to the User page. Pull up the User and see if your changes were saved.

Conclusion
Having the ability to store comments with a particular user account can give an admin useful insight into the customer. Any opportunity to know more about who you are dealing with is an opportunity to succeed. Knowledge truly is power.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

FmaAlbee
Lieutenant (LT)
Lieutenant (LT)
Posts: 51
Joined: Fri Sep 12, 2008 2:12 pm

Re: How to add a Comment field to the User page

Post by FmaAlbee » Wed Oct 08, 2008 3:26 pm

**
Last edited by FmaAlbee on Fri Oct 10, 2008 8:13 am, edited 1 time in total.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: How to add a Comment field to the User page

Post by AbleMods » Wed Oct 08, 2008 3:34 pm

There is no member ID field in the Users table.

This post is about adding an existing comment field to an existing display page. The comment field isn't displayed by default, but the comment field exists in the table.

This technique only works if the field already exists in the ac_Users table.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

FmaAlbee
Lieutenant (LT)
Lieutenant (LT)
Posts: 51
Joined: Fri Sep 12, 2008 2:12 pm

Re: How to add a Comment field to the User page

Post by FmaAlbee » Wed Oct 08, 2008 3:47 pm

**
Last edited by FmaAlbee on Fri Oct 10, 2008 8:14 am, edited 1 time in total.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: How to add a Comment field to the User page

Post by AbleMods » Wed Oct 08, 2008 5:59 pm

Ok.

Use the comments field but CALL it Member ID on the screens.

Now you have a Member ID field :wink:
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

FmaAlbee
Lieutenant (LT)
Lieutenant (LT)
Posts: 51
Joined: Fri Sep 12, 2008 2:12 pm

Re: How to add a Comment field to the User page

Post by FmaAlbee » Thu Oct 09, 2008 7:45 am

**
Last edited by FmaAlbee on Fri Oct 10, 2008 8:13 am, edited 1 time in total.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: How to add a Comment field to the User page

Post by AbleMods » Thu Oct 09, 2008 8:14 am

Well, you are sort of asking for help doing the actual design of a custom modification. That's usually a paid service with custom developers such as myself. Depending on the complexity of the request, some posts won't get an effective response. As you've seen, it's not as easy sifting through 20 text messages to come to a solution. Especially if the recipient is not fluent in .Net programming.

In general, you're on the right track but don't confuse the solution. If you're already using UserSettings, don't switch to the comment field. User settings will accomplish exactly what you need. You can have a custom MemberID field associated with each user record.

From there you'll have to modify the login page to accomodate your customized member ID validation requirements. It'll have to accept the visitor member ID input, identify the user record for that member ID and validate it against your SQL stored procedure. But if you're going to all this development effort, skip the stored procedure and just code it in .Net. The less complexity and less diversity in your programming, the more stable it will be and less difficult to troubleshoot when (not if) issues arise.

You'll also have to give yourselves some sort of way to manage/edit these member ID values on the backend, presumably on the edituser.aspx page.

If all if this seems beyond your available skillset(s), my recommendation would be to contact any number of the Able partners to discuss a custom modification. I've been where you are now, and that level of frustration does nothing to help you run your business.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

FmaAlbee
Lieutenant (LT)
Lieutenant (LT)
Posts: 51
Joined: Fri Sep 12, 2008 2:12 pm

Re: How to add a Comment field to the User page

Post by FmaAlbee » Thu Oct 09, 2008 8:31 am

**
Last edited by FmaAlbee on Fri Oct 10, 2008 8:13 am, edited 1 time in total.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: How to add a Comment field to the User page

Post by AbleMods » Thu Oct 09, 2008 9:42 am

I'm sorry to hear you are unhappy. I thought I had done everything I could for you save actually write, debug and upload the programming code itself.

ANY change from the default installation of AC7 is custom. It doesn't matter if you're changing "Cart" to say "Basket" or adding all new functionality not previously designed into the system. All of that is custom.

But if your primary decision to purchase AbleCommerce was based on the presumption that your customizations would be designed, written, tested and deployed for free by others in the forum....that's quite an expectation don't you think?

The entire community here is happy to help. We've grown substantially as developers and site admins by helping each other whenever possible. But we all do this for free - none of us are paid for our time and effort with the exception of Able staff. We have jobs and businesses of our own to run.

Assuming forum members will design, develop and test your specific customizations is not a reasonable expectation. We will always be happy to help you along the way as best we can, but we cannot do all the work for you. You as an AC7 site owner must assume some responsibility for the choices you make regarding your particular site functionality.

Perhaps Mazhar could you help in this situation. He is very skilled with his responses to forum posts.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

FmaAlbee
Lieutenant (LT)
Lieutenant (LT)
Posts: 51
Joined: Fri Sep 12, 2008 2:12 pm

Re: How to add a Comment field to the User page

Post by FmaAlbee » Thu Oct 09, 2008 10:35 am

**
Last edited by FmaAlbee on Fri Oct 10, 2008 8:14 am, edited 1 time in total.

Robbie@FireFold
Commodore (COMO)
Commodore (COMO)
Posts: 433
Joined: Wed May 28, 2008 9:42 am
Location: Concord, NC
Contact:

Re: How to add a Comment field to the User page

Post by Robbie@FireFold » Fri Oct 10, 2008 7:29 am

A big thanks to JOE!!

This works great and is free. Complaining about that is pretty worthless.
Robbie Hodge
General Manager
Robbie@FireFold.com
http://www.FireFold.com

Thistle3408
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Apr 19, 2010 4:52 pm

Re: How to add a Comment field to the User page

Post by Thistle3408 » Sat Jul 03, 2010 9:54 am

Joe,
Do you have any update on this post?

Using AC 7.0.4 the fields moved around, it appears. Now the "residence/business" is in the AddressBook.ascx modules. I don't mind that.
I can clearly get the comment field to appear as a text box, but I can not get the comments entered to be saved and/or redisplayed.

I suspect this is because the save has to have changed.

_User.Comment = Comment.Text;
address.Save();

I'll look further to see if I can figure it out, but if you know what has to change and can save me the time, it would be great.

Thistle3408
Lieutenant (LT)
Lieutenant (LT)
Posts: 77
Joined: Mon Apr 19, 2010 4:52 pm

Re: How to add a Comment field to the User page

Post by Thistle3408 » Sun Jul 04, 2010 9:48 am

Joe,
If you see the post above, I solved it.
Here's how.
In AC 7.0.4, as mentioned they use a tab for user, another for address, etc.

So, instead of putting the <asp:TextBox ID="Comment" stuff after the address I put it in the "account" tab area in "edituser.aspx".
Same stuff you suggest.

Then the two lines of code (to pull the "comment" field for display and to include it in the information "saved" I put the two code lines in an appropriate place in the "edituser.aspx.cs" module.

So, it works fine now. If anyone wants the detail I can supply it.

mouse_8b
Commander (CMDR)
Commander (CMDR)
Posts: 115
Joined: Mon Oct 11, 2010 1:21 pm
Location: Austin, TX
Contact:

Re: How to add a Comment field to the User page

Post by mouse_8b » Tue Sep 06, 2011 12:37 pm

Update for AC 7.0.7

This puts the comment field on the first tab ("Account") of the Edit User page.

In ~/Admin/People/Users/EditUser.aspx find:

Code: Select all

<td>
   <asp:DropDownList ID="Affiliate" runat="server" AppendDataBoundItems="true" DataSourceID="AffiliateDS" DataTextField="Name" DataValueField="AffiliateId" OnDataBound="Affiliate_DataBound">
      <asp:ListItem Selected="True" Value="0" Text="No Affliate"></asp:ListItem>
   </asp:DropDownList>
   <asp:Label ID="ReferredDate" runat="server" Text=""></asp:Label>
   <asp:ObjectDataSource ID="AffiliateDS" runat="server" SelectMethod="LoadForStore" TypeName="CommerceBuilder.Marketing.AffiliateDataSource" DataObjectTypeName="CommerceBuilder.Marketing.Affiliate">
      <SelectParameters>
      <asp:Parameter Name="sortExpression" DbType="String" DefaultValue="Name" />
      </SelectParameters>
   </asp:ObjectDataSource>
</td>
</tr>
And put this right below it:

Code: Select all

<!-- Added to show comments about user -->
<tr>
   <th class="rowHeader">Comment:</th>
   <td colspan="3">
      <asp:TextBox ID="Comment" runat="server" Height="95px" TextMode="MultiLine" Width="445px"></asp:TextBox>
   </td>
</tr>
<!-- End Add -->
In ~/Admin/People/Users/EditUser.aspx.cs find:

Code: Select all

protected void SaveAccountButton_Click(object sender, EventArgs e)
{
    string newUserName = UserName.Text.Trim();
        if (Page.IsValid && ValidateNewUserName(newUserName))
        {
            //UPDATE ACCOUNT SETTINGS
            _User.UserName = newUserName;
            _User.Email = Email.Text;
            _User.PrimaryAddress.Email = Email.Text;
put this right under it:

Code: Select all

//Added for user comments
_User.Comment = Comment.Text;
//end add
Still in EditUser.aspx.cs find:

Code: Select all

#region Account Page
    protected void InitializeAccountPage()
    {
        // INITIALIZE LEFT COLUMN WITH ADJUSTABLE ACCOUNT SETTINGS
        UserName.Text = _User.UserName;
        Email.Text = _User.Email;
        InitializeChangeGroupsJS();
        IsDisabled.Enabled = (_User.UserId != Token.Instance.UserId);
        IsDisabled.Checked = !_User.IsApproved;
        ShowHideDisabledAlert();
put this right below it:

Code: Select all

//Added for user comments
Comment.Text = _User.Comment;
//end add

mouse_8b
Commander (CMDR)
Commander (CMDR)
Posts: 115
Joined: Mon Oct 11, 2010 1:21 pm
Location: Austin, TX
Contact:

Re: How to add a Comment field to the User page

Post by mouse_8b » Thu Dec 13, 2012 4:19 pm

FYI, the comment field is also used when a customer needs a password reset. Anything in the comment box will be erased if the user resets their password.

User avatar
AnySupport
Lieutenant (LT)
Lieutenant (LT)
Posts: 73
Joined: Fri Feb 17, 2012 8:58 am

Re: How to add a Comment field to the User page

Post by AnySupport » Thu Apr 18, 2013 6:22 am

I know this is an old post, but it covers the same question/area I posted on the other board.

Context: I'm only inquiring about potentials of a feature like this, I admit I cannot completely comprehend the code or try implementing this myself. It looks like this is only for a single comment and ideally I am looking for any option of keeping a log on a customer like you could for a note log on an order, either within the system or by just tieing in a third party service (email help desk/ticket type thing or ?? purely brainstorming)

So, despite all that, the short question to Joe, or anyone else, is: if you implemented this or something like this, have you had any experience in evaluating or implementing this again in a Gold instance?

Thank you!

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: How to add a Comment field to the User page

Post by jmestep » Fri Apr 19, 2013 4:51 am

See my answer to the other post. That was on Able 7, but it would be possible in Gold also.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply