Recently Viewed...
To help you navigate to pages you most recently visited, select from the links below.
Product Forums
Sharepoint Forums
DNN Modules
SnowCovered Top Sellers

Ultra Media Gallery 5.3
Ultra Media Gallery is the most popular photo gallery and media gallery module for DotNetNuke, the major purpose of this module is to allow you create unlimited pictures and medias to your gallery and organize them by albums, your albums and medias are browsed in flash interface.

Ultra Video Gallery 2.3
Ultra Video Gallery is a brother product of Ultra Media Gallery, The major purpose of this product is to provide an easy way to add videos in various formats to your website by and play them in a unique flash gallery.

Flex By DrNuke
The Flex skins are professionally designed, coded and packaged by a team of DotNetNuke experts. Available in 8 great colours, each with 15 banner images, 2 menu types and a choice of 3 background styles. The entire pack features a total of 2472 skins!

Engage: Publish 5.1
Content Workflow + Versioning + Categorization + Multiple Display Options = Truly Advanced DotNetNuke Content Management (Requires DNN 4.5.1 or later)

XMod 5.1
Version 5 of the perennial best-selling tool for creating data-based solutions in DNN without custom programming. This version focuses on greater flexibility, expandability, and ease-of-use.

Events Calendar and Registration 2.1.8 for DNN4.xx
One stop solution for events calendar and events registration! Demo site available for free trial.

Open-DocumentLibrary v3.0
Powerful, Ajax Enabled, Easy to Use. Document Management has never been better. Open-DocumentLibrary allows DotNetNuke users to share and manage documents in a flexible, intelligent way, offering granular control over Folder and Document access.

DNNMasters SEO Suite Enterprise w/Source
If you want better Search Engine ranking you need KeepAlive, URL Rewrite, Custom 404 error, Custom Redirect, Friendly URL's, Sitemap, Google Sitemap.DNNMasters SEO Suite delivers all of it and more!

Form Master 1.6 For DNN 4
Form Master 1.6 improves on the success of version 1.5 with new features in Function, and Presentation, while maintaining the Intuitive User Interface. Form Master 1.6 delivers visual form design where input fields can easily be created, modified, and moved.

Document Exchange Professional 4
Edit documents directly on your server using the latest iteration of the premier document management solution for DotNetNuke (DNN). With a completely revised Ajax-enabled UI.
    |   Register   |   Friday, September 05, 2008   
Data Springs Product Forums...
Subject: Multiple Completion Events mapped to single Dynamic Field?
Prev Next
You are not authorized to post a reply.

Author Messages
Paul
Posts:34
paddling down the creek
paddling down the creek

05/21/2008 4:44 PM  

I have a checkbox dynamic field that is defaulted to checked and this field is tied to a completion event that adds the user to a role. 

 

I would like that if the user unchecks the box that they would be added to a different role I specify. I have another completion event tied to this same dynamic field but speficifies that the box is unchecked and when this is the case the user is added to another role.

 

In testing, when the box is checked, the user gets added to the proper role as they should.  When unchecked, the user still gets added to the role asociated with the checked box completion event.

 

Is there another way to do this or should this be working?

 

Thanks,

 

Paul

Chad
Posts:1873
river guide
river guide

05/23/2008 12:42 PM  
Hmmm... You might consider using a single SQL Completion Event and having a stored procedure setup to add/remove the user from any specific security role based on the users response.

In this case though it should be working as you have described as far as I know it. Without the 2nd event, would be user not be added to the security role associated with the 'checked box' completion event?

-Chad
Paul
Posts:34
paddling down the creek
paddling down the creek

05/23/2008 2:20 PM  

Hi Chad,

Yes, the user gets added to the security role regardless of their choice related to the completion event.  I am sure I have the configuration right.  Not sure what is going on.

 

A couple of things I thought of and tried but not sure if they're related:

1) I have the opt-in email module installed with a completion event setup on the registration page that subscribes them to our school newsletter.  Is there somewhere in the opt-in email module configuration that I could have tied this completion event to a security role?  It doesn't seem the case as I tested the registration and unchecked both completion events and the user still got added to the security role.

2) In dynamic registration's module configuration and more specfically the opt-in email settings, are the settings that you choose supposed to remain there after you update the opt-in dynamic field and update settings or do they get cleared?  Everytime I return to the settings they are back to the default.

 

Any guidance appreciated. I will continue to test.

 

Thanks,

 

Paul

Paul
Posts:34
paddling down the creek
paddling down the creek

05/25/2008 1:06 PM  

I have reduced the problem of the user getting added to the security role no matter what their response was to a corrupted security role.  I deleted the role and recreated it in dnn and now when the user checks the box, they get added properly.  If the user doesn't check the box, they are not added to the role although I do have a completion event that says if the user does not check the box, add them to another role that I have specified.  This part is still not working and I need some help if I'm going to need an SQL completion event to accomplish what I'm after which is if the user checks the box add to role A, if the user doesn't check the box add them to role B.

 

More specifically, I need an example of the code (stored proc) I would need to accomplish this.

 

Thanks,

 

Paul

Chad
Posts:1873
river guide
river guide

05/28/2008 10:25 AM  

Paul,

