
Runner.pages.PageSettings.addPageEvent( 
	"replacement_request", 
	"add", 
	"afterPageReady", 
	function(pageObj, proxy, pageid, inlineRow, inlineObject, row ) {
		// Place event code here.
// Use "Add Action" button to add code snippets.

// Place event code here.
// Use "Add Action" button to add code snippets.

setTimeout(function() {

    var ctrlReferenceNo = Runner.getControl(pageid, "replacement_no");

    if (!ctrlReferenceNo) {
        console.log("Reference Number control not found.");
        return;
    }

    if (proxy["preview_reference_number"]) {
        ctrlReferenceNo.setValue(proxy["preview_reference_number"]);
    }

    // Optional: make it readonly
    ctrlReferenceNo.setDisabled();

}, 500);



this.on('beforeSave', function(formObj, fieldControlsArr, pageObj) {

    var ctrlref = Runner.getControl(pageid, "replacement_no");


    if (ctrlref) {
        ctrlref.setEnabled();
    }

   
    return true;
});
});







