Ignore NULL values from NetSuite Saved Search Calls - netsuite

I'm using PHP Toolkit 2013_2 version. Currently I run a transaction typed saved search which returns the responses from NetSuite. But, I get many data with NULL values in the response. So is it possible to either filter only specific items or ignore the NULL values through the NetSuite call itself, so that the time to retrieve response is reduced?

You can use #NONE# with your filters in NS to prevent null values. In the NS help center you can place a query for searching filter there you can find more info reading the usage.
Here is a small example :
var searchFilters= new Array();
searchFilters[0] = new nlobjSearchFilter('serviceitem', null, 'noneof', '#NONE#');
Hope this will help.

Related

querieng document which doesn't have a given field or is empty string in Solr

I am doing a query with solr where I need to find documents without a given field say 'name' and I am trying following part;
$q=+status:active -name:["" TO *]'
But it sends both all the documents with and without that field.
Can anyone help me figure this out?
the field name is a normal String type and is indexed.
I am using nodejs. Can anyone help me with this
According to docs:
-field:[* TO *] finds all documents without a value for field
Update
I tried it but it sends even the ones with the field non empty
Then my wild quess is that you are using search query q instead of using filter query fq. Since you are using multiple statements in query I assume that q does some extra magic to get the most relevant documents for you, which can lead to returning some non-wanted results.
If you want to get the strict set of results you should use filter query fq instead, see docs.

How to query for isinactive item using Netsuite REST API

I have what must be a simple question, but I've scoured the documentation and web and can't seem to find an answer.
Is there a way to query on isinactive when querying for items via the Netsuite API?
In my RESTlet when I try to specify "isinactive" with new nlobjSearchColumn() I get an error saying "undefined".
When I add a filter via new nlobjSearchFilter('isinactive', null, 'is', 0) it doesn't give me an error, it simply ignores the condition.
All I really want to accomplish is to query for active records only along with all of my other search criteria.

Alfresco webscript (js) and pagination

I have a question about the good way to use pagination with Alfresco.
I know the documentation (https://wiki.alfresco.com/wiki/4.0_JavaScript_API#Search_API)
and I use with success the query part.
I mean by that that I use the parameters maxItems and skipCount and they work the way I want.
This is an example of a query that I am doing :
var paging =
{
maxItems: 100,
skipCount: 0
};
var def =
{
query: "cm:name:test*"
page: paging
};
var results = search.query(def);
The problem is that, if I get the number of results I want (100 for example), I don't know how to get the maxResults of my query (I mean the total amount of result that Alfresco can give me with this query).
And I need this to :
know if there are more results
know how many pages of results are lasting
I'm using a workaround for the first need : I'm doing a query for (maxItems+1), and showing only maxItems. If I have maxItems+1, I know that there are more results. But this doesn't give me the total amount of result.
Do you have any idea ?
With the javascript search object you can't know if there are more items. This javascript object is backed by the class org.alfresco.repo.jscript.Search.java. As you can see the query method only returns the query results without any extra information. Compare it with org.alfresco.repo.links.LinkServiceImpl which gives you results wrapped in PagingResults.
So, as javacript search object doesn't provide hasMoreItems info, you need to perform some workaround, for instance first query without limits to know the total, and then apply pagination as desired.
You can find how many objects have been found by your query simply calling
results.length
paying attention to the fact that usually queries have a configured maximum result set of 1000 entries to save resources.
You can change this value by editing the <alfresco>/tomcat/webapps/alfresco/WEB_INF/classes/alfresco/repository.properties file.
So, but is an alternative to your solution, you can launch a query with no constraints and obtain the real value or the max results configured.
Then you can use this value to devise how many pages are available basing you calculation on the number of results for page.
Then dinamically pass the number of the current page to the builder of your query def and the results variable will contain the corresponding chunk of data.
In this SO post you can find more information about pagination.

What is the internal id(name/number) for a saved search record type?

I created a savedSearch for a savedSearch itself via UI with an internal id customsearch_savedsearch.
When I'm loading the search using a suiteScript. It shows me an Unexpected error has occured.
var search = nlapiLoadSearch(null, 'customsearch_savedsearch');
The above statement works fine for all other record-types, But fails for a savedSearch record type.
What could be the internal id for the savedSearch record type?
You cannot use null for the first parameter. When loading or creating a search, you must specify the record type for the search as well. Whatever record type customsearch_savedsearch searches for, that's what you would pass in as the first parameter.
So for instance if your saved search is a Customer search, then you would load it by:
var search = nlapiLoadSearch('customer', 'customsearch_savedsearch');
Try
var search = nlapiSearchRecord(null, 'customsearch_savedsearch');
Documentation:
nlapiSearchRecord(type, id, filters, columns)
Performs a search using a set of criteria (your search filters) and columns (the results). Alternatively, you can use this API to execute an existing saved search. Results are limited to 1000 rows. Also note that in search/lookup operations, long text fields are truncated at 4,000 characters. Usage metering allowed for nlapiSearchRecord is 10 units.
This API is supported in client, user event, scheduled, portlet, and Suitelet scripts.
If `
var search = nlapiSearchRecord(null, 'customsearch_savedsearch');
does not work`use
var search = nlapiSearchRecord('', 'customsearch_savedsearch');
Everything looks correct in your statement. I think the problem is that SuiteScript does not support SavedSearch record types. Here is a list of supported types.
You should be able to run this using the above mentioned
var search = nlapiSearchRecord(null, 'customsearch_savedsearch',null,null);
I've used this in my code and haven't had any issues. Make sure you have the right permissions set on the saved search. To start with, set it as Public. And in the Audience, "select all" roles.
Your syntax is correct. However, Saved Search type (also like Budget record) is not scriptable even you are able to create a saved search. That is why you encountered that error. Most likely, those record types listed on the SuiteScript Record Browser are supported. You may check the list here:
***Note: You should log in first to the account..
Production: https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/account.html
Sandbox: https://system.sandbox.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/account.html
I know this is a bit of an old question, and I came across it in my own attempt to do the same, but I just tried the following with success:
var search = nlapiLoadSearch('savedsearch', 'customsearch_savedsearch');
Seemed a little on the nose, but it did the trick.

SharePoint returns extra system columns

I do query to SherePoint. I have created query, viewquery and query options.
Web services returns me great results, but it include some other system columns such as:
ows_Modified , ows_DocIcon, ows_Editor. I don't want them. How do I return only those which is in ViewQuery string?
My queryoptions is:
#"<QueryOptions>
<IncludeMandatoryColumns>False</IncludeMandatoryColumns><ViewAttributes Scope='Recursive' />
</QueryOptions>";
Thanks!
In order to return only selected columns (and not all of them) use ViewFields property of SPQuery object. You can find some more information about it and a sample code here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewfields.aspx.
In order to do it from javascript, you can try code as written here (that post is on another topic, but it still shows how to specify fields to select): https://sharepoint.stackexchange.com/questions/33683/spservices-today-not-returning-correct-results.

Resources