I am making an app in java that uses Netsuite's SuiteTalk web services to create a report. I defined a transaction saved search in which I use as a criteria the date and I print in the results the default Transaction columns plus the Department external ID and the sum of the amount. I run the saved search via UI and I get what I am expecting, however, when I try to get the information in my java code I keep getting null results. I have tried the java versions of the following solutions:
C# NetSuite WebServices: Get value from custom field in saved search (ItemSearchAdvanced)
http://www.anyforum.in/question/web-service/netsuite/How-to-get-data-from-saved-search-through-webservice-request/345
However, none of this has worked for me. When I go to the Lists->Search->Saved Searches menu on my Netsuite UI, I am able to see my saved search when I set in the filters "General" and "Transaction". However, I haven't been able to retrieve it's information via API.
This is the code that I use to try to get the saved search data:
public void printReport() throws ExceededUsageLimitFault, UnexpectedErrorFault, InvalidSessionFault, ExceededRecordCountFault, RemoteException, UnsupportedEncodingException, SOAPException{
//METHOD 1: Transaction Search
TransactionSearchAdvanced sr = new TransactionSearchAdvanced();
//"customsearchreport" is the IF of my saved search
sr.setSavedSearchId("customsearchreport");
SearchResult res = _port.search(sr);
System.out.println(res.getTotalRecords());
//METHOD 2: Item search
ItemSearchAdvanced isa = new ItemSearchAdvanced();
isa.setSavedSearchId("customsearchreport");
SearchResult resp = _port.search(isa);
System.out.println(resp.getTotalRecords());
//METHOD 3: General saved search
GetSavedSearchRecord gssr= new GetSavedSearchRecord();
//I set the record type as "transaction" as I created a transaction saved search.
gssr.setSearchType(SearchRecordType.transaction);
GetSavedSearchResult gssre = _port.getSavedSearch(gssr);
System.out.println("Saved Search status: "+ gssre.getStatus().isIsSuccess());
RecordRefList srl = gssre.getRecordRefList();
RecordRef[] rr = srl.getRecordRef();
System.out.println("RecordRef[] size: " + rr.length);
for (int i = 0; i < rr.length; i++) {
RecordRef rref = rr[i];
System.out.println("External ID: " + rref.getExternalId());
System.out.println("Internal ID: "+ rref.getInternalId());
System.out.println("Name: "+ rref.getName());
}
}
With METHODS 1 and 2, I am not able to obtain results (I print "null"). The third method prints me 16 saved searches, however, none of the printed searches correspond to the ones I have created. When I check the saved search list through the UI, I see that there exist 21 non private saved searches and 4 have been created by me. From the 16 reports that are printed, one corresponds to a private saved search.
So, I don't get why I can't get my saved search result and what determines if a report is accessible through any method. Any help to obtain my savedSearch throough the API would be appreciated. Also, could any one explain how Netsuite determines which saved searches appear through any "get" method?
Thanks!
I solved it. The ID "customsearchreport" I was using is a UI ID. I had to use the InternalID for my report. Also, I was able to print my saved search IDs with the getSavedSearch() method by selecting the "All company members" checkbox in my the "Audience" section of my saved search.
I solved them
Before the second script, we must increase the number pages limit like this:
SearchPreferences sp = new SearchPreferences();
sp.pageSize = 1000;
_service.searchPreferences = sp;
SubsidiarySearch subsidiarySrch = new SubsidiarySearch();
SearchResult srchResult = _service.search(subsidiarySrch);
Related
While implementing the Android AutoFill functionality for my password manager, I’m unable to get the domain name for the webpage with which the user is interacting. While testing other password managers, I see they are able to get the domain, because they are able to filter responses according to the domain stored on various records. For example, if I have 3 records that have “yahoo.com” as the domain and 6 other records with different domains, when I tap into the username field on Yahoo’s sign in form, I’m only presented with the 3 records with “yahoo.com” as the domain, which is the correct functionality. In my own app, when I tap into the username field, I’m presented with all 9 records. I’m not able to get the domain needed to filter the records appropriately.
I studied the documentation in detail and used an example from Google for development.
I did not find any mention there may be any difficulties with getting the domain, but I am not able to get the data I need. Below is an example of how I am trying to get the domain name on a page.
public void onFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) {
List<FillContext> context = request.getFillContexts();
AssistStructure structure = context.get(context.size() - 1).getStructure();
ArrayMap<String, AutofillId> fields = new ArrayMap<>();
int nodes = structure.getWindowNodeCount();
for (int i = 0; i < nodes; i++) {
AssistStructure.ViewNode node = structure.getWindowNodeAt(i).getRootViewNode();
String webDomain = node.getWebDomain();
if (webDomain != null){
Log.d(TAG,"domain: " + webDomain);
}
addAutofillableFields(fields, node);
}
FillResponse response = createResponse(this, fields);
callback.onSuccess(response);
}
I have not been able to get a real webDomain value. Only null…
It works fine in the apps due there I need only packageName for identifying the app. But for browser pages I need a page domain name.
I would be grateful if someone could tell me what I did wrong. The project is posted here -
Solved. web Domain name can be retrieved only from the one of the nodes from the node tree. I thought that it should be filled for each node.
I am using the SmartyStreets API to verify valid street addresses in New York City.
I downloaded their example code file and I tried running it with a variety of different values. I tried my address, the address of Apples HQ, and even the stock address they had preloaded and nothing is working. This is the Example class and it is the shortest template of them all.
public class Example {
public static void main(String[] args) throws IOException, SmartyException {
// This keypair will have been deleted by the time you are watching this video...
String authId = "d418a4cc-69da-e48f-bc9d-ee7357b30d61";
String authToken = "clDiwTlcW5YTFjEl5mp1";
System.out.println("Step 0. Wire up the client with your keypair.");
Client client = new ClientBuilder(authId, authToken).buildUsStreetApiClient();
System.out.println("Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)");
Lookup lookup = new Lookup();
lookup.setStreet("1 Rosedale");
lookup.setLastline("Baltimore MD");
lookup.setMaxCandidates(10);
System.out.println("Step 2. Send the lookup.");
client.send(lookup);
System.out.println("Step 3. Show the resulting candidate addresses:");
int index = 0;
for (Candidate candidate : lookup.getResult()) {
System.out.printf("- %d: %s, %s\n", index, candidate.getDeliveryLine1(), candidate.getLastLine());
index++;
}
}
The message I am supposed to get after running this main method is:
Step 0. Wire up the client with your keypair.
Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)
Step 2. Send the lookup.
Step 3. Show the resulting candidate addresses:
- 0: 1 N Rosedale St, Baltimore MD 21229-3737
- 1: 1 S Rosedale St, Baltimore MD 21229-3739
But instead I am getting this and an error code:
Step 0. Wire up the client with your keypair.
Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)
Step 2. Send the lookup.
Exception in thread "main" com.smartystreets.api.exceptions.BadCredentialsException: Unauthorized: The credentials were provided incorrectly or did not match any existing, active credentials.
at com.smartystreets.api.StatusCodeSender.send(StatusCodeSender.java:21)
at com.smartystreets.api.SigningSender.send(SigningSender.java:18)
at com.smartystreets.api.URLPrefixSender.send(URLPrefixSender.java:19)
at com.smartystreets.api.RetrySender.trySend(RetrySender.java:34)
at com.smartystreets.api.RetrySender.send(RetrySender.java:23)
at com.smartystreets.api.us_street.Client.send(Client.java:48)
at com.smartystreets.api.us_street.Client.send(Client.java:27)
at examples.Example.main(Example.java:25)
Process finished with exit code 1
SOLUTION:
I received the following solution for my problem privately with whom I assume is a developer for the program.
Go to the following link
https://account.smartystreets.com/#keys
Login and scroll to the bottom of the page where it says auto-generated.
You must take the auth-id and auth-token values from here and use them to replace the dummy values in the Example class.
At this point you are able to test out whatever addresses you want in USA.
For rulings on what combinations and parts of addresses are required check this link:
https://smartystreets.com/docs/cloud/us-street-api#root
I am working on Face Recognition project using Microsoft Cognitive Services (Face API) in Xamarin application. To talk with Cognitive Services I used Xamarin.Microsoft.Cognitive.Face. Till now I am able to detect the Face by images and successfully identified the person.
Code for what I did:
var faceServiceClient = new FaceServiceRestClient("https://australiaeast.api.cognitive.microsoft.com/face/v1.0", "KEY_GOES_HERE");
var faceAttributes = new FaceServiceClientFaceAttributeType[] { FaceServiceClientFaceAttributeType.Gender, ........ };
Com.Microsoft.Projectoxford.Face.Contract.Face[] result = faceServiceClient.Detect(#params[0], true, false, faceAttributes);
var faceIds = result.Select(face => face.FaceId).ToArray();
var results = faceServiceClient.Identity(personGroupId, faceIds, 5);
In above code I do get the Face detected (by Detect()) with FaceID and Candidate (by Identity()) stored in results variable. Now, I want to use GetPerson method to get the name of identified Face, for that I need personID. when I was debugging I expanded results but I did not got any personID. Now to get the Name of identified person do we have only GetPerson()? If YES, then can you please suggest me how to get personID by posting FaceId & personGroupID?
Thank You.
Could you provide the content in the 'results'? If no person is identified, the Identify call should return an empty array. But if some person is identified, there should be faceId and confidence returned in the Candidates array. Also, you can use the Get Person Group API to check how many and which personIds are under your personGroupID
I'm using the Java API with Case Manager 5.2.1, on Windows.
My web service does the following:
// Create a brand new case
CaseType myCaseType = CaseType.fetchInstance(osRef, myCaseTypeName);
Case newPendingCase = Case.createPendingInstance(myCaseType);
// Save it now to get access to the Case ID
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
newCaseIdentifier = newPendingCase.getIdentifier();
// Fetch a fresh copy of the case instance
Case cs = Case.fetchInstanceFromIdentifier(osRef, newCaseIdentifier);
// Now set a whole bunch of properties, add documents, etc. etc.
...
// Finally, save all our updates: to "cs", not "newCaseIdentifier"
cs.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
PROBLEM: I intermittently get this error:
The object {52EECAC2-38B2-4CB5-8F22-BAF33D6C35EC} of class
"MyCaseTypeName" was not changed or deleted because it was modified
one or more times in the repository since the application retrieved
it. Update sequence number mismatch; requested USN = 0, database USN =
1
I know there are only two case.save() calls: one for "newPendingDocument", the other (much later) for "cs".
I execute the SAME code multiple times: sometimes it works, sometimes if fails with the
"Update sequence number mismatch" error.
Q: Any ideas/any suggestions as to how I can troubleshoot this problem?
Looking at the code that you provide I am confused as to why you would create a second Case instance.
I would imagine that you would be better off doing this instead:
// Create a brand new case
CaseType myCaseType = CaseType.fetchInstance(osRef, myCaseTypeName);
Case newPendingCase = Case.createPendingInstance(myCaseType);
// Save it now to get access to the Case ID
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
newCaseIdentifier = newPendingCase.getIdentifier();
// Fetch a fresh copy of the case instance (not sure if this is necessary)
newPendingCase = Case.fetchInstanceFromIdentifier(osRef, newCaseIdentifier);
// Now set a whole bunch of properties, add documents, etc. etc.
...
// Finally, save all our updates: to "newPendingCase"
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
I haven't worked with Case Manager, but have worked with P8. The api calls are very similar.
The USN number can be a little tricky. If there is any time period that you are waiting for an external call (to a 3rd party REST interface for instance) you might want to do a newPendingCase.Refresh() after the call, and then repopulate any needed properties of the case.
I'm trying to download www.pandora.com/profile/stations/olin_d_kirkland HTML with Java to match what I get when I select 'view page source' from the context menu of the webpage in Chrome.
Now, I know how to download webpage HTML source code with Java. I have done it with downloads.nl and tested it on other sites. However, Pandora is being a mystery. My ultimate goal is to parse the 'Stations' from a Pandora account.
Specifically, I would like to grab the Station names from a site such as www.pandora.com/profile/stations/olin_d_kirkland
I have attempted using the selenium library and the built in URL getter in Java, but I only get ~4700 lines of code when I should be getting 5300. Not to mention that there is no personalized data in the code, which is what I'm looking for.
I figured it was that I wasn't grabbing the JavaScript or letting the JavaScript execute first, but even though I waited for it to load in my code, I would only always get the same result.
If at all possible, I should have a method called 'grabPageSource()' that returns a String. It should return the source code when called upon.
public class PandoraStationFinder {
public static void main(String[] args) throws IOException, InterruptedException {
String s = grabPageSource();
String[] lines = s.split("\n\r");
String t;
ArrayList stations = new ArrayList();
for (int i = 0; i < lines.length; i++) {
t = lines[i].trim();
Pattern p = Pattern.compile("[\\w\\s]+");
Matcher m = p.matcher(t);
if (m.matches() ? true : false) {
Station someStation = new Station(t);
stations.add(someStation);
// System.out.println("I found a match on line " + i + ".");
// System.out.println(t);
}
}
}
public static String grabPageSource() throws IOException {
String fullTxt = "";
// Get HTML from www.pandora.com/profile/stations/olin_d_kirkland
return fullTxt;
}
}
It is irrelevant how it's done, but I'd like, in the final product, to grab a comprehensive list of ALL songs that have been liked by a user on Pandora.
The Pandora pages are heavily constructed using ajax, so many scrapers struggle. In the case you've shown above, looking at the list of stations, the page actually puts through a secondary request to:
http://www.pandora.com/content/stations?startIndex=0&webname=olin_d_kirkland
If you run your request, but point it to that URL rather than the main site, I think you will have a lot more luck with your scraping.
Similarly, to access the "likes", you want this URL:
http://www.pandora.com/content/tracklikes?likeStartIndex=0&thumbStartIndex=0&webname=olin_d_kirkland
This will pull back the liked tracks in groups of 5, but you can page through the results by increasing the 'thumbStartIndex' parameter.
Not an answer exactly, but hopefully this will get you moving in the correct direction:
Whenever I get into this sort of thing, I always fall back on an HTTP monitoring tool. I use firefox, and I really like the Live HTTP Headers extension. Check out what the headers are that are going back and forth, then tailor your http requests accordingly. As an absolute lowest level test, grab the header from a successful request, then send it to port 80 using telnet and see what comes back.