Hi. Ok, I see what you are saying... I actually think that you should be able to create a role completion event for both checked/not checked and add the user to seperate security roles but ill review this. In the mean time, I felt that we need a good thread related to a stored procedure which adds the user to a security role anyway so I decided to create one. This particular example is a stored procedure where you will pass it a PortalID, the UserID, the Role Name (so you don't have to have the RoleID), and the results from a checkbox. You could easily change this if you review the stored procedure (for example to pass it a value such as a combo box where the response is a specific response etc...)

So... Please follow these steps:

Step 1: Go to Host, SQL and execute this query... Go ahead and check the box that this is a SQL query.

Create Procedure {databaseOwner}[{objectQualifier}DataSprings_AddToSecurityRoleIfNotChecked]
@PortalID as Integer,
@UserID as Integer,
@RoleName as nvarchar(200),
@IsChecked as varchar(10)

AS


DECLARE @RoleID as integer

IF @IsChecked = ''
BEGIN
      Set @RoleID = (Select RoleID from {databaseOwner}[{objectQualifier}Roles] Where RoleName = @RoleName AND PortalID = @PortalID)
      Insert Into {databaseOwner}[{objectQualifier}UserRoles](UserID, RoleID, ExpiryDate, IsTrialUsed, EffectiveDate)
      Values(@UserID, @RoleID, Null, Null, Null)
END

The stored procedure has been created. You can now reference this stored procedure, passing it the portalID, UserID, role name, and value of the checkbox. Keep in mind that the value of the checkbox is simply blank (or '') if its not checked and if its checked its 'Yes'. So within the stored procedure you could change the @isChecked = '' to be @IsChecked = 'Yes' if you wanted them to be added to the security role if they checked the box. In this case though you mentioned you want them to be added if they do not check the box, so I left it at ''

Step 2: Create a SQL Event. Technically you could set the even to be fired for Any Response as you are going to pass it the value of the checkbox and if the user checked it as 'Yes' then the stored procedure is not going to do anything.
So... Lets assume that my portalID is 0 and my role name is 'Test Role One'. Lets also assume that the short field name for my checkbox is 'MyCheckBox'. If this was the case the SQL Event should look like this:

DataSprings_AddToSecurityRoleIfNotChecked 0, $(UserID), 'Test Role One', '$(MyCheckBox)'

So could technically test this without the SQL event as well if you went to Host SQL and entered something like:


DataSprings_AddToSecurityRoleIfNotChecked 0, 55, 'Test Role One', ''

The above SQL should add the user with userID 55 to the role Test Role One because it was passed ''


Or


DataSprings_AddToSecurityRoleIfNotChecked 0, 55, 'Test Role One', 'Yes'


The above SQL should not add the user with userID 55  to the role Test Role One because it was passed 'Yes'


Step 3: Test!

Ummmmmm... So you can use this stored procedure or tweak it for other users.  It wouldn't be hard to change the SQL within the stored procedure to also delete from a security role etc... You could also change the SQL to be if an if / else statement where it would maybe add them to a role if it was '' or delete them from a role if it was 'Yes' etc...


-Chad

Chad
Posts:1873
river guide
river guide

05/28/2008 10:41 AM  
Also... I thought for another example I would post a stored procedure that would both AddOrDelete based on the response. In this case we will have it add the user to a security role if they check the box, or delete it if they dont... Just to be clear again, most implementations would not require this SQL event (most could just use the Role completion event) but there are situations where you might want to conditionally run other checks, references, conditions, etc... In that case SQL event is the way to go.

So... Another example which will add the user to the role if they check a box, and not if they don't:

Create Procedure {databaseOwner}[{objectQualifier}DataSprings_AddOrDeleteFromSecurityRole]
@PortalID as Integer,
@UserID as Integer,
@RoleName as nvarchar(200),
@IsChecked as varchar(10)

AS


DECLARE @RoleID as integer

IF @IsChecked = 'Yes'
BEGIN
Set @RoleID = (Select RoleID from {databaseOwner}[{objectQualifier}Roles] Where RoleName = @RoleName AND PortalID = @PortalID)
Insert Into {databaseOwner}[{objectQualifier}UserRoles](UserID, RoleID, ExpiryDate, IsTrialUsed, EffectiveDate)
Values(@UserID, @RoleID, Null, Null, Null)
END
If @isChecked = ''
BEGIN
Set @RoleID = (Select RoleID from {databaseOwner}[{objectQualifier}Roles] Where RoleName = @RoleName AND PortalID = @PortalID)

DELETE FROM {databaseOwner}[{objectQualifier}UserRoles]
Where UserID = @UserID AND RoleID = @RoleID
END


-Chad


Paul
Posts:34
paddling down the creek
paddling down the creek

05/28/2008 2:42 PM  

Oh man...that worked like a charm!  I'm all giddy now:-)  I set the SQL completion event to any field response and set my DNN Role completion event to the checkbox field with the user response being a check.  Now when the user checks the box, they are added to the role called Parents and when they don't check the box, they are added to a role called Parents ND (No Directory).  Now I can integrate the User Directory module and only show those parents who chose to be included in the directory!

 

When I tried to accomplish this with 2 role completion events mapped to the same dynamic field, one with the box checked, the other response not checked, I never could get this result so I'm not sure what the problem was although it seems like that is the more intuitive way and should work.

 

Dynamic Registration, Opt-in Email, and the User Directory modules are 3 great products and with a little work on the configuration side, the three together have brought great value to my portal.

 

Great modules and great support.  Thanks for all your help.

 

Paul

Bamse
Posts:70
river guide
river guide

05/29/2008 5:37 AM  

I think I feature request would solve this without custom sql things, with "parent question answer condition rule”.

 

If answer in question 1 is xxxx then set this answer to yyyy

 

And this could be extended to a checkbox question like, if this question answer is “checked” then “uncheck” this question answer.

 

With this function the role add/remove role event could be set based on hidden answers where a checkbox is on/off in parent conditions.

 

"Answer condition rule" feature would be so nice...

You are not authorized to post a reply.
Forums > Product Discussion - DotNetNuke Modules > Dynamic Registration > Multiple Completion Events mapped to single Dynamic Field?



ActiveForums 3.7

Copyright 2005 - 2008 by Data Springs, Inc.
Terms Of Use | Privacy Statement