Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Webpart: send message customize DefaultRecipient property View modes: 
User avatar
Member
Member
kimiiic - 1/9/2014 5:36:06 PM
   
Webpart: send message customize DefaultRecipient property
Hello, Kentico Support

I want to customize the send message webpart - DefaultRecipient property, which it can vary according to different userid of the URL parameters.

Can I know which way i can customize this, Macro?


Thanks
Kimi Chang

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/9/2014 7:01:16 PM
   
RE:Webpart: send message customize DefaultRecipient property
You can make a clone of it and modify it as you see fit. This is a best practice for Kentico. Modifying the base code isn't recommended which is why you clone it first. This way when you upgrade you don't have to worry about breaking base functionality.

User avatar
Member
Member
kimiiic - 1/9/2014 10:35:44 PM
   
RE:Webpart: send message customize DefaultRecipient property
Thanks FroggEye,

but what do you mean by "making a done of it and modify it as you see fit"?

I am thinking the way how to use Macro to get the recipient object dynamically by its userid which is in the URL parameter.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/10/2014 2:28:23 AM
   
RE:Webpart: send message customize DefaultRecipient property
Hi,

By cloning is meant making a copy of the web part. There is an example available here. It makes sense in case you do not want to edit the default web part - since it could be overwritten back to defaults in case of future upgrade.

Best regards,
Juraj Ondrus

User avatar
Member
Member
kimiiic - 1/12/2014 11:41:49 PM
   
RE:Webpart: send message customize DefaultRecipient property
Thanks for your reply, Juraj

I know how to make custom webpart by copying the existing one.

My question is in the SENDMESSAGE webpart:

ucSendMessage.DefaultRecipient = DefaultRecipient;

How can I change the DefaultRecipient to a dynamic User which will be decided by the userid?

Like

ucSendMessage.DefaultRecipient = getUsernamebyID(ID);

but It seems the object is not the username of the user, what object should I assign to this defaultRecipient field?

Thanks
Kimi Chang

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/13/2014 12:31:23 AM
   
RE:Webpart: send message customize DefaultRecipient property
The DefaultRecipient is a email address (string). So you could use something like
CMS.CMSHelper.CMSContext.CurrentUser.Email
This will get the current logged in users email address.

OR you can use something like this
CMS.SiteProvider.UserInfoProvider.GetUserInfo(57).Email

User avatar
Member
Member
kimiiic - 1/15/2014 7:42:51 PM
   
RE:Webpart: send message customize DefaultRecipient property
Thanks FroggEye,

But when i set the

ucSendMessage.DefaultRecipient = CMS.CMSHelper.CMSContext.CurrentUser.Email;

In the backend,

it got me no result in the recipient.

So i am not sure if the defaultRecipient field is the email field.

Thanks
Kimi Chang

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/16/2014 6:47:44 AM
   
RE:Webpart: send message customize DefaultRecipient property
That gets the current logged in user's email address. So it might be:

1). There is no one logged in then
2). The user who is logged in doesn't have an email address
3). The user who is logged in doesn't have a VALID email address
4). Your email settings are not properly set