I’ve built a custom scripting extension that I intend to launch from a record button, send that record’s ID to the extension, and execute my script. I configured the button to launch my extension, which it does, but I can’t seem to get it to register the ID of the record clicked. I’ve tried using both useRecordActionData and registerRecordActionDataCallback, the latter example can be found below:
function CheckAvailability() {
const recordActionData, setRecordActionData] = useState(null);
const callback = useCallback((data) => {
console.log('Record action received', data);
setRecordActionData(data);
}, ])
useEffect(() => {
const unsubscribe = registerRecordActionDataCallback((data) => {
console.log('Record action received:', data);
if (data && data.recordId) {
console.log(`Button pressed on record: ${data.recordId}`);
// Process data here
} else {
console.error('No recordId found in action data');
}
});
console.log('Callback registered.');
return () => unsubscribe();
}, callback]);
return (
<ul>
<li>Record id: {recordActionData.recordId}</li>
<li>View id: {recordActionData.viewId}</li>
<li>Table id: {recordActionData.tableId}</li>
</ul>
);
}
initializeBlock(() => <CheckAvailability />);
I’ve tried numerous variations of the code to register the callback and set the current record info, but no luck getting anything to work. No matter what I do, the button will only launch the extension and nothing more. And unfortunately, I cannot use a simple Run Script action because my full script utilizes other libraries to perform it actions. How can I fix this to accept the Record ID on button click, or is that even possible with custom script extension built using the Extensions SDK?