SearchExecutor (JSOM) did not retrieve values from Sharepoint online user profile - sharepoint-online

I'm trying to perform people search in SharePoint online user profile from Sharepoint hosted app but it returns no data.
I'm using the following code to do this:
clientContext = new SP.ClientContext.get_current();
// Building Keyword query for the search
var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(clientContext);
keywordQuery.set_queryText("mohammed");
keywordQuery.set_sourceId("B09A7990-05EA-4AF9-81EF-EDFAB16C4E31");
keywordQuery.set_rowLimit(500);
keywordQuery.set_trimDuplicates(false);
var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(clientContext);
results = searchExecutor.executeQuery(keywordQuery);
clientContext.executeQueryAsync(
function () {
alert(results.m_value);
},
function (err) {
alert("Error");
}
);
I'm trying to search user profile which contains "mohammed" text.
searchExecutor.executeQuery(keywordQuery) executes without any error but results.m_value returns 0. If I get value from results.m_value then I can move towards reading UserProfile properties using PeopleManager
Note: I've user as Mohammed Arief Kannubasha
Anyone please advice, thanks in advance

Try this
keywordQuery.set_queryText("mohammed*");

Related

Finding role and script deployment relations im Netsuite

Is it possible to easily see which roles have access to which script deployments?
I tried making a script deployments saved search as well as a role saved search but could not really find out how to extract this information.
Does anyone know?
I cannot see a way to complete this in the UI/via saved search. You can complete this via suitescript however by following this sort of layout. You can schedule the script to run periodically, or just run in the browser console to get the data you want. You can also add code to create an excel file to easily digest the information...
Layout in SS2.0
//gather all applicable role ids
var Roles = [];
//gather all applicable script deployment ids
var ScriptDep = [];
//for each script deployment id get the "Roles" from the "Audience" tab in the UI
for (var i=0; i<ScriptDep.length; i++){
var script = record.load({
type: 'scriptdeployment',
id: ScriptDep[i]
});
var scriptAudienceField = script.getField({
fieldId: 'audslctrole'
});
var scriptAudience = scriptAudienceField.getSelectOptions({
filter : '*',
operator : 'contains'
});
var RoleID = ; //role ID you care about, maybe loop through all roles with Roles[j]
var test = scriptAudience.includes(RoleID); //returns true or false this deployment is deployed to this role
}
Suite Answer 86327 gives the dollowing SS1.0 sample code
var search = nlapiLoadSearch('scriptdeployment', 147); //load search of all script deployments
var resultSet = search.runSearch();
resultSet.forEachResult(function(searchResult){ //for each script deployment returned by the search, get the id
var record = nlapiLoadRecord('scriptdeployment', searchResult.id); //load the script deployemnt
var arrayOfRoles = record.getFieldValues('audslctrole'); //get the values of the "Roles" from the "Audience" tab in the UI
if(arrayOfRoles == '18'){ //change based on the internal ID of the role
console.log(searchResult.id);
};
return true;
});

Get a list of users who have full control to a sub site using j query or rest api in SharePoint 2013

Is there a way you can have a list of users who have full control to a web.
There is a function called owner which gives the owner of current site collection but is there anything similar for a sub site or web.
I use a function that gives you all the permission for the user when you provide a username and web URL
function getUserRoles(webUrl,accountName)
{
return getUserEffectivePermissions(webUrl,accountName).then(function(data){
var permissions = new SP.BasePermissions();
permissions.initPropertiesFromJson(data);
var permLevels = [];
for(var permLevelName in SP.PermissionKind.prototype) {
if (SP.PermissionKind.hasOwnProperty(permLevelName)) {
var permLevel = SP.PermissionKind.parse(permLevelName);
if(permissions.has(permLevel)){
permLevels.push(permLevelName);
}
}
}
return permLevels;
});
}
use this rest api to get all users and filter the login name
_api/web/siteusers
to get the subsite use this
/_api/web/webinfos

How do I get the Active Directory Information with Sharepoint programatically on sharepoint 2013 Farm Solution On Code Behind File?

