NetSuite SuiteScript 1.0: Cannot save quote in RESTlet - netsuite

So I'm trying to create an estimate (quote) within NetSuite using SuiteScript 1.0.
I have been following this example provided from NetSuite's help centre:
Example 1
The following example creates an estimate with two items.
var record = nlapiCreateRecord('estimate');
record.setFieldValue('entity', 79);
record.setFieldValue('memo', 'Estimate Memo' );
record.setLineItemValue('item', 'item', 1, 21);
record.setLineItemValue('item', 'quantity', 1, 10 );
record.setLineItemValue('item', 'price', 1, 1 );
record.setLineItemValue('item', 'item', 2, 21);
record.setLineItemValue('item', 'quantity', 2, 5 );
record.setLineItemValue('item', 'price', 2, 2 );
var id = nlapiSubmitRecord(record, true);
The problem I get however is on that last line, whenever I go to try and save the record:
nlapiSubmitRecord(record, true);
I get the following error:
Module does not exist: ../Client/OFI_ActionButtonsClient.js (SYSTEM_LIBS$debugger.sys#475)
Has anyone else come across this? And know what could be causing the issue? Just for reference I am just running this script through the inbuilt script debugger in NetSuite.
Please note as well, I have tried writing this up using SuiteScript 2.0, and my issue then was that only custom fields were being saved, whereas the primary/ inbuilt fields for the quote in NetSuite had no values added at all.
Thank you

Please provide the entire code. Are you using any library scripts.

Seems you're trying to use a relative path to access a dependency library while running on the debugger
../Client/OFI_ActionButtonsClient.js
Use the full path instead
/SuiteScripts/{your path}/Client/OFI_ActionButtonsClient.js

So I managed to fix the issue. The problem was with me trying to set the customform field. So removing this line in my own code helped fix the issue, and I was able to successfully save the record:
record.setFieldValue('customform', '123' );
Initially I thought it was a problem with the save, but it seems like it was actually happening much earlier on, and only just manifested itself at the point of saving. I'm not entirely sure why that was the case, but for anyone else who might be stuck on this I thought it might be useful to know.
Thanks all.

Related

SDD Payment via Automated Action (Odoo v13)

Unfortunately Odoo has removed the automatic SSD payment from v12 to v13, which is crucial for me. Therefore I try to reproduce the behavior via an automated action and came quite far I guess.
I created an Automated Action that watches all invoices in draft and runs a python code if the invoice is set from draft to not draft. But unfortunately I get an error as soon as I try to post an invoice:
"Database fetch misses ids (('10',)) and has extra ids ((10,)), may be caused by a type incoherence in a previous request"
As far as I know this is related to type transformation, but as I am new to python & odoo, I am not sure how to transform the odoo datatypes correctly. Does anyone have a hint?
Here's the python code that should be executed:
payment = env['account.payment'].create({
'payment_method_id' : '6',
'partner_id': record.partner_id.id,
'journal_id' : '10',
'amount' : record.amount_residual
})
The ids are double checked and link to the correct entries:
payment_method_id '6' = my bank account
journal_id '10' = SDD Payment
Below please find the current domain applied to the Automated Action.
Any hints or help is much appreciated!
Many thanks.
Best regards,
Christian
CBfac
On the many2one field you have to assign the ID.
Code Correction:
payment = env['account.payment'].create({
'payment_method_id' : 6,
'partner_id': record.partner_id.id,
'journal_id' : 10,
'amount' : record.amount_residual
})
For everyone who needs automatic SDD payments in Odoo v13, here's the Automated Action that works for me (one more, thanks #Dipen Sah for your assistance):
Modell: account.move
Trigger: on update
Action: Execute python code
Domain (before update):
["&","&","&","&",["sdd_paying_mandate_id","=",False],["partner_id.sdd_mandate_ids","!=",False],["type","=","out_invoice"],["invoice_payment_state","=","not_paid"],["state","=","draft"]]
Domain (after update):
["&","&","&","&",["sdd_paying_mandate_id","=",False],["partner_id.sdd_mandate_ids","!=",False],["type","=","out_invoice"],["invoice_payment_state","=","not_paid"],["state","!=","draft"]]
Python code to execute:
payment = env['account.payment'].create({
#'name' : env['ir.sequence'].next_by_code('account.payment.customer.invoice'),
#'payment_type': 'inbound',
#'partner_type' : 'customer',
'payment_method_id' : 6,
'partner_id': record.partner_id.id,
'journal_id' : 10,
'amount' : record.amount_residual}).post()
You have to upate the journal and payment_method ids within the python code to match your IDs in order to get the action running properly.
Any improvements and/or feedback are welcome.
Best regards,
Christian

#DbLookup formula in dialog list: Server error: Entry not found in index

As usual, I am trying to populate my Dialog List field by using #-formula in it:
server:="WPRServer/Un";
dbPath:="Region/Users.nsf";
viewName:="Search_users";
#DbLookup("":"NoCache"; server:dbPath; viewName; "myKey"; 2)
But every time I am getting the error in my field:
Server error: Entry not found in index
I have tryed to use this formula to this field with another database on other server with different key names, but I am getting this error on this field again.
I have updated the views with CTRL + SHIFT + F9.
Tryed to update the current db design.
Recompiled LS and all views.
This is very strange, because I am using the similar formulas in other databases and everything is working fine every time.
Can you please give some small advise what is the way to fix this issue or maybe I am doing something incorrect? Thank you.
Update 17.09.2018:
1. The view Search_users is sorted.
2. I am using Windows server, and tryed to add **\** slashes and It helped to solve this issue, now I am getting this error:
This database is currently in use by another person or process, and cannot be accessed at this time. In order to share a Notes database, it must be accessed via a Domino Server by all users of the database.
I have tryed to reset all current accesses to this database with Domino Administrator tool, nothing helped - still getting this error in my Dialog List.
3. #DbColumn formula works fine with this view.
4. Also, already tryed to compact the database, no changes.
This may show you what the issue is:
server:="WPRServer/Un";
dbPath:="Region/Users.nsf";
viewName:="Search_users";
searchkey := "myKey";
rslt := #DbLookup("":"NoCache"; server:dbPath; viewName; searchkey; 2);
#If(#IsError(rslt); #Text(rslt) + " for:[" + searchkey + "]"; rslt);
Anticipation and handling error conditions.

Updating a many to many join table using sequelize for nodejs

I have a Products table and a Categories table. A single Product can have many Categories and a single Category can have many Products, therefore I have a ProductsCategories table to handle the many-to-many join.
In the example below, I'm trying to associate one of my products (that has an ID of 1) with 3 different categories (that have IDs of 1, 2, & 3). I know something is off in my code snippet below because I'm getting an ugly SQL error message indicating that I'm trying to insert an object into the ProductsCategories join table. I have no idea how to fix the snippet below or if I'm even on the right track here. The Sequelize documentation is pretty sparse for this kind of thing.
models.Product.find({ where: {id: 1} }).on('success', function(product) {
models.Category.findAll({where: {id: [1,2,3]}}).on('success', function(category){
product.setCategories([category]);
});
});
I'd really appreciate some help here, thanks. Also, I'm using Postgres, not sure if that matters.
models.Category.findAll returns an array. By doing setCategories([category]); you are wrapping that array in an array. Try changing it to setCategories(category); instead
I think you are close. I had a similar issue with some of my code. Try iterating over your found categories and then add them. I think this might do the trick.
models.Category.findAll({where: {id: [1,2,3]}}).on('success', function(category){
for(var i=0; i<category.length; i++){
product.setCategories([category[i]]);
}
});

Unable to pull Net Suite custom record values through Restlet : (Error: SSS_INVALID_SRCH_COL)

I'm running with a strange issue here. Haven't up fronted with any issue with Netsuite Restlet earlier while pulling the field values.But suddenly I encountered with a strange issue here. I have a custom record and it has almost 20 fields and previously my restlet was able to pull all the information correctly. And now I added one extra field but I was totally surprised, I was unable to put it in search column.
var Filters = [];
Filters[0] = new nlobjSearchFilter('custrecord_name', null, 'anyof', dataIn.gId);
Filters[1] = new nlobjSearchFilter('internalid', null, 'is', dataIn.rId);
var Columns = [];
Columns[0] = new nlobjSearchColumn('name');
Columns[1] = new nlobjSearchColumn('custrecord_name');
Columns[2] = new nlobjSearchColumn('custrecord_type');
.
.
.
.
Columns[13] = new nlobjSearchColumn('custrecord_service_name'); // getting error
var rCatResults = nlapiSearchRecord('customrecord_service_category', null, Filters, Columns);
It is throwing error.
Error: SSS_INVALID_SRCH_COL
An nlobjSearchColumn contains an invalid column, or is not in proper syntax:
However I'm well acquainted with nlobjSearchFilter and nlobjSearchColumn. I double checked with the field internal id and its working fine in debugger but I'm getting the above error while calling through rest. Does anybody have any idea why it is throwing this error ??
I encountered the exact same issue and there was no real error in the search column syntax but there seems to be a very frustrating Netsuite bug that makes the search error out when you add a new field to a custom record form while logged in as the current user. When I logged out and logged back in with the same user the search column worked perfectly fine as if there were never any error to begin with.
Check a couple of things first..
Field permissions, might be that the user running the rest request doesn't have access to that field.
Field data type, could be you are searching for something which NS doesn't know how to respond.
Syntax, maybe you put a letter in the wrong place and didn't noticed.

How can I clear an external ID on a record in NetSuite?

I need to clear/reset the external ID on a record in NetSuite, but nothing I do is working.
Some of the InventoryItem records are incorrectly mapped to records in another system. I have an application that can sync up the two systems, but I need to clear NetSuite's external IDs first.
Responses don't really need to be SOAP-specific. If you know how to do it with some specific NetSuite/SuiteTalk client, that might point me in the right direction.
What I've Tried
First up, I tried using the nullFieldList... but maybe it doesn't work because externalId is an attribute, not an element?
<messages:update>
<messages:record internalId="7777" xsi:type="accounting:InventoryItem">
<core:nullFieldList xsi:type="core:NullField">
<core:name>externalId</core:name>
</core:nullFieldList>
</messages:record>
</messages:update>
The external ID is just a string, so I tried just setting it to blank. Didn't work either.
<messages:update>
<messages:record internalId="7777" xsi:type="accounting:InventoryItem">
<accounting:externalId></accounting:externalId>
</messages:record>
</messages:update>
I even tried setting the external ID to 0, but I get back a "not unique identifier" error
<messages:update>
<messages:record internalId="7777" xsi:type="accounting:InventoryItem">
<accounting:externalId>0</accounting:externalId>
</messages:record>
</messages:update>
Other Info
I'm using NetSuite's SOAP API v.2013_1
When I say "it doesn't work", I mean: after I do the update, I get a success response similar to the following:
<readResponse>
<platformCore:status isSuccess="true" xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com"/>
<record internalId="7777" externalId="42" xsi:type="listAcct:InventoryItem" xmlns:listAcct="urn:accounting_2013_1.lists.webservices.netsuite.com">
<!-- snip -->
</record>
</readResponse>
If you are using scripts in netsuite you can run a scheduled script to clear records in NS by loading each record and setting the externalid to '' using the following simple code:
var rec= nlapiLoadRecord(type,id);
rec.setFieldValue('externalid','');
nlapiSubmitRecord(rec);
This seemed to work for me in my enviornment which was on 2015.2.
Unfortunately my understanding is that once you set an externalid you cannot clear it, you can set it to another value, but not back to null. I have experienced this both using SuiteScript as well as a Boomi process that uses the 2014.1 endpoint. This may have changed in the recent releases, as I have not tried it recently with SuiteScript nor with a newer endpoint.
You can eliminate the externalId on a record once it's been set. Here's an example using the NetSuite gem:
ns_customer = NetSuite::Records::Customer.get external_id: 'ext_id'
ns_customer.external_id = ''
ns_customer.update
Here's the corresponding XML for update:
<env:Body>
<platformMsgs:update>
<platformMsgs:record xsi:type="listRel:Customer" platformMsgs:internalId="199113" platformMsgs:externalId=""/>
</platformMsgs:update>
</env:Body>
I have had to attempt this before as well. I know the pains you describe. I ended up putting a "-" in front of my external ID to unlink it between my systems. You can do this in SOAP or even as a simple one time csv upload. As it was one time, I did csv.

Resources