Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Update your Profile with your Support type to get your Support Type badge.
Don't miss out on our Pop Quiz You only have until April 22, 2025, 2:00 PM ET to comment your answers and earn rewards! Click here for more details.
Expand your NetSuite knowledge by joining our Ask A Guru Live sessions. RSVP on this event now.
Make Your Voice Heard: What Tech & ERP Topics Should We Explore in our Next Webinar?? We’re all ears! Vote now, and the poll runs until January. Poll for ERP | Poll for Tech.
Uncover the power of data with the Analytics Hub —your ultimate guide to mastering NetSuite Saved Searches and Reports. Simplify the complex and unlock your organization's true potential. Dive into the Analytics Hub now and soar to new heights!
Executing JS on a PDP via Extension
DHello Everyone,
I was able to successfully add a piece of JS to the site globally and successfully works.
I am reading through the articles presented on my post, and I am having trouble deploying some JS to the PDP.
My JS is embedded on the PDP and uses the model custom fields to pull and manipulate the page.
On my extension's module JS, I changed the layout from 'layout' to PDP and added my script. Is this the proper way to execute this script?
define( 'FAS.PDPJS.PDPm' , [ 'FAS.PDPJS.PDPm.View' ] , function ( PDPmView ) { 'use strict'; return { mountToApp: function mountToApp (container) { // using the 'Layout' component we add a new child view inside the 'Header' existing view // (there will be a DOM element with the HTML attribute data-view="Header.Logo") // more documentation of the Extensibility API in // https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html /** @type {LayoutComponent} */ var layout = container.getComponent('PDP'); if(layout) { // console.log('PDP JS ACTIVE, PDPJS.PDPm'); //PDP JS var ItemType="{{model.item.itemtype}}",NonInvtPartval="{{pageHeader}}",sparepart="{{model.item.custitem303}}",Accessory="{{model.item.custitem491}}",SeriesComp="{{model.item.custitem40}}",brand="Service"===ItemType?"FAS":"{{model.item.manufacturer}}";brand="/img/manufacturers/"+(brand=(brand=brand.replace(/\W+(?!$)/g,"-")).replace(/\W$/,""))+".png",$(".brand img").attr("src",brand),"NonInvtPart"===ItemType&&($(".reviewsdiv").addClass("d-none"),$(".ratingdiv").addClass("d-none"),$(".skudiv").addClass("d-none"),$(".ddesc h2").html("{{pageHeader}}")),"NonInvtPart"!==ItemType&&"Service"!=ItemType||($("#pdp .hdr-sect h1").attr("content",NonInvtPartval).html(NonInvtPartval),$("#skuu_{{model.item.internalid}}").text(NonInvtPartval),$(".product-detail-to-quote-add-to-quote").remove()),"InvtPart"===ItemType&&"false"===sparepart&&$(".flexwarranty").removeClass("d-none"),46<$("#pdp .hdr-sect h1").text().length&&$("#pdp .hdr-sect h1").css("font-size","2em"),71<$("#pdp .hdr-sect h1").text().length&&$("#pdp .hdr-sect h1").css("font-size","1.5em"),92<$("#pdp .hdr-sect h1").text().length&&$("#pdp .hdr-sect h1").css("font-size","1.25em"),120<$("#pdp .hdr-sect h1").text().length&&$("#pdp .hdr-sect h1").css("font-size","100%"),$(function(){var t=$(".t360").height(),d=$(".t360").width(),e=$(".imgdiv").height(),i=$(".imgdiv").width();t<e&&($(".t360").height(e),$(".t360").width(i)),e<t&&($(".imgdiv").height(t),$(".imgdiv").width(d))}),$(".btn-360").click(function(){$(".imgdiv").toggleClass("d-none"),$(".threesix").toggleClass("d-none"),$(".btn-360").toggleClass("btn-360s")}),$(".btn-close").click(function(){$(".imgdiv").toggleClass("d-none"),$(".threesix").toggleClass("d-none"),$(".btn-360").toggleClass("btn-360s")}),$(".fdbk").click(function(){var t="";"sb.flexibleassembly.com"===window.location.hostname&&(t="https://IDFF-sb1.extforms.netsuite.com/app/site/crm/externalcasepage.nl?compid=I&formid=31&h=AAFdikaIbjmuWO61YDfCUN_16y4LeP5Hmthq8dCYwriIrB5js8Q"),"www.flexibleassembly.com"===window.location.hostname&&(t="https://I.extforms.netsuite.com/app/site/crm/externalcasepage.nl?compid=ID&formid=31&h=AAFdikaIflDGyjiCb_4gxq4sOmWaZl3bw04UPELDY3UxdXhZtwk"),window.open(t,"Feedback Form","height=1140,width=600")});var vid0="{{model.item.custitemfeaturedvidsnippet}}",vid1="{{model.item.custitemvidtab1}}",vid2="{{model.item.custitemvidtab2}}",vid3="{{model.item.custitemvidtab3}}",vid4="{{model.item.custitemvidtab4}}",vid5="{{model.item.custitemvidtab5}}",vid6="{{model.item.custitemvidtab6}}";""===vid0&&(vid0=vid1),""===vid1&&(vid1=vid2),""===vid2&&(vid2=vid3),""===vid3&&(vid3=vid4),""===vid4&&(vid4=vid5),""===vid5&&(vid5=vid6),""==vid0&&""==vid1&&""==vid2&&""==vid3&&""==vid4&&""==vid5&&""==vid6&&$(".videos").addClass("d-none"),$(".vid0").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid0)}),$(".vid1").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid1)}),$(".vid2").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid2)}),$(".vid3").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid3)}),$(".vid4").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid4)}),$(".vid5").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid5)}),$(".vid6").click(function(){$(".ftvid iframe").attr("src","https://www.youtube.com/embed/"+vid6)});var numTdocs=$(".tdoc").length;numTdocs<1&&$(".tdocrq").removeClass("d-none");var techdoc1="{{model.item.custitem116}}",fndr1=techdoc1.indexOf("(")+1,fndr1=techdoc1.slice(fndr1,-1),techdoc2="{{model.item.custitem118}}",fndr2=techdoc2.indexOf("(")+1,fndr2=techdoc2.slice(fndr2,-1),techdoc3="{{model.item.custitem120}}",fndr3=techdoc3.indexOf("(")+1,fndr3=techdoc3.slice(fndr3,-1),techdoc4="{{model.item.custitem122}}",fndr4=techdoc4.indexOf("(")+1,fndr4=techdoc4.slice(fndr4,-1),techdoc5="{{model.item.custitem124}}",fndr5=techdoc5.indexOf("(")+1,fndr5=techdoc5.slice(fndr5,-1),techdoc6="{{model.item.custitem126}}",fndr6=techdoc6.indexOf("(")+1,fndr6=techdoc6.slice(fndr6,-1),pdfimg="/img/file-pdf.png",zipimg="/img/file-zip.png",genimg="/img/file-tech-doc.png";$(document).ready(function(){"PDF"===fndr1&&$(".tdoc1 a img").attr("src",pdfimg),"ZIP"===fndr1&&$(".tdoc1 a img").attr("src",zipimg),"PDF"!=fndr1&&"ZIP"!=fndr1&&$(".tdoc1 a img").attr("src",genimg),"PDF"===fndr2&&$(".tdoc2 a
0