nlapiResolveURL, identifiers? - netsuite

I'm having trouble finding the identifiers for the nlapiResolveURL command. According to the dev guide, nlapiResolveURL(type, identifier, id, displayMode) and identifier is identifier {string} [required] - The primary id for this resource (recordType for RECORD, scriptId for SUITELET)
for bill payments the recordType is vendorpayment not VendPymt I have been searching in the dev guide for the list of recordTypes but I can seem to find the list of recordTypes to use for nlapiResolveURL

Check the Records Browser for a list of all Records. The page for each Record Type will display its Internal ID, which is always in all lowercase letters (e.g. "salesorder", "invoice", "journalentry").
In addition to that, when you are running SuiteScript in the context of a record (e.g. User Event or Client Script), you can use nlapiGetRecordType() to get the type's internal ID.
Edit: Just found the page title SuiteScript Supported Records in the NetSuite Help. This has a list of all record types supported by SuiteScript along with their internal IDs. There is an accompanying Web Services Supported Records if you're using the SOAP API as well.

Check SuiteScript Supported Records to check the internal id's of records that is to be used in identifier.

Make a bookmark on your browser and paste this as the link
javascript:if(nsRecordTypes==null){nsRecordTypes=nsServerCall(nsJSONProxyURL,"getRecordTypes");};console.log("nsRecordTypes");console.log(nsRecordTypes)
Then go to NetSuite and open the console (F12 in Chrome > console), and press the bookmark button.
This will show all record types in NetSuite.

Related

Search payment records information in Netsuite using Suitelet

Need to get payment data from Transaction >> Payable >> Pay single vendor form and create a data file. This has been done with an eventscript (add button), a clientscript and a Suitelet by searching currentRecord data from client script to Suitelet and generated a file. However, searching Transaction record type could not get payer payment department and cost center data as I know. So any advice and recommendation from Netsuite experts on how can get these payer data from Netsuite with the existing Transaction information on the Bill Payment form, like payment check number, entity id, transaction number, etc ?
When using the N/search module the following 3 tools are invaluable for retrieving data from netsuite transactions.
Netsuite records browser (shows all of the fields, available search filters, and joins ect.)
https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_1/script/record/vendorpayment.html
Another great tool is an extension called Netsuite Field Explorer developed by Michoel Chaikin
you can also turn on field ids in your account by navigating to Home->Set preferences->General tab->Set defaults->Show internal ids
(This will show the field id when you click on the field "What is this?" link directly on the record)
between the three you should be able to get everything you need to run a search and retrieve the data you are looking for.
Depending on your needs you can either search.create (return multiple records) or search.lookupfield(return a single record)

NetSuite: How can I get a list of custom fields using suitesql or REST?

Using the REST suiteql query endpoint or the records endpoints, is there a way to query NetSuite to get a list of custom fields?
You can use SuiteQL to list customfields.
For example to list entity custom fields:
{
"q": "SELECT * FROM CustomField where fieldtype = 'ENTITY'"
}
Use Setup -> Records Catalog to see the records you can query. It includes custom records and custom lists. ex. If you have a custom list called customlist_year then the records browser will include it and you can do a query like: SELECT * FROM customlist_year with SuiteQL.
One caveat: SuiteQL is still in development so the fieldnames and results might change with a NetSuite release. Make sure things get tested with a Release Preview account so you are ready for any changes when they hit your production account.
Using RESTWEB Services you can fetch the schemas of the objects. Below is the screen shot which gives the sample rest web service request.
enter image description here
Any specific reason to use suiteqql? With a normal RESTlet you can load a dummy record and read all field names starting with "cust".

Using Graph API to query SharePoint list items and expand user field

