Aly
11/24/2024, 4:29 PMCeligo AI
11/24/2024, 4:29 PMAI generated answer (using internal Slack threads):Based on the conversations, you can define an if statement to ensure that only a button being pressed on the record which calls is a suitelet is a certain id, then run the Suitelet, otherwise don't. Here is a snippet of code in SuiteScript 2.0:
javascript
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define(['N/currentRecord', 'N/url'], function(currentRecord, url) {
function pageInit(scriptContext) {
var currentRec = scriptContext.currentRecord;
var button = currentRec.getField({ fieldId: 'custpage_mybutton' });
if (button) {
button.isDisabled = false;
} else {
button.isDisabled = true;
}
}
function onButtonClick() {
var currentRec = currentRecord.get();
var button = currentRec.getField({ fieldId: 'custpage_mybutton' });
if (button && !button.isDisabled) {
var suiteletUrl = url.resolveScript({
scriptId: 'customscript_my_suitelet',
deploymentId: 'customdeploy_my_suitelet',
params: {
'custparam_record_id': currentRec.id
}
});
window.location = suiteletUrl;
}
}
return {
pageInit: pageInit,
onButtonClick: onButtonClick
};
});
In this code, pageInit
function is used to enable or disable the button based on its presence. The onButtonClick
function is triggered when the button is clicked. If the button is enabled, it redirects to the Suitelet URL.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
11/24/2024, 4:29 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836352885
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83319068
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831146955
Celigo AI
11/24/2024, 4:29 PM