Search
 

Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Quick login...


Or... now make it easy with Facebook Integration
Connect via Facebook



Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Setting default value in set of Radio buttons based on Role
Last Post 07-01-2009 02:32 PM by David To. 8 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Antony (WEBPC)User is Offline
river guide
river guide
Posts:152
Avatar

--
06-30-2009 07:17 PM

    For a new registration we have a radio button question with text/values for each of the available membership levels. On a successful registration we fire some SQL scripts to add the user to the appropriate role.

    Using the same form for renewal how can we default the answer to the one matching the expiring role?

    Any ideas?

    TIA

    Antony

    David ToUser is Offline
    river guide
    river guide
    Posts:2736
    Avatar

    --
    07-01-2009 07:10 AM
    First of all, when you're adding the user to the appropriate role, are you also adding an expiration date or is it left blank?
    If you are using the same form (moduleID), and fields (radio button), then you might consider changing your SQL script to a store procedure and on renewal, grab all the roles based on expirydate compared to the current getdate(). -- David
    Antony (WEBPC)User is Offline
    river guide
    river guide
    Posts:152
    Avatar

    --
    07-01-2009 07:38 AM

    For the roles in question we do set an expiry date.

    However, we are using a different form for renewal (a copy of the orginal).

    Have you got any examples of the SQL to set the default answer for the question?  Bearing in mind the user could be a member of other roles not related to thier annual 'club' membership

    Antony

    David ToUser is Offline
    river guide
    river guide
    Posts:2736
    Avatar

    --
    07-01-2009 08:42 AM
    Will there be only one expiring role (annual club membership) or multiple expiring roles (differing annual club membership) roles?

    If there's only one, then you might consider using a textbox. If multiple, then combobox. Anyhow, the SQL statement might be something similar to this:
    select roles.rolename as questionoption, roles.roleid as questionoptionvalue from roles inner join userroles on roles.roleid = userroles.roleid where userroles.expirydate <= getdate()

    You may need to tweak the SQL a little bit if this doesn't exactly work out but it gives you a basic idea. -- David
    Antony (WEBPC)User is Offline
    river guide
    river guide
    Posts:152
    Avatar

    --
    07-01-2009 09:14 AM

    David,

    What I am trying to do is show all the available membership levels at time of renewal, and default the answer to the expiring membership level of the user.

    The user will only be a member of one of the available roles.

    By my reading your suggestion would just put all the roles the current user is a member of.

    Can you use 'as questionoptionselected' to set which of the values is selected?

    TIA

    Antony

    Antony (WEBPC)User is Offline
    river guide
    river guide
    Posts:152
    Avatar

    --
    07-01-2009 09:25 AM

    Just looking at the configuration options and where would you put the SQL query?

    To set the default value using SQL I thought you could only return 1 field which had to be called 'DefaultValue' and you can't pass a variable (eg $UserID).

    Antony

    David ToUser is Offline
    river guide
    river guide
    Posts:2736
    Avatar

    --
    07-01-2009 09:33 AM
    Well, I know you can set a default value on combobox but the entries would have to be something you enter hard-coded. I don't believe there is a way to set a default value when your entries are pulled from an SQL statement since this gets pulled on page load from reading the SQL table so there's no way to know which values are available to choose as a default value before hand under "Advanced Field Options".

    What you can do is have a combobox that shows all the available membership levels and a separate textbox field that pulls the default expiring membership role of the user using an SQL statement.

    Also add in client side javascript on the combobox to set: $(textbox) = $(combobox). That way, if a user picks something else on the combobox, it will also appear on the textbox and overwrite the default there.

    Then use the textbox as the user choice for renewal. -- David
    Antony (WEBPC)User is Offline
    river guide
    river guide
    Posts:152
    Avatar

    --
    07-01-2009 12:58 PM

    David

    I am trying your suggestion.  I have created a TextBox field and am trying to set the default of this using the following SQL Query:

    SELECT TOP (1) Roles.RoleName AS DefaultValue FROM Roles INNER JOIN UserRoles ON Roles.RoleID = UserRoles.RoleID INNER JOIN Users ON UserRoles.UserID = Users.UserID WHERE (Users.UserID = $(UsersID)) AND ((Roles.RoleID = 29) OR (Roles.RoleID = 30) OR (Roles.RoleID = 31) OR (Roles.RoleID = 33) OR (Roles.RoleID = 32))ORDER BY UserRoles.ExpiryDate DESC

    However, whenever I 'update' the question it just reloads the page displaying the question options (instead of just displaying the dropdown box to select the question you want to change) AND the "question" field (above the short name) is cleared of the text that was there.

    If I replace the above SQL statement with the example one (Select count(*) As DefaultValue from users) under the SQL box everything saves OK but when you look at the field as a normal user nothing is displayed.

    I am using DynReg 3.2.7 on DNN 4.9.4

    Any ideas on how to get the SQL to work?

    TIA

    Antony

    David ToUser is Offline
    river guide
    river guide
    Posts:2736
    Avatar

    --
    07-01-2009 02:32 PM
    Perhaps problem is that the SQL statement can only be 200 characters max. Yours is 350 which is why it's not saving. You will need to create a stored procedure and call the stored procedure instead:

    create procedure usp_GetDefaultRole (@UserID int)
    as begin
    SELECT TOP (1) Roles.RoleName AS DefaultValue FROM Roles INNER JOIN UserRoles ON Roles.RoleID = UserRoles.RoleID INNER JOIN Users ON UserRoles.UserID = Users.UserID WHERE Users.UserID = @UserID AND Roles.RoleID in (29,30,31,33,32)
    order by Roles.ExpiryDate DESC
    end

    in the HOST / SQL (be sure to click on execute as script).
    In your question field, call the stored procedure as:
    exec usp_GetDefaultRole $(UserID)
    You are not authorized to post a reply.


     
     

    Join our mailing list...

    Get current news and events the easy way

     

     

       
    Subscribe Me
     
    Copyright 2005 - 2011 by Data Springs, Inc.