Access Netsuite Internal Id Dynamically - netsuite

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.

Related

How to get a sales order ID and set it in a Custom Record in netsuite?

I am very new to netsuite. I want to redirect a user from sales order to a custom record I created on button click, I want to get sales order ID and set it in the custom form where the user is being redirected by clicking a button the way fulfillment works in netsuite. I am using client script to redirect user when the button is clicked. Is there a way to pass the sale order id to the next form/Record?
Like this
https://i.stack.imgur.com/QghDv.png
I tried to use the saved search feature but I couldn't fully understand it. If indeed it can be done through saved search, it would be a great help if someone could guide me.
In your Client Script you can use the N/currentRecord module to retrieve the ID of the record in context. It will allow you to retrieve a reference to the CurrentRecord object, which will have an id property.
See the Help page for N/currentRecord for details.

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.

display locationquanityavailable on Netsuite Sitebuilder Site

Trying to figure out how to set the location of a multi-location Netsuite so that on the web store it only will display the quantity of that location only. Currently it displays ALL locations (sums).
I would like js in the header possibly that will set the location to one location and then when using locationquantityavailable it will grab that locations quantity and displays it.
Anyone been able to display just a locations quantity?
You can mark your locations as making their inventory available in the web store. Then the standard sitebuilder tags quantityavailable and quantityonhand will pull from those.
If that doesn't work you could manage this by various forms of scripting.
Script your inventory affecting transactions so that inventory changes from the desired locations update custom item fields.
Create a Suitelet that takes a page's item ids as a query string and returns current inventory for those items.
create a non-stored custsom item field that populates with the results of a saved search. I doubt this option will work in the context of the web store but it's very low effort to check. Search for "Creating Custom Fields with Values Derived from Summary Search Results" in the Netsuite online help for details.
I've used the first two of these in production to achieve the result you're looking for.
each of these has advantages and disadvantages so there's a trade off between how busy your back-end is vs how busy the site is.

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.

nlapiResolveURL, identifiers?

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.

Resources