Anyway to know it is stored in savedsearch or not - javascript

I'd like to search using savedsearch.
Here my code snippet goes.
var searchresults = nlapiSearchRecord('item', search_id, null, null);
search_id is defined as parameter in text field.
This is suitelet script so if you couldn't find similar search_id in savedsearch then it throws exception.
To avoid this I'd like to check if there is any similar internal id in saved searches.
For instance if there are two saved searches which ids are customsearch1, customsearch2.
If search_id is 'cust' then it throws exception and script finished with error.
It shows this in script log
'That search or mass update does not exist.'
Looking forward to hearing from you soon.
Regard

You can do a saved search of saved searches. You could take the results and use regex to determine if there is a similiar one. Use trim plus regex.

You could prevent this by changing your search_id parameter to a List/Record of Saved Searches.
Any reason why it has to be a text field?

Related

How to copy the value of a yform to an other field

In our (hybris) shop some products have a yform to summarize the parts of the product. Is there an easy way to copy the value of the sum field into an other field (automaticly) like the productquantity (no yForm)?
I guess I need javascript, but the id of the sumfield is generatad, so I don't know how to get the sum. Also my Javascript abilities are quite limited...
UPDATE:
To get the value I use this part of code:
copyYFormValueToProductQuantity : function() {
var copyText = document.querySelector('input[id*="sum"]').value
if (copyText > 0 && copyText != null)
{
//do stuff
}
console.log("Copied value: " + copyText)
},
But this line
document.querySelector('input[id*="sum"]').value
returns null. If I use it in the browserconsole, it also returns null. But after I inspected the element it works and returns the value I want to. So I guess I am missing some JS-basics here and the object isn't ready before?
Btw.: I call this function with a keydown-eventlistener.
This can most likely be done from the jsp files. There you have all the data that is needed, so you most likely need to only copy that field where you need it.
We can also help you more if you add some code examples here (what exactly is that yform?). If you struggle to find where in code is that specific yform created/added, it's always worth giving a try to search for the applied classes of the html (search the entire project and see what you find).
As I understand your question, you are saying that you want to copy the value of a yForm field named sum into a non-yForm field named productquantity, and you are asking specifically about how to access the value of a yForm field from JavaScript. If I understand this correctly, you can do so by calling the following JavaScript API:
ORBEON.xforms.Document.getValue("sum");
You can find more about this and other related API on Client-side JavaScript API.

Where is extra encoded query coming from and what does it mean?

I've the following in a SI
var serviceAsset=new GlideRecord('u_service_asset');
serviceAsset.addQuery('u_service',service_sys_id);
serviceAsset.addNotNullQuery('u_parent');
serviceAsset.query();
gs.log(serviceAsset.getEncodedQuery());
This prints the following in the logs
u_service=305baa6fdb17d0d44bb6e126059619e1^u_parent!=NULL^sys_idNotValidnull^ORsys_idNotValidnull
What does sys_idNotValidnull mean and why is it getting added as an OR condition?
I've a "Query" Business Rule on the table but that code doesn't seem to be referencing the above.
Business Rule code
(function executeRule(current, previous /*null when async*/) {
var serviceassetquery;
serviceassetquery = current.addEncodedQuery("u_sourcesystem!=Wholesale^ORu_sourcesystem=NULL");
})(current, previous);
So the
sys_idNotValidnull^ORsys_idNotValidnull
part was being added by the Business Rule. And the reason for sys_idNotValidnull presence was because the column u_sourcesystem was NOT present on the table u_service_asset
Duh! It was an invalid column after all that caused all the issue.
Assuming sys_idNotValidnull means "referred sys_id is not exist".
The easiest and best way to get an encoded query as follows:
Navigate to the table.
Build filter and run
Right-click on the bread crumb (You will see copy query option that will give proper encoded query, Please refer to the screenshot attached)
Example of copied query: "active=true^state!=10^ORstate=^sys_idISNOTEMPTY"

Adobe Acrobat - Error Iterating Over All Fields in a PDF with JavaScript

