I'm developing an approval workflow in SP Designer 2007. I need a form field that will allow the user to verify that they have entered a working email address from Active Directory into a form field. (This will be the email address of the user's supervisor who grants approval - if this email address is wrong the entire process is derailed). I'm thinking it would work just like the Address Book button in an email form. Or better yet, like the Check Name button that simply checks the email address currently entered and verifies it by underlining it or some other visual cue.
Seems like an obviously useful behavior - I must be missing something - I am new to SP. Thanks!
Can you not run an LDAP query using the current users username, getting the user "Manager" field. Use that to get the managers email address.
That way the user only overrides the email address if they explicitly want someone elses.
Here is a little code to help you do an LDAP query
using System.DirectoryServices;
//DirectoryEntry de = new DirectoryEntry("LDAP://wel0101");
DirectoryEntry de = new DirectoryEntry();
DirectorySearcher deSearch = new DirectorySearcher(de);
//deSearch.PropertiesToLoad.Add("Email");
SearchResultCollection results;
deSearch.SearchScope = SearchScope.Subtree;
deSearch.Filter ="(&(objectClass=user)(cn=bacchu*))";
//deSearch.
results = deSearch.FindAll();
foreach (SearchResult result in results)
{
ResultPropertyCollection props = result.Properties;
richTextBox1.Text += "------------------------\n";
foreach (string propName in props.PropertyNames)
{
richTextBox1.Text += propName + ":\"" + props[propName][0] + "\"\n";
}
}
richTextBox1.Text += "Done" + DateTime.Now.ToString() + "\n";
Related
in a Sandbox environment nlapiSendEmail (defined inside a suitelet) returns SSS_AUTHOR_MUST_BE_EMPLOYEE even when the sender id is correct
My distribution is Kilimanjaro, with SuiteScript 1.0. I have an administrator role, when calling nlapiSenEmail() directly from the backend model with my employee id, the email was sent to my employee profile, but not to the specified email, which is really a company distribution list. Even when I did not specify the logged customer email, a copy was sent to the logged customer email, a gmail account. The backend model operates only for the MyAccount application. It's worth noting that in this scenario nlapiSendEmail() return value was undefined. In my experience, Netsuite is really ambiguous in its behavior returning values or just functioning in an expected way, due to the "execution context". So, with the same data I put my call inside a suitelet, and now I am having the return SSS_AUTHOR_MUST_BE_EMPLOYEE.
function sendEmailWithAPI(request, response)
{
var senderId = request.getParameter('senderId');
var to = request.getParameter('emailTo');
var subject = request.getParameter('subject');
var body = request.getParameter('body');
var cc = request.getParameter('emailCC');
var result = {success:false, errorInfo:''};
try
{
var sendingResult = nlapiSendEmail(senderId, to, subject, body, cc);
result.success = true;
}
catch (errorOnMailSending)
{
result.returnValue = sendingResult;
result.errorInfo = errorOnMailSending.details;
}
response.write(JSON.stringify(result));
}
What is the record type of the senderId? NetSuite only accepts Employee records as sender of script generated emails. Also in Sandbox accounts, the emails are re-routed to the logged in user, specific list, or not at all. This is actually based on the Company preference in your Sandbox account. The reason for this is Sandbox is usually used for testing and you don't want to send test emails to actual customers.
In the end the "problem" was that I was just working in the Sandbox, as I prepared a snippet to test email sending in production everything went right. In the sandbox you can still send emails specifying a list at the subtab "Email options"
with the option "SEND EMAIL TO (SEPARATE ADDRESSES WITH COMMAS)"
this is located at Setup > Company > Email Preferences.
I need to update a FieldUserValue field in sharepoint 2013. i am only given an email address data. I can't user EnsureUser since it only accepts the logonName. i used the FromUser method but it gives me an error that says "the user does not exist or is not unique"
FieldUserValue user = FieldUserValue.FromUser(email);
it worked when i tried using my email address but when i use the email addresses in my data it results in an error. how do i fix the issue?
You could resolve user by email address using Utility.ResolvePrincipal method, for example:
var result = Microsoft.SharePoint.Client.Utilities.Utility.ResolvePrincipal(ctx, ctx.Web, emailAddress,Microsoft.SharePoint.Client.Utilities.PrincipalType.User,Microsoft.SharePoint.Client.Utilities.PrincipalSource.All, null, true);
ctx.ExecuteQuery();
if (result != null)
{
var user = ctx.Web.EnsureUser(result.Value.LoginName);
ctx.Load(user);
ctx.ExecuteQuery();
}
References
Get user identity and properties in SharePoint 2013
I'm building a custom workflow where all users that are members of a specific role will receive email notifications depending on certain state changes. I've begun fleshing out e-mail templates via Sitecore items with replaceable tokens, but I'm struggling to find a way to allow the setting of the recipient role in Sitecore. I'd like to avoid having users enter a string representation of the role, so a droplink would be ideal if there were a way to populate it with the various roles defined in sitecore. Bonus points if I can filter the roles that populate the droplink.
I'm aware that users/roles/domains aren't defined as items in the content tree, so how exactly does one go about configuring this droplink?
Sitecore 6.5.
I'm not sure if there is a module for this already made, but you can use this technique: http://newguid.net/sitecore/2013/coded-field-datasources-in-sitecore/
It explains how you can use a class as data source. So you could create a class that lists all user roles.
You might want to take a look at http://sitecorejunkie.com/2012/12/28/have-a-field-day-with-custom-sitecore-fields/ which presents a multilist to allow you to select a list of users.
Also take a look at the Workflow Escaltor Module form which you can borrow the AccountSelector control which allows you to select either individual person or roles.
This is the module I previously used to do this exact thing. The following code gets all the unique email addresses of users and only for those users that have read access to the item (it was a multisite implementation, the roles were restricted to each site but the workflow was shared).
protected override List<string> GetRecipientList(WorkflowPipelineArgs args, Item workflowItem)
{
Field recipientsField = workflowItem.Fields["To"];
Error.Assert((recipientsField != null || !string.IsNullOrEmpty(recipientsField.Value)), "The 'To' field is not specified in the mail action item: " + workflowItem.Paths.FullPath);
List<string> recepients = GetEmailsForUsersAndRoles(recipientsField, args);
if (recepients.Count == 0)
Log.Info("There are no users with valid email addresses to notify for item submission: " + workflowItem.Paths.FullPath);
return recepients;
}
//Returns unique email addresses of users that correspond to the selected list of users/roles
private List<string> GetEmailsForUsersAndRoles(Field field, WorkflowPipelineArgs args)
{
List<string> emails = new List<string>();
List<User> allUsers = new List<User>();
AccountSelectorField accountSelectorField = new AccountSelectorField(field);
List<Account> selectedRoles = accountSelectorField.GetSelectedAccountsByType(AccountType.Role);
List<Account> selectedUsers = accountSelectorField.GetSelectedAccountsByType(AccountType.User);
foreach (var role in selectedRoles)
{
var users = RolesInRolesManager.GetUsersInRole(Role.FromName(role.Name), true).ToList();
if (users.Any())
allUsers.AddRange(users);
}
selectedUsers.ForEach(i => allUsers.Add(Sitecore.Security.Accounts.User.FromName(i.Name, false)));
foreach (var user in allUsers)
{
if (user == null || !args.DataItem.Security.CanRead(user)) continue; //move on if user does not have access to item
if (!emails.Contains(user.Profile.Email.ToLower()))
{
if(user.Profile.Email != null && !string.IsNullOrEmpty(user.Profile.Email.Trim()))
emails.Add(user.Profile.Email.ToLower());
else
Log.Error("No email address setup for user: " + user.Name);
}
}
return emails;
}
I am trying to Get the RecordCenterURL from Sharepoint2010,
I have created Connection to Connect RecordCenter or DocumentRepository. I used this LINK
When I try to Retrieve the OfficialFileUrl from Application, Its always return NULL value.
I have used this sample Code , Please help me for this Issue.
string URL = "http://inblr-iifw8sv03:31521";
SPSite site = new SPSite(URL);
string recordCenterUrl = string.Empty;
if (site.WebApplication.OfficialFileUrl != null)// This is Always NULL
{
recordCenterUrl = site.WebApplication.OfficialFileUrl.ToString().
Replace("_vti_bin/officialfile.asmx", string.Empty);
}
Console.WriteLine("URL Found " + recordCenterUrl);
Console.ReadLine();
Is the Send To Recordcenter showing up in the site collection when you choose "Send to" context menu on e.g. document? Please double check General Settings -> Configure Send to Connections (in Central Admin), perhaps you configured it for wrong webapplication?
In my VSTO Outlook 2007 plug-in, I am able to get the email address of a recipient which is an exchange user. But when I have the following case, it does not return me the smtp email:
Add a new Outlook Contact item (in Outlook contacts).
The email address of this Contact Item should be an email of an exchange user (any person of your organization, but that is an exchange user).
Now when I select this Outlook contact as email recipient and in item send event I cannot get the smtp address.
Below is my code:
Recipient r = mailItem.Recipients[i];
r.Resolve();
//Note, i have different conditions that check the AddressEntryUserType of recipient's
//address entry object. All other cases work fine. In this case this is
//olOutlookContactAddressEntry.
//I have tried the following:
ContactItem cont = r.AddressEntry.GetContact();
string email = cont.Email1Address;
string emailtmp = r.AddressEntry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101E") as string;
Can anyone please help me about what property I should use in this case to get smtp email?
I have found a way to use the ExchangeUser item and resolve the smtp address through that object. This post helped - Get Smtp email from ContactInfo stored in Exchange
foreach (Outlook.Recipient recipient in currentAppointment.Recipients)
{
Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
string smtpAddress;
if (exchangeUser != null)
{
smtpAddress = exchangeUser.PrimarySmtpAddress;
}
else
{
smtpAddress = recipient.Address;
}
}
If I recall correctly, there were several instances where email addresses wouldn't resolve unless you SAVED the item being sent first. You might try that. Also, are you not getting any "security violation" messages asking for permission to access the user's address book, or have you disabled/worked around all that stuff? I had lots of probs with that that ended up requiring using Redemption for outlook.