Developer forum

Forum » Development » Newsletter v3 and Extranetnet group creation

Newsletter v3 and Extranetnet group creation


Reply

 I think i found a bug in how the extranet and the newsletterv3 handles creation of groups.

If you create a Group from the Newsletterv3 interface this group will show in the extranet / user management module under the "newsletterv3 Categories"

But if you do it the other way around and create a group under "Newsletterv3 categories" in the user management module this group will not appear in the interface of Newsletterv3.

I can't seem to find the relation in any of the Newsletterv3 tables. The only difference i could find if i looked on the AccessUser of the group i created was that the one created from the Newsletter was user type 11 and the other user type 2. This is also a bit odd cause i though that the user type 11 was supposed not to be used anymore in the >7 versions of Dynamicweb.

I would like to know if this is a bug. I’m currently importing some users into the database(console app), and I want to be 100% sure that I get the relation correct in newsletterv3 so that our client can send out newsletters.

DW version is 19.1.1.0

Thanks


Replies

 
Nicolai Høeg Pedersen
Reply
We are aware of this issue - the 2 api's are not consistent. We are working on fixing that.

To create a newsletter category, create the category using Usermanagement API first, and then call NewsletterItem.SaveCategory(CategoryID, NewsLetterV3.Consts.CategoryType.Email) - that will add a record in the table NewsLetterV3NewsLetterItem which is the secret....

Or use NewsletterV3.Category add newsletter categories.
 
Reply
Oh i see now, it makes "sense" Thank you.

One other thing - I create a new Category in Newsletterv3 and related that to an extranet group. When i insert new AccessUsers and related them to this ExtranetGroup - All users in this extranetgroup, current and future users, will recive emails sent to this category - correct?

If so its not really a problem for my current situation cause them i dont need to think much about the relationship other than the AccessUserGroup.



 
Nicolai Høeg Pedersen
Reply
Yes - that is correct.
 
Reply
 Hi again.

I can't get it to work.

Group newGroup = new Group();
                newGroup.ParentID = int.Parse(languageGroupID);                
                newGroup.Name = txtname.Value;
                newGroup.Save();
 
                //Newsletter userGroup                
                Dynamicweb.NewsLetterV3.NewsletterItem.SaveCategory(newGroup.ID, Dynamicweb.NewsLetterV3.Consts.CategoryType.Email);    

I can see that the Item is created in the table, but the category it self cannot be seen from Newsletter v3. Am i doing something wrong?
 
Reply
Hi, Mikkel

Your code looks good and actually we use almost the same approach in our current fix to DW to solve that problem. Do you have your solution online to check the database?
One more idea: I post SQL statement below, used to fetch categories in NewsletterV3 module. Could you try it on your db, may be we can find the source of problem this way?

SELECT a.*, b.NewsLetterItemSubType FROM AccessUser a, NewsLetterV3NewsLetterItem b  WHERE AccessUserParentID = 256 AND a.AccessUserID=b.NewsLetterItemAccessUserID AND a.AccessUserActive=1 ORDER BY AccessUserName  ASC


 
Reply
Hi

I don't have it online right now, im working local. But i could set it up, if we cant find the problem. You query got me one step closer to the problem.

If i run your query with my "NewsletterV3Categories" ID in "WHERE AccessUserParentID = xx" I get the Categories that are created from the inferface.
 
And i know i why. When i create the group i set the parentID to "languageGroupID" - This is cause i have this structure in my extranet

Extranet --> Friends --> Denmark --> New Group.

I Want this newgroup to be part of the Group "Denmark". But i want the newgroup to be part of NewsletterGroup aswell, this is not possible, as far as i know cause u can only have one parentID and "AccessUserGroups" Dont work on AccessUsers that are groups - only on users. And if the group doesn't have the premade "NewsletterV3 Categories" ID as the parent ID, i will not show up in the inferface of Newsletterv3.

So the solution to this problem right now is to create two groups. And when u then want to insert a user u have to set AccessUSerGRoups = @extranetgroup@@newslettergrup@

//Extranet User Group creation
                Group newGroup = new Group();
                newGroup.ParentID = int.Parse(languageGroupID);               
                newGroup.Name = txtname.Value;               
                newGroup.Save();
 
                //Newsletter userGroup
                Group newNlGroup = new Group();
                newNlGroup.ParentID = 272; //MY newsletterv3 category id
                newNlGroup.Name = txtname.Value;
                newNlGroup.Save();
                Dynamicweb.NewsLetterV3.NewsletterItem.SaveCategory(newNlGroup.ID, Dynamicweb.NewsLetterV3.Consts.CategoryType.Email);


Why dont u use the table "NewsLetterV3NewsLetterCategory"?

And also please make sure if you alter/fix some of this logic please inform all your partners.

Hope this post will save other the headache.
 
Reply

 Another question related to this.

After finding out how this works i maybe came up with another solution.

Could i just use the Newsletterv3 Categories as my groups? I mean if these Categories are as other extranet groups (login to ecom etc.) And i could just remove the DB entry in "NewsLetterV3Subscription" If a user wants to unsubscribe to a newsletter, then i don't really need 2 groups?

So my question is, when sending out a newsletter how does DW figure out who should receive and not.

My guess is the Subscription entry cause if you set a user “inactive” he cannot login –and this would not make much sense if a user can’t use the ecom if the decides to unsubscribe from the newsletter. If im right, I think the “active/inactive” feature in newsletterv3 is a bit misplaced – or are there a good reason for sorting users based on this?

Can you tell me how to unsubscribe a user from newsletterv3 ? And what it exactly does in the DB..

Then i can make my decision on what road to choose.





 


 
Reply
Try this one: new NewsLetterV3.Recipient(userID).Unsibscribe(categoryID)
 
Reply
Thanks it works.

While i'm here, this might help some one else.

If you are working with newsletterv3 and creating a new user with the UserManagement API, and right after want to make a subscription, i wont work cause the userType will be set to 5 and i don't think you can change that with the API.

So something like this is needed.

 User newUser = new User(friendStoreID);             
             newUser.Name = friendName;
             newUser.UserName = friendEmail;
             newUser.Password = firendsNr;             
             newUser.PhoneMobile = friendMob;
             newUser.Email = friendEmail;
             newUser.CustomerNumber = firendsNr;
             newUser.Active = true;             
             newUser.Save();
 
             //Newsletterv3 Fix! We need to set the usertype to 15 otherwise u cant set the user to active/inactive or send them newsletters.
             Database.ExecuteNonQuery(@"UPDATE AccessUser
                                        SET AccessUserType = 15
                                        WHERE AccessUserID = "+newUser.ID+"",""); 




 
Reply
 
You can specify the user type on either the User or the Recipient, like this...

var user = new User();
user.Active = true;
user.Type = UserType.ExtranetUser; // you can set the user type here...
user.UserName = "johndoe";
user.Password = "abc";
user.Name = "John Doe";            
user.Save();
 
var recipient = new Recipient(user.ID);
recipient.RecipientType = Consts.RecipientType.User; // ... or you can set the user type here
recipient.Subscriptions.Add(new Subscription(123, Constants.MailFormat.HTML));
recipient.Save();


BR.
Morten
 
Reply
 Hi Morten,

Thanks - that is good to know. 

I have not tested it yet, but if any of these usertypes " Consts.RecipientType.User" / "ExtranetUser" end up as usertype 15 in the DB, it will work. 

Cheers




 

You must be logged in to post in the forum