Permission Access to Employee Data(Record) - netsuite

How can i get permission or access?
I'm trying to build search in NETSUITE SSP Application and I get the following error:
ERROR TITLE: "YOU_CANNOT_PERFORM_THIS_SEARCH_BECAUSE_YOU_DO_NOT_HAVE_PERMISSION_TO_ACCESS_EMPLOYEE_DATA"
I have tried: nlapiloadrecord()
Then I tried saved search method to get employee record
Search function
function getContact(sEmail) {
var aFilter = new Array();
aFilter.push(new nlobjSearchFilter('email', null, 'is', sEmail));
var aResult = nlapiSearchRecord('employee', null, aFilter, null);
}

What role are you using while executing the above script?
If you only want to view(perform search) on employee record, you can contact your admin and ask them to give access on Employee record for the said role of type View.
You can check this out for further reading on Roles and how to create/edit/update one in NetSuite.

Related

Netsuite report list field

I want to create a list field of saved reports in Netsuite Project record.
I created a saved search for the report type. but I cannot load that search in user-event script. I want to load the search and give addSelectOption of that search to the scripted field. But i get this error: UNABLE_TO_DETERMINE_RECORD_TYPE_FOR_SAVED_SEARCH_ID_1
var searchReport = search.load({
id: 'customsearch461'
}); //Reward Project Report Search
var searchRs = searchReport.run().getRange({start:0,end:1000});
for (index in searchRs)
{
var searchRecord = searchRs[index];
var InternalId = searchRecord.getValue(searchRecord.columns[0]);
addSelectOption(field,report);
}
Unfortunately the report search type is not supported by SuiteScript.

"Permission Access on Suite-let External Link"

How can I get access Suite-let externally without login into NETSUITE..
I am trying to get Employee record through suitelet but internally it is showing employee records but when I get external link it send me error message
"You do not have permission to access Employee data"
///Search for employee record////
var mySearch = search.create({
type: record.Type.EMPLOYEE,
columns: ['entityid','salutation','email','mobilephone'],
filters: [
['supervisor', 'is', 8316]
]
});
In the Script Deployment, change the value of Execute as Role to a role that has permission on Employees.

querying the System Notes in Netsuite

I have been looking for a way to pull the records in the System Notes in NetSuite. The lines below throw an 'INVALID_RCRD_TYPE' error:
var columns = new Array();
columns[0] = new nlobjSearchColumn('internalid').setSort();
var results = nlapiSearchRecord('systemnote', null, null, columns);
I wonder how to reference the System Notes as the first argument of nlapiSearchRecord API. Obviously, it's not called systemnote.
A similar question has been posted here but the System Notes has been incorrectly referenced there.
systemnotes aren't available as record type which is evident from the record browser link
However, you can still get system notes fields using join searches on any record type in NetSuite
eg:
x = nlapiSearchRecord('vendor', null, null,
[new nlobjSearchColumn('date', 'systemNotes'),
new nlobjSearchColumn('name', 'systemNotes'), // Set By
new nlobjSearchColumn('context', 'systemNotes'),
new nlobjSearchColumn('newvalue', 'systemNotes'),
new nlobjSearchColumn('oldvalue', 'systemNotes'),
])
x[0].getValue('name', 'systemNotes'); //gives the set by value
Thanks for your responses guys. I finally managed to query the System Notes using the code below. I thought I should share it in case someone else wants to accomplish the same job. I created a RESTlet in NetSuite using the below code that returns the list of merged customer records merged after a given date.
I created a new search with ID customsearch_mergedrecords and in Criteria tab, added a filter on 'System Notes: NewValue' where the description is 'starts with Merged with duplicates:' and in the Results tab, I added the columns I needed.
Note that you need to create the new search on Customer, not on System Notes. System Notes is hooked up in the search using join (the second argument in nlobjSearchFilter constructor).
function GetMergedRecordsAfter(input) {
var systemNotesSearch = nlapiLoadSearch('customer', 'customsearch_mergedrecords');
var filters = new Array();
filters.push(new nlobjSearchFilter('date', 'systemNotes', 'notbefore', input.fromdate));
systemNotesSearch.addFilters(filters);
var resultSet = systemNotesSearch.runSearch();
var searchResultJson = [];
resultSet.forEachResult(function (searchResult){
var searchColumns = resultSet.getColumns();
searchResultJson.push({
ID: searchResult.getValue(searchColumns[0]),
Name: searchResult.getValue(searchColumns[1]),
Context: searchResult.getValue(searchColumns[2]),
Date: searchResult.getValue(searchColumns[3]),
Field: searchResult.getValue(searchColumns[4]),
NewValue: searchResult.getValue(searchColumns[5]),
OldValue: searchResult.getValue(searchColumns[6]),
Record: searchResult.getValue(searchColumns[7]),
Setby: searchResult.getValue(searchColumns[8]),
Type: searchResult.getValue(searchColumns[9]),
InternalId: searchResult.getValue(searchColumns[10])
});
return true;
});
return searchResultJson;
}

