Finding role and script deployment relations im Netsuite - 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;
});

Related

Create a SharePoint Document Library with Microsoft Graph

I'm trying to create a new document library in a SharePoint Teams site using Microsoft Graph.
var docLibrary = $#"{{ ""name"": ""{listName}"", ""list"": {{ ""template"": ""documentLibrary"" }} }}";
var res = await GraphClient.QueryGraphAsyncPost($"/groups/{groupId}/sites/root/lists/", docLibrary, user);
var result = await res.Content.ReadAsStringAsync();
This is the code that I'm using, but it is returning a bad request. I can't seem to find in the documentation the correct way to create a Document Library.
You'll want to specify the displayName instead of the name. The value of name is generated by the server, and so the 400 is an error saying it cannot be written to. You should see an error response that contains the following message:
Cannot define a 'name' for a list as it is assigned by the server. Instead, provide 'displayName'
If you change your request to the following it should work:
var docLibrary = $#"{{ ""displayName"": ""{listName}"", ""list"": {{ ""template"": ""documentLibrary"" }} }}";
var res = await GraphClient.QueryGraphAsyncPost($"/groups/{groupId}/sites/root/lists", docLibrary, user);
var result = await res.Content.ReadAsStringAsync();

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

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*");

Sending email from netsuite using freemarker template engine

Can someone help me to work my task on netsuite Sending email. The email body should be generated with the freemarker template engine using nlapiCreateTemplateRenderer. I try to used the sample on the help page in netsuite but it doesnt work. Can somebody explain or give me a example on this API.
By the way i can sent email using suitelet, my problem is the email body.
Thank you.
Provided that you have your scriptable template. This should run OK.
var emailTempId = 1; // internal id of the email template
var emailTemp = nlapiLoadRecord('emailtemplate',emailTempId);
var emailSubj = emailTemp.getFieldValue('subject');
var emailBody = emailTemp.getFieldValue('content');
var records = new Object();
records['transaction'] = '1'; //internal id of Transaction
var salesOrder = nlapiLoadRecord('salesorder', 1);
var renderer = nlapiCreateTemplateRenderer();
renderer.addRecord('transaction', salesOrder );
renderer.setTemplate(emailSubj);
renderSubj = renderer.renderToString();
renderer.setTemplate(emailBody);
renderBody = renderer.renderToString();
nlapiSendEmail(-5, 'email#domain.com', renderSubj, renderBody , null, null, records);
The new Scriptable Template that is using the FreeMarker only supports Entity, Transaction, Custom Record, Case, & Project Record. Other records might work but based on Answer Id: 32621 from the SuiteAnswers those record are the ones that will be supported.

MS Dynamics CRM 2011, Get subgrid elements from other form

I am new to jscript and have problems to get all elements in a subgrid.
I tried the code from this sites,
Retrieve rows in crm2011 subgrid with JScript
https://lakshmanindian.wordpress.com/2012/05/25/retrieve-subgrid-rows-in-crm-2011-using-jscript/
but get every time the error message:
(Translated)
Error in the user defined event of the field
Field:window
Event: onload
Error: The preference "control" of a undefined or null reference can not be called.
The last code I tried:
var grid = document.getElementById("accountContactsGrid").control;
for (var rowNo = 0; rowNo<grid.getRecordsFromInnerGrid().length; rowNo++)
for (var cellNo = 0; cellNo<grid.getRecordsFromInnerGrid()[rowNo][3].cells.length; cellNo++)
alert(grid.getRecordsFromInnerGrid()[rowNo][3].cells[cellNo].outerText);
I tried it in the entity Account(Company) with the subgrid "accountContactsGrid".
My main goal would be to catch all the assigned elements in the account form and list it under the contacts form. But only if the checkbox "Eko" is activated.
This is my working code so far:
var chkEko = Xrm.Page.getAttribute("testcrm_ekonomi").getValue();
if (chkEko === true)
{
alert("Eko active: " + chkEko);
}
else
{
alert("Eko not active: " + chkEko);
}
After a time and the help of some threads I was able to get information of this grid. But now I have the problem to catch the elements.
I looked up the variable "grid" and found out that variable is an Object.
Since I don't really know the properties of the objects I tried to get it all.
But it seems, that my code doesn't work and I can not understand why.
Here is the code so far:
function subgridItemCount() {
// Get the Subgrid Control
var grid = Xrm.Page.ui.controls.get('accountContactsGrid')._control;
var keys = Object.keys(grid);
var getKeys = function(obj){
var keys = [];
for(var key in obj){
keys.push(key);
}
return keys;
}
for(var i = 0; i<keys.length; i++) {
document.write(keys[i]);
}
}
First I wanted to get the property of the object and then the propertyValue.
Or is there an other way to get all values of an object?
It seems like I am on the wrong way. This is what I try to do:
In the account/company form is an existing grid which is called Contacts. In this field are some Contacts assigned (with the button "add existing contact").
Now when I open some Contact there should be a box/grid/iframe with a list of all companies this contact is assigned too.
This list should be linked to the Companies (When i click on them CRM should open the form).
Maybe someone can give me a tip?
My plan was first to look for all companies and then to compare the assigned contacts to the opened one with some Jscript. Then the script should list all matching contacts in the contact form.
This way is not really performant since the script needs to read all companies first. But I don't know an other way...

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