I'm having trouble iterating over all of the fields in my document to remove the tooltip. Here's my code:
var index=0;
while(index<this.numFields)
{
var nom=this.getNthFieldName(index);
var fieldName=this.getField(nom);
fieldName.userName = "";
index=index+1;
}
I'm getting an error saying fieldName is null and my script won't run. I've seen this answer already:
Iterating over all fields in a PDF form with JavaScript
I get the same error with that code too. If I manually assign a field name to fieldName using var fieldName=this.getField("field1");, it works fine.
Does anyone have any idea why this would error on me?
Edit:
I can iterate over the list and output nom to the console so I know it's grabbing the names of the fields properly. It seems to have trouble dropping that name into the this.getField(nom) statement. No idea why...
Why use while… for this?
Doing exactly the same (setting the mousetip text to a blank string) is simpler using
for (var i = 0 ; i < this.numFields ; i++) {
this.getField(this.getNthFieldName(i)).userName = "" ;
}
and that should do it.
However, unless you have a very good reason, setting the userName to the blank string is not recommended; it is needed if your form is used with assistive devices, and it is also the very nearest and simplest help item.
I figured out my issue.
When I created the form, I used the automatic field detection to create my fields for me in order to save time (there are like 250 fields on this form). The reason I needed the script in the first place was to remove the crummy tooltip names that the feature generates.
Apparently, in its infinite wisdom, the field detection feature named a handful of fields with a leading space ( something like " OF INFORMATIONrow1"). Since getNthFieldName(index) returns the fields in alphabetical order, it was returning one of these broken fields and erroring immediately because getField() doesn't like the leading space in the name.
I renamed the handful of fields and the script works like a charm.

Getting the thread id in Gmail

I'm looking for a way to figure out how to get the thread id for a particular email on Gmail, just before it is sent OR at the point where the send button is clicked.
Currently, I'm working with Javascript in order to scrape other items off the email and store them in a record which works pretty well for everything except the thread id.
The thread ID can be found after I send the email within the URL:
https://mail.google.com/mail/u/0/?shva=1#inbox/13ddda647539dcca
In this case, the thread id (if I'm right - is 13ddda647539dcca.
Any help would be appreciated.
If anyone is still interested - You can retrieve the thread id after the email is sent by observing the that appears at the top of the page. This span contains a link which has an attribute named 'param' which has the thread-id.
You could try:
var matched = window.location.hash.match(/[A-Za-z0-9]+$/);
if (matched) {
// Found alphanumeric string at end of hash
}
And you can get the value with matched[0].
window.location.hash should only grab the "#inbox/13ddda647539dcca" part. Then the regex is to match against any alphanumeric characters at the end of the string. So the fact that "inbox" is separated from the thread id by a "/" is important.
Of course, all of this depends on the reliability of Gmail keeping the URL following the same convention as it currently seems to be.

Why in the World is the UserName/Login Field Filling with Random String of Numbers and Letters?

The username/login field autofills with numbers and letters - I have checked the JavaCode, hunted the web for others experiencing the same problem but found nothing.
http://scottjaxon.com/gotchalegaldev/
sample of generated string (and I'm not trying to generate anything in the login field)
ab722fa-134c68dddcf-7d431b6-82
7639673-135df770710-11a7fb05-70
Is this coming from a conflict with the ShareThis Javascript?
Or is this a serverside error conflicting with AutoLogin.aspx?
any hints, tips or solutions are very much appreciated
SJ
Here's the problem:
There's a cookie called "__unam" being set by ShareThis.com.
In the pageLoad() function in global.js, you're looking for a cookie called "un" and using it to preset the username field.
Your cookie parsing function (getCookie(), also in global.js) is poorly written - it just checks whether the name of the desired cookie is found within the name of each cookie in document.cookie, rather than equal to:
if (key.indexOf(idStr.toLowerCase()) >= 0)
So getCookie("un") matches the __unam cookie, gets that cookie's value (which happens to be some sort of hash string), and then inserts it into the username field.
It's definitely JavaScript from somewhere. Try changing the id of the text box to something different and see if that fixes it.

Categories

Resources