All recordtypes work with my restlet suitescript except 'customer' recordtype - netsuite

This is my SuiteScript, pretty simple:
function getRecord(datain) {
var result = nlapiLoadRecord(datain.recordtype, datain.id);
return result;
}
All the recordtypes work as should (salesorder, returnauthorization, currency, etc), however, when i try to use 'customer' as recordtype, i get this weird HTML 500 Internal Server Error response, and i can't figure out why, it's not a script error, because all other Record Types work, and i know it's a valid Record Type, otherwise it'd return a diferent error, and i know it's not permission, because i have checked those as well.

Related

Mutator runs on update but cell data unchanged

I want to create a new field reservationAction and put into my table as a column Reservation defined as:
{title: "Reservation", field: "reservationAction", mutator: reservationMutator},
with reservationMutator as:
var reservationMutator = function(value, data, type, params, component) {
console.log(data);
if (!data.checkoutable) return null;
if (data.is_reserved) {
return "Free";
}
return "Get";
}
is_reserved and checkoutable are pre-existing fields of my data.
When the page initially loads, and table is created using ajax, the cell shows the correct string for Reservation. When is_reserved is changed server-side, I call table.updateOrAddData([newData]) (as part of websocket event-handler).
The problem:
When table.updateOrAddData([newData]) run, I can see the custom mutator get triggered
and from the console.log() line, see that the reservationAction is correctly set in the log. But the table itself is showing the old value. Other (non-mutating) columns are updated on the table as expected. Am I missing something or is this a bug?
If instead I use table.replaceData(), then both console, and table show correct value. But I would want to avoid doing this on each websocket event for performance reasons.
Version: I've tried all 5+.
Any help would be appreciated!
jsfiddle
Don't know if this is a workaround or how I'm actually supposed to do it in the first place but, doing row.reformat() seems to do what I expect. Oh well.
table.updateOrAddData([row_obj])
.then(function(rows){
rows.forEach(row => {
row.reformat();
});
});

SwiftUI, Xcode 13, Question about .filter'ing CoreData

#FetchRequest(
entity: Client.entity(),
sortDescriptors: [])
private var clients: FetchedResults<Client>
(...)
var searchResults: FetchedResults<Client> {
if searchText.isEmpty {
return clients
} else {
return clients.filter({$0.name!.contains(searchText)}) // Error here!
}
}
(...)
ForEach(searchResults, id: \.self) { client in
(...)
Error
Cannot convert return expression of type '[FetchedResults<Client>.Element]' (aka 'Array<Client>') to return type 'FetchedResults<Client>'
Hi,
I'm not sure how my logic is wrong. Could someone please tell me how to fix searchResults?
Also, is this the more efficient way to filter results or should I filter in the ForEach()? It seems pretty slow when I put the filter in ForEach()
While I know you have a code fix, and it is the correct one, I wanted to answer the question for posterity as I have run into this myself. The logic is wrong simply because your searchResults var is of type FetchedResults<Client>, but a filter returns an Array. So, the error message is telling you exactly the problem. You are trying to return an [Client] as a FetchedResults<Client> so you have a type mismatch.
You have two solutions:
You can filter in the fetch request, which is how you solved it per #Larme suggestion. This is especially helpful if you only need the filtered results in the UI and/or you have a lot of results.
You can filter when you use your fetched results. This is useful when you want your user to be able to determine what is filtered out by their own selections, but you don't know what filtering they will want ahead of time or that regardless of the filtering you are doing, you may need the whole FetchRequest later.

Can't access unique identifier for Bixby using code from docs

To access a unique identifier for Bixby, I'm trying to access the contactId field within the contact library (which is also viv.self I think?). I tried using the code snippet found in the docs here, but I'm getting some errors.
Code Snippet (Source)
text (Name) {
extends (contact.StructuredName)
}
Errors
ERROR: invalid capsule alias contact
ERROR: unknown super-type: contact.contactId
I would ultimately like to do something like this
integer (Identifier) {
extends (contact.ContactId)
}
Would appreciate any help on accessing this data!
I ended up finding another way to get a device identifier from these docs. There's also a sample capsule here.
In your corresponding JavaScript file, access the $vivContext.locale parameter to return the locale information.
module.exports.function = function accessVivContext (dummyInput, $vivContext) {
var result = "Testing Access vivContext..."
// See docs for all the properties of $vivContext
result = $vivContext.userId
return result
}
You would then need to configure your endpoints for this action like below, including making sure that you set up the proper accepted-inputs for your endpoint:
action-endpoint (AccessVivContext) {
accepted-inputs (dummyInput, $vivContext)
local-endpoint ("AccessVivContext.js")
}

Netsuite Suite Script 2.0 getSelectOptions function on record field does not exist

I am trying to get the values from the Status select field on a customer record so that I can get the proper internal id. I should note that I am trying to create a new customer and I am at the point where I need to set the entitystatus.
According to the documentation for Suite Script 2.0 there is a method called getSelectOptions() on the Field object of a record. For some reason when I try to call that method I get an error saying that it does not exist.
Below is my code for my restlet:
define([ 'N/record', 'N/search' ],
function(record, search) {
function doPost(requestBody) {
var custRec = record.create({
type : record.Type.CUSTOMER
});
var statusRec = custRec.getField({
fieldId : 'entitystatus'
});
var status = statusRec.getSelectOptions({
filter : 'CUSTOMER-Closed Won',
operator : 'is'
});
return JSON.stringify(status);
}
}
If I return statusRec as a JSON string I get back {"id":"entitystatus","label":"Status","type":"select"}
But when I call statusRec.getSelectOptions(options) it returns error code: JS_EXCEPTION error message:TypeError: Cannot find function getSelectOptions in object Field.
Can anyone tell me what I am doing wrong? Maybe there is a better way to do what I want without hard coding the internal ids.

Sailsjs Postgres NULL Raw query

I want to make sure this isn't a user error before creating a bug report
Using sails-postgresql adapter I have a query (I've dummied down for purposes of this question) that wants to handle a NULL value, but I get an error no matter how I write the query. I've tried different variations of it, but you should get the jist of what I want to do here:
parent = req.param('parent') or null
Route.query 'SELECT * FROM route WHERE parent '+(if not parent then 'is' else '=')+' $1', [parent], (err, routes)->
console.log(err, routes)
if err
return res.json(400, [error: sails.__('Database.connect'), _error: err])
res.json(routes.rows)
Some variation of the above where I'm always passing in data will always error out.
A simple fix is
parent = req.param('parent') or null
values = []
if(parent)
values.unshift(parent)
Route.query 'SELECT * FROM route WHERE parent '+(if not parent then 'is NULL' else '= $1'), values, (err, routes)->
Which is just kind of a nuisance.
Is there a better way to do that? I have to assume this raw query is making a postgres prepared statement so perhaps it's how postgres is actually handling the null. I haven't dug much into the source to see what is going on yet.

Resources