I want to Get the Active Directory names in sharepoint in a list.
To got Know that SharePoint 2013 Has some Hidden URL which Shows Current Active Directory User I wan to get it into List.
http://{YourSharepointUrl}/_catalogs/users/simple.aspx
Now I want to have list of all the names Displayed on my sharepoint
I am using the code:
private static void GetAllSiteUsers()
{
// Starting with ClientContext, the constructor requires a URL to the server running SharePoint.
var sharepointContext = new ClientContext("http://yoursharepointurl/");
}
Now I am Getting error it says about assembly reference doesn't exist.So I checked on google and added up this ddl and add the using Microsoft.SharePoint.Client; reference also.Still Not working.
Please Let me Know what needed to be done Guys
Purpose Of Making Program:To have all the AD Users and Make a work Group so that I can Assign them some right in such a way when assigned grp open something some other URL in iframe shows. and if some one else than other URL in iframe is shown to him.
Thanks IN Advance Guys.
You are in Server side (Farms solution), so don't use : ClientContext, this is for Client application, not server.
You just have to get the : User Information List
You could try somthing like :
using(SPSite site = new SPSite("URLsiteCollection")){
using(SPWeb web = site.rootWeb){
SPList userList = web.SiteUserInfoList;
SPListItemCollection allUsers = userList.Items;
foreach(SPListItem userItem in allUsers){
string userEmail = Convert.Tostring(userItem["EMail"]);
string userName = userItem.Title;
....
}
}
}
To get all information about active directory user or group you can use
PrincipalContext pContext = new PrincipalContext (ContextType.Domain, YOUR_DOMAIN);
//For User
UserPrincipal userPrincipal = new UserPrincipal (pContext);
PrincipalSearcher userSearch = new PrincipalSearcher (userPrincipal);
//For Group
GroupPrincipal grpPrincipal = new GroupPrincipal (pContext);
PrincipalSearcher grpSearch = new PrincipalSearcher (grpPrincipal);
foreach (UserPrincipal result in userSearch.FindAll())
{
if (result.SamAccountName!= null)
// Your code
}
foreach (GroupPrincipal result in grpSearch.FindAll())
{
if (result != null)
{
// Your code
}
Assembly
System.DirectoryServices.AccountManagement
Namespace
using System.DirectoryServices.AccountManagement;

Qualify Lead in MS CRM 2011

I'm newbie to CRM. I want to qualify a lead to create opportunity. I'm passing following parameters as request
CreateOpportunity
CreateAccount
CreateContact
customerid
targetentityname
targetentityid
requestname
transactioncurrencyid
statuscode
subject
fullname
lastname
companyname
createdby
campaignid
But am getting Insufficient parameter error as response.
Can anybody help me out by providing the missing parameters?
In case you need to create only opportunity from your lead it's completely enough to pass next parameters to QualifyLeadRequest:
1. CreateOpportunity
2. OpportunityCurrencyId
3. OpportunityCustomerId
4. Status
5. LeadId
Please take a look at sample code below
C#:
var rmc = new RetrieveMultipleRequest()
{
Query = new QueryExpression("organization")
{
ColumnSet = new ColumnSet("basecurrencyid")
}
};
var rmc_r = (RetrieveMultipleResponse)serviceProxy.Execute(rmc);
//Qualify lead
var qlr = new QualifyLeadRequest()
{
CreateOpportunity = true,
OpportunityCurrencyId = rmc_r.EntityCollection.Entities[0].GetAttributeValue<EntityReference>("basecurrencyid"),
OpportunityCustomerId = new EntityReference("account", new Guid(<your-existing-account-guid>)),
//3 is statuscode value "Qualified" for lead entity
Status = new OptionSetValue(3),
LeadId = new EntityReference("lead", new Guid(<your-existing-account-guid>))
};
Please take a look at SOAPLogger (SDK\SampleCode\CS\Client\SOAPLogger) tool distributed with Dynamics CRM SDK to get request XML string and send as request payload from your client extensions (JavaScript).
via

Get Current Users Group using the SP 2010 javascript Client Side Object Model

I am trying to obtain the current user's SharePoint group name that they belong to. I haven't been able to find a method/property that provides that information. I've only been able to get the current user's username. Is there a property that provides me this information that I am not seeing?
There is no direct method for returning the groups for the current user through javascript.
Here is a post to an MSDN discussion group that describes a work around to return this information.
If you want to know the group Name for checking permissions, a workaround is here.
So basically:
context = new SP.ClientContext.get_current();
web = context.get_web();
var value = web.get_effectiveBasePermissions();
If you need the Group Name, unfortunately there is no direct way to do that. But we can get the current user and get user collection for one group. Then you can check the user collection from one group to see whether it contains the current user.
Get current user: example
Get group collection for the current web: example
Get specified group
var groupCollection = clientContext.get_web().get_siteGroups();
// Get the visitors group, assuming its ID is 4.
visitorsGroup = groupCollection.getById(4);
Get users for the group
var userCollection = visitorsGroup.get_users();
Check the user collection to see whether it contains the specified user.
For a simple demo you can see the following document.
As indicated by Vadim Gremyachev here you can get the current user var currentUser = currentContext.get_web().get_currentUser() then get all the groups var allGroups = currentWeb.get_siteGroups();
From here you can loop through the group to see if your user is in the current group. So if you have a list of groups you want to check, Members, Owners, Viewers, then just use this method to detect if they are in each group.
function IsCurrentUserMemberOfGroup(groupName, OnComplete) {
var currentContext = new SP.ClientContext.get_current();
var currentWeb = currentContext.get_web();
var currentUser = currentContext.get_web().get_currentUser();
currentContext.load(currentUser);
var allGroups = currentWeb.get_siteGroups();
currentContext.load(allGroups);
var group = allGroups.getByName(groupName);
currentContext.load(group);
var groupUsers = group.get_users();
currentContext.load(groupUsers);
currentContext.executeQueryAsync(OnSuccess,OnFailure);
function OnSuccess(sender, args) {
var userInGroup = false;
var groupUserEnumerator = groupUsers.getEnumerator();
while (groupUserEnumerator.moveNext()) {
var groupUser = groupUserEnumerator.get_current();
if (groupUser.get_id() == currentUser.get_id()) {
userInGroup = true;
break;
}
}
OnComplete(userInGroup);
}
function OnFailure(sender, args) {
OnComplete(false);
}
}
// example use
window.IsCurrentUserMemberOfGroup("Members", function (isCurrentUserInGroup){
if(isCurrentUserInGroup){
console.log('yep he is');
} else {
console.log('nope he aint');
}
});

Resources