Hi All, I have a custom list created via Suitelet....
# suitescript
x
Hi All, I have a custom list created via Suitelet. The last column has a button which calls a client script which brings up another suitelet to enter data. This button needs to grab the id of the record that line relates to. When I inspect the button element, it is grabbing the correct record id. But when I actually click on the button, the value passed to the client id is the last record id on the list. Any ideas what I am doing wrong? Here's the suitelet button that I am setting:
Copy code
//the add column
var linkColumn = list01.addColumn({
                    id: 'c_link',
                    type: serverWidget.FieldType.TEXT,
                    label: 'Attach Invoice',
                    align: 'CENTER'
                });

//The value I am setting on the column
stLink = '<button type="button" id="DistUploadBtn" onclick="myFuncDistUpload();">Attach Invoice</button><script>function myFuncDistUpload() {require(["/SuiteScripts/Distributor Portal/FFW_CL_Call_EKR_Page.js"], function(client) { client.uploadCustomerDoc(' + cusId +','+ stId +'); });}</script>';
b
onclick="myFuncDistUpload();"
means that your on click uses the global myFuncDistUpload function
you add one script element per row
with each overwriting the global myFuncDistUpload
last one to overwrite wins
x
ah! ok I see. I changed to:
Copy code
stLink = '<button type="button" id="DistUploadBtn" onclick=\'require(["/SuiteScripts/Distributor Portal/FFW_CL_Call_EKR_Page.js"], function(client) { client.uploadCustomerDoc(' + cusId +','+ stId +'); });\'>Attach Invoice</button>';
and now it works, thank you!