Imran Hasan
10/22/2024, 8:42 AMCeligo AI
10/22/2024, 8:42 AMAI generated answer (using internal Slack threads):Based on the conversations, you can add a button in a transaction form using a User Event script and then use a Client Script to handle the button click event. Here's a step-by-step guide: 1. In your User Event script, use the
beforeLoad
function to add a button to your form. Here's a sample code snippet:
javascript
function beforeLoad(context) {
if (context.type !== context.UserEventType.CREATE)
return;
var form = context.form;
form.addButton({
id: 'custpage_save',
label: 'Save and Edit',
functionName: 'saveAndEdit'
});
form.clientScriptModulePath = './Client_Script.js';
}
In this code, a button with the label 'Save and Edit' is added to the form. The functionName
is set to 'saveAndEdit', which is a function that will be defined in the Client Script.
2. In your Client Script, define the saveAndEdit
function. This function will be triggered when the button is clicked. Here's a sample code snippet:
javascript
function saveAndEdit() {
var record = currentRecord.get();
var recordId = record.save();
if (recordId) {
var url = url.resolveRecord({
recordType: record.type,
recordId: recordId,
isEditMode: true
});
window.location = url;
}
}
In this code, the current record is saved and then the page is redirected to the edit mode of the saved record.
Please note that this is a simplified example and you may need to adjust the code to fit your specific needs.
******
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
10/22/2024, 8:42 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854895
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849112
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836581409
Celigo AI
10/22/2024, 8:42 AM