This topic contains 4 replies, has 0 voices, and was last updated by mwhite@hgyp.com 7 years ago.
-
AuthorPosts
-
November 6, 2017 at 1:33 pm #21428
kentroylanceI am having a difficult time finding any information about the best way to search custom fields for an object like Partner. Lets say I have a custom field named something like custentity_account_id, how would I search that custom field and return a partner record back. Currently, I am using something similar to this and getting "UNEXPECTED_ERROR"; which, means nothing to me.
var filters = new Array();
filters[0] = new nlobjSearchFilter('custentity_account_id', null, 'anyof', '333476');
var columns = [
new nlobjSearchColumn('internalid')
];
var partner = nlapiSearchRecord("partner", null, filters, columns);
Appreciate any help,
Kent
This is a cached copy. Click here to see the original post. -
November 6, 2017 at 1:46 pm #21429
mwhite@hgyp.comNot sure if this was psuedo-code or the real deal, but note how I defined the search column. I also used single quotes around partner.
var filters = new Array();
filters[0] = new nlobjSearchFilter('custentity_account_id', null, 'anyof', '333476');
var columns = new Array();
columns[0] = new nlobjSearchColumn('internalid');
var partner = nlapiSearchRecord('partner', null, filters, columns);
Otherwise, it should work. On a related note, I recommend referencing an existing saved if there is complicated logic or a lot of columns. If you're only getting a couple fields and you know the partner you're looking for, you might use nlapiLookupField.
-
November 6, 2017 at 2:34 pm #21430
pcutlerCheck out the page in HELP called "Search Operators." Different search operators are valid for different data types, so you may be getting this error because the custom field's data type is not compatible with the anyof operator. For instance, if the data type is numeric, then you would actually want to use the "any" operator.
kentroylance replied on 11/06/2017, 02:49 PM: I think you might be right. Thanks for the tip.
-
November 6, 2017 at 2:45 pm #21431
kentroylanceI appreciate your help, even though what you provided is nearly identical in fuctionality. Since this is java script, using single or double quotes really doesn't matter. I have other code that works with both single and double quotes. This code works, but only searching internalid. I cannot get this code to work with custom fields.
var ids = new int[] { 144110 };
var filters = new Array();
filters[0] = new nlobjSearchFilter('internalid', null, 'anyof', ids);
var columns = [
new nlobjSearchColumn('internalid')
];
partner = nlapiSearchRecord("partner", null, filters, columns);
-
November 7, 2017 at 7:06 am #21432
mwhite@hgyp.comDoes the default form for the role you're using for SuiteScript show the field in question?
-
AuthorPosts
You must be logged in to reply to this topic.