What I am trying to accomplish is to get item information from the internal ID passed to getAttribute but I am getting the following error.
Error processing dynamic tag getAttribute('item',362,'storedisplayname') : id paramter 2 must be an integer
Here is a sample of the code:
var itemIntId = 362;
var id = "<%=getAttribute('item',"+itemIntId+",'storedisplayname')%>";
console.log("ID: " + id);
Doing the following does not seem to change anything as it still gives me the same error
var id = "<%=declareAttribute('item',"+itemIntId+",'storedisplayname')%>";
console.log("ID: " + id);
This is in a presentation tab page and found the following info in the Netsuite help section
getAttribute tag on Presentation tab throws error Sometimes using the
getAttribute() tag in a Presentation tab can throw error %u2018Error
processing dynamic tag getAttribute('item',9047,'storeurl') %u2018. In
that case you have to use declareAttribute() to display the embedded
tag on your Presentation tab. On the Presentation tab > Meta Tag HTML
area, just add:
<%=declareAttribute('item',9047,'storeurl')%>
but did not seem to help
I'm sure I am just missing something simple but have been bashing my head against my desk for a few hours now trying to figure this out and
Well after talking with Netsuite support and going back and forth on the code it seems that the getAttribute or declareAttribute can not take a dynamic variable from JavaScript. Not sure why as its still an int but I guess it is what it is.
Related
I am making a Tags System on my Discord Bot with Discord.JS. Basically with Tags, you start by adding a tag with the name and content. Once added, running the tag command will return the content of the Tag. Theres other Tag Commands such as Tag Info (To get Tag Info), Tag list, edit tag etc.
I am experiencing issues with my Add Tag Command. Basically, what I am trying to do is add a line of code which is to check if the Tag Name already Exists. However, whenever I run the Add Command 2nd time or more with the same Tag Name, it will just override the name.
I've tried with this line of code:
let tags = await db.fetch(`tags_${message.guild.id}-${name}.name`)
if(!tags) return message.channel.send(`**Tags |** **Tag Exists!**`)
This should return a message response if the same Tag Name exists in the Guild But it is not working as expected.
For other Tag Commands I have, they kept getting Cannot read property 'content' of null error but I've somewhat resolved this with this snippet of code that uses the Try and Catch Statements.
} catch (e){
if (e.message === "Cannot read property 'content' of null")
return message.channel.send(`**Tag Not Found**`)
The Tags System uses Quick.DB for Database storing. It wasn't easy to get this all working right. I have an API Debug JSON Link that i've used to try and diagnose the problems. https://nate-devbot.glitch.me/api/coinslb
Please only look at JSON Formats like this:
The other data entries are old and were resolved earlier.
The full code to AddTag.JS: https://hastebin.com/neqasomisa.js
I'm using diffbot to scrape products. It gets things right on most sites, and if it doesn't the custom API usually allows me to easily tweak until correct. However there are a few cases that are baffling me.
I know diffbot doesn't execute javascript in the custom API preview window, but for the product endpoint, it should always execute it when a request is made to the API (e.g. from the diffbot client in a Python shell).
Foot asylum
For products on this website, e.g. https://www.footasylum.com/hugo-boss-three-pack-tshirt-103678/, the offerPrice field is empty. I can see the price is in a div#priceFrm, so I try to edit and add a custom selector on that field to this effect. However even when making a new API call from the Python shell, the response is 'offerPrice': ''.
This price is obviously being added by Javascript, but why can't diffbot deal with that? What can I do about it?
I can also see the price I want can be found in some JSON data inside a <script>. Normally I could just scrape it from there, with //script[contains(text(), "dataLayer")]/text() followed by a regex. However in another diffbot custom field I defined a selector script:contains(dataLayer) and even this is blank.
Any ideas on getting the price from this product with diffbot?
Nike
I'm also trying to get the price from https://www.nike.com/gb/t/flyknit-trainer-shoe-GBXjsV/AH8396-600
The first problem is the preview window of custom API just gives a 500 error weirdly.
Next I edit the offerPrice field with a custom selector of div[data-test=product-price], however this field doesn't hit anything - even when called from client in Python shell.
Footlocker
Finally on this site https://www.footlocker.co.uk/en/p/jordan-1-flight-2-men-shoes-6671?v=314100340604#!searchCategory=all diffbot cannot seem to get product image.
The images are loaded by "scene7", and with XPATH can be found with //div[#class="s7thumb"][#data-namespace="s7classic"]/#style and then parsing out the "background-url".
I tried to at least get the style attribute with diffbot using the selector div.s7thumb div[data-namespace=s7classic] and then adding the Attribute filter "style", but again nothing at all is returned.
In some cases, specific rendering of certain elements will be blocked either by Diffbot's renderer or by a target site's anti-block measures. That's why Diffbot has X-eval functionality which lets you add custom JavaScript into calls which will get executed on a target site, as if running from the console. In this case, something like the following helps:
function() {
start();
setTimeout(function() {
price = document.querySelector("[itemprop="
Offers "] [itemprop="
price "]");
currency = document.querySelector("[itemprop="
Offers "] [itemprop="
priceCurrency "]").getAttribute("content");
price.parentElement.setAttribute("style", "");
price.parentElement.innerHTML += '<h1 class="thePrice">' + price.innerText + " " + currency + '</h1>';
setTimeout(function() {
end();
}, 500);
}, 500);
}
This has been applied as a fix and the price returns now.
Wonder if anyone can help as im really stuck on a problem i'm having
Using vb.net I have a web application with several .aspx pages.
on one of my aspx pages I have a javascript function that i want to retrieve a pdf path from a session value i set within code behind. After searching the web everywhere seems to say use something like the following
var pdf_link = '<%=Session["pdfpath"].ToString() %>';
here is the javascript function:
function showmodal() {
var pdf_link = '<%=Session["pdfpath"].ToString() %>';
var iframe = '<div class="iframe-container"><iframe src="' + pdf_link + '"></iframe></div>'
$.createModal({
title: 'PDF Preview',
message: iframe,
closeButton: true,
scrollable: false
});
}
to get the value but i get an error message before i can even compile 'Identifier Expected' and it highlights between the [" as being the problem area. i just can't get this to work what am i doing wrong.
Also because i couldn't workout what was wrong with the above i have tried saving the value i want into a hidden field and tried to access that using the following
document.getElementById("PdfPathHiddenField").value
but that just returns null all the time. I just can't seem to access anything within my javascript function.
What i also see as odd is for instance when debugging i have say page1.aspx and page2.aspx. From page1.aspx in code behind on a button click i use
Response.Redirect("~/page2.aspx")
When I have stopped the debugger within my javascript function on page2.aspx to retrieve the value i notice that the tab with the code where the debugger has stopped for page2.aspx is titled page1[Dynamic] but it is the correct source from page2.aspx not page1.aspx really confused as shouldn't it say page2[Dynamic] on that - is this why i maybe can't seem to access any controls as it thinks it's elsewhere ???? Help
Thanks in advance any help would be much appreciated.
In VB.NET arrays have parentessis, Session("pdfpath").ToString(), in C# or javascript you can use square brackets, but not in VB.
PS: Remeber to mark this an answer if it's a solution for your problem
The javascript code below works perfectly in the HTML of my site. It is a geo-target server that shows the city based on the user's IP.
<script src='http://promos.fling.com/geo/txt/location.php?testip='></script>
What I am doing is and I can not get it to work within a link I want to be generated according to the person's city. Example:
New York
I tried to work the way down but the response to the end of the URL after ?Q= is the code itself. I tried this:
New York
I have no experience with this, so any solution either in PHP or javascript would be welcome. I thank you!
In Jquery this is quite easy:
function cityUrl( ){
var url = "http://www.example.net/?q=";
var city;
$.get("http://promos.fling.com/geo/txt/location.php?testip=", function(data){
url += data;
city = data
}
var html = "<a href='" + url + "'>"+city+"</a>";
$( "div" ).append( html );
}
This generates a url based on the location, makes a link out of that url and sets the city as the clickable part of the link. Then this will be appended to the element specified (in this case div)
This might need some tweeking for your purposes but im sure you get the idea
I believe I was too much unclear about everything so I`ll try to clarify:
This is a function you need to call once for the page you want to show them on. Of course you cannot copy and paste this code and expect it to work.
Fiddle doesnt 100% work due to https and cross origin requests, but does reflect the idea
I'm trying to make a field similar to the facebook share box where you can enter a url and it gives you data about the page, title, pictures, etc. I have set up a server side service to get the html from the page as a string and am trying to just get the page title. I tried this:
function getLinkData(link) {
link = '/Home/GetStringFromURL?url=' + link;
$.ajax({
url: link,
success: function (data) {
$('#result').html($(data).find('title').html());
$('#result').fadeIn('slow');
}
});
}
which doesn't work, however the following does:
$(data).appendTo('#result')
var title = $('#result').find('title').html();
$('#result').html(title);
$('#result').fadeIn('slow');
but I don't want to write all the HTML to the page as in some case it redirects and does all sorts of nasty things. Any ideas?
Thanks
Ben
Try using filter rather than find:
$('#result').html($(data).filter('title').html());
To do this with jQuery, .filter is what you need (as lonesomeday pointed out):
$("#result").text($(data).filter("title").text());
However do not insert the HTML of the foreign document into your page. This will leave your site open to XSS attacks.
As has been pointed out, this depends on the browser's innerHTML implementation, so it does not work consistently.
Even better is to do all the relevant HTML processing on the server. Sending only the relevant information to your JS will make the client code vastly simpler and faster. You can whitelist safe/desired tags/attributes without ever worrying about dangerous ish getting sent to your users. Processing the HTML on the server will not slow down your site. Your language already has excellent HTML parsers, why not use them?.
When you place an entire HTML document into a jQuery object, all but the content of the <body> gets stripped away.
If all you need is the content of the <title>, you could try a simple regex:
var title = /<title>([^<]+)<\/title>/.exec(dat)[ 1 ];
alert(title);
Or using .split():
var title = dat.split( '<title>' )[1].split( '</title>' )[0];
alert(title);
The alternative is to look for the title yourself. Fortunately, unlike most parse your own html questions, finding the title is very easy because it doesn;t allow any nested elements. Look in the string for something like <title>(.*)</title> and you should be set.
(yes yes yes I know never use regex on html, but this is an exceptionally simple case)