RetrieveMultiple query on team security roles

I'm working on a plugin event using the Plugin Registration Tool and CRM Dynamics SDK that needs to check the security roles for the logged in user.
I've found plenty of examples and documentation on retrieval of user roles assigned specifically to the user but I also need to retrieve the security roles assigned to the teams the user is a member of.
I have the list of teams the user is a part of via a separate RetrieveMultiple query but I have been unable to find documentation on the relationship between teams and their assigned security roles.
I have the following incorrect query but as the security role to team relationship is many to many, I would assume there is a relational entity that I am missing for the query:
CrmService.RetrieveMultiple(new QueryExpression
{
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = "role",
LinkFromAttributeName = "roleid",
LinkToEntityName = "???",
LinkToAttributeName = "roleid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "teamid",
Operator = ConditionOperator.Equal,
Values = {p_team.Id}
}
}
}
}
},
EntityName = "role",
ColumnSet = new ColumnSet(true)
});
It seems like this would be a straight forward query on the team but I've turned up empty on my Google searches.
teamroles is what are you looking for.
here is complete list of N:N tables for default entities

How can I automatically assign a role to a CouchDB user?

I have the following method for registering users:
// Registration method
exports.register = function(req, res) {
var username = req.body.username,
password = req.body.password,
first = req.body.first;
last = req.body.last;
role = req.body.institution;
nano = require('nano')('http://127.0.0.1:5984');
var users = nano.use('_users');
var user = {
"_id": "org.couchdb.user:" + username,
"name": username,
"type": "user",
"roles": [],
"password": password,
"realname": first + " " + last
};
users.insert(user, function(err, body) {
if(err) {
res.send(err.reason, err.status_code);
} else {
res.send(body, 200);
}
});
};
As you can see, I have a variable called role which I would like to set in the "roles" array. Unfortunately, as you probably know, CouchDB only allows the admin to set roles. I'm okay with this, but I'm using the roles as institutions, so I'd like a registering user to be able to pick what institution they're registering under and therefore it should automatically be assigning them this role. Without hard-coding my admin credentials into this method, i.e.
nano.config.url = "http://admin:password#127.0.0.1:5984/"
How can I automatically assign a new user to their specified role as I've mentioned?
The roles array is used by CouchDB to decide database authorization. This allows you to configure access to a given database by a user's role. If the user can set their own role then somebody can give themselves access to any institution. They can even make themselves an admin, which defeats the purpose of protecting your admin password.
I'm not sure what your use-case is, but I don't think you are trying to prevent access to other institutions. Rather, I suspect you are trying to use the roles to perform some other application function (e.g. filtering out information for them to simplify what they see). Since you are wanting to perform a non-security function, I strongly suggest that you just add your own field to the users documents. You could add an institutions property to each user.
If you really want to do this, there is a way. The error you are receiving is coming from an update validation function in _design/_auth in the _users database. As an admin you can change this function.
Download the document. Open the file and search for Only _admin may edit roles to see where the test is being performed. Remove that conditional and save the document back to CouchDB.

Resources