I'm trying to query for some SP list items, all is working fine except I can't seem to expand a custom column of type Person.
I can see the createdBy and lastModifiedBy expanded and even includes the AAD user id, which is great and also leads me to think what I want is possible!
But mine is a custom column.
I'm running this and can only seem to get the SP user list id and the user's display name...neither of which are much use.
/items?expand=fields(select=UserLookupId,User)
Ideally I'd like to get the AAD user id as per createdBy and modifiedBy field, but the email would suffice.
Otherwise the only way I can see is to query the User Information List (using the UserLookupId) to get the email?
Thanks
This appears to be correct assumption:
Otherwise the only way I can see is to query the User Information List
(using the UserLookupId) to get the email?
for non-system user fields, it is indeed a way to go, but there are some distinctions whether user field is multi-valued or single-valued.
If Approvers is a multi-valued user field, then the following query:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields($select=Approvers)
returns email and id properties along with displayName property for user field value.
While for single-valued user field only id (available via {userfield}LookupId property) and displayName properties could be requested via items endpoint, for example:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields($select=Approver,ApproverLookupId)
So, indeed User Information List needs to be utilized to request additional user properties, for example:
https://graph.microsoft.com/v1.0/sites/root/lists('User Information List')/items/{item-id}/?$expand=fields($select=Email)
where item-id corresponds to user field lookup id
This was my experience modifying the
Build Angular single-page apps with Microsoft Graph. In the examples below, I changed my id's out with the default text.
Here is
The Finished Project on thier github
In Graph Explorer, this worked. You can verify it at the Microsoft Graph Explorer.
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?expand=fields($select=id,Title)
In the app/graph.service.ts in the app, this did not work. Even though you would expect it to based on the graph explorer.
.api('/sites/{site-id}/lists/{list-id}/items?fields($select=id,Title)')
Changing the app/graph.service.ts api call worked.
.api('/sites/{site-id}/lists/{list-id}/items?')
.expand('fields($select=id,Title)')
The result looked like this:
fields: {
#odata.etag: ""d6f5b6ea-9f90-452d-98ba-e838f58d3359,1"",
Title: "IT SPECIALIST (MID)",
id: "20"
}
Here's an example site id:
some.sharepoint.com,9dk062b-2e54-4e4f-b71a-cdb74f42cc44,c6cf6b0a-cc7c-41fd-a76a-ef8f97e8a22f
Here's an example list id.
8eg8c29a-5555-4cfc-bfa4-0e907488f781
The end url won't have any {} in it.

Workaround to search Netsuite Note record by Customer id

I'm trying to get an app I'm working on to display all associated user notes for a given Customer record (as it appears on the UI Customer record page in Netsuite proper).
To that end, I've set up a Netsuite RESTlet to return a list of internal ids for associated Note records given a Customer internal id.
I've set up a simple search in the RESTlet script:
function get_notes(params) {
log("GET params", JSON.stringify(params));
var filters = [
new nlobjSearchFilter('internalid', 'customer', 'is', params.id)
];
var columns = [
new nlobjSearchColumn('internalid'),
new nlobjSearchColumn('note'),
];
var search = nlapiCreateSearch('note', filters, columns);
var notes = search.runSearch().getResults(0, 3);
return notes;
}
function log(msg, details) {
nlapiLogExecution('DEBUG', msg, details);
}
The script works as expected, but the problem is that this search ONLY returns Notes for which the author field (which is a user internal id) matches the internal id of the user performing the search. Meaning - you can only search for Notes for which you are the author.
I have been informed that this is a 'feature' of Netsuite for some unfathomable security reason.
I need to be able to get a list of all the associated Note ids, not just those for which the user making the request is the author.
Any ideas on a workaround to get at all the associated Notes? A different way to structure the search? Some kind of secret way to define your own custom Search Joins?
I can't even find documentation on this behavior (blocking Note searches from non-authors). Perhaps someone knows how to override it at the admin level?
I'm not quite ready to admit that this is impossible yet.
NB: User Note is a Note-type record associated with the Customer record, not a field on Customer record, so I can't access it directly from Customer. There is also not a Search Filter or Search Join for Note or User Note.
Using RESTlets you cannot get the notes of other users unless you invoke the RESTlet using credentials/tokens of roles like Administrator/Full Access. RESTlets always runs in the context of current user.
One alternative to do that, if you really got to achieve this any how:
1) Create a user event script on customer which creates a custom record that simulates the functionality of system notes.
2) Make sure that the RESTlet user roles have full level of access on the custom record and make customer as parent of your custom record.
3) In your RESTlet return the custom records.
Basically RESTLETS always run as the user who invokes them.
If you can use a Suitelet for this you can set that up to run as Administrator and can return any Notes you can craft a search for.
Are you actually needing a Restlet ? i.e. Are you calling this from an external application or are you trying to add functionality in the NS GUI? If the latter then you can easily use a Suitelet.

Access Netsuite Internal Id Dynamically

Searching the Netsuite documentations is like having a date with freddy krueger, not good. Wondering if anyone knows a way to access Netsuite product internal IDs dynamically? We have WSDK enabled and can populate item name, descriptions, weight, etc., but we have to manually enter the ide for every script we run on the product page we create.
<script src='http://shopping.sandbox.netsuite.com/app/site/query/getitemname.nl?c=xxxxxx&n=1&id=3706'></script>
<script src='http://shopping.sandbox.netsuite.com/app/site/query/getitemname.nl?c=xxxxxx&n=1&id=DYNAMICALLY PULL THE ID'></script>
c= is the Netsuite account number, the id= is the product internal id. We need this for every product script "getitemsdescr" "getitemweight" etc. Is there a way to access that internal id dynamically? Or do we need to manually enter them on all 200 plus product pages we are building?
Not sure how to source this from inside the shopping cart, although I know it's possible, a dev I used to work with managed to do it.
You could alternatively use a SuiteLet to fetch the product Ids based on certain item parameters, and return as a JSON object to be used on by the page JS.

Resources