...
Code Block |
---|
language | js |
---|
firstline | 1 |
---|
title | New method in generic-record-handling.js |
---|
|
/*
* Used in EventToolbarGo Attribute for dialog Windows.
* Saves a record and closed the dialog
* Note: This is an alternative to SaveNewRecord which
* automatically saves the change, closes the dialog and
* opens the record in a new details window.
*/
akioma.osiv.saveRecordInDialogAndClose = function(self) {
console.log(self,'saveRecordInDialogAndClose');
var oBE = self.container.getLink('PRIMARYSDO:TARGET').controller;
//Find record and Save it
oBE.updateRecord({});
oBE.cleanSaveChangesOnceEvts();
oBE.addAfterSaveChangesOnceCallback(function(success){
// Close Dialogbox
if(success && self.container.controller && self.container.controller.close)
self.container.controller.close();
});
};?? |
In the Main calling window (In this case sStammDetailWindow) create a NEW menu ribbon option:
Do this using the Menu Maintenance and Menu Functions as normal in SmartFramework Menu
Image Added
Action Type: RUN
Action Parameter: $ akioma.osiv.openNewRecordDialogFK(self,'sProtokollCreateDialogWindow','$ akioma.osiv.setForeignKeyCalcMethodStamm_ID (self)')
Where akioma.osiv.openNewRecordDialogFK I have created in Generic-record-handlings.js It saves the record, checks for errors, and if there are none closes the Dialog Window.
'sProtokollCreateDialogWindow Is the name of your NewRecord dialog window
akioma.osiv.setForeignKeyCalcMethodStamm_ID (self)') Is a JS code to set the Stamm_ID in the Initial values If you need another field, then create your own method.
Set Foreign-Keys for Linking records
Code Block |
---|
language | js |
---|
title | Function in Protokoll.js file |
---|
|
// call method for Stamm_ID for foreignkeys new record in panel
akioma.osiv.setForeignKeyCalcMethodStamm_ID = function(self){
var aForeignKeys = [{
name: 'Stamm_ID',
value: "" + self.container.getLink("PRIMARYSDO:TARGET").getValue("stamm_id")
}];
return aForeignKeys;
}; |
Refreshing the Grid
In order that the ProtokollQuery Grid is updated when a new record is created do the following.
In the main window,, in this case sStammDetailWindow, find the Protokoll DSO and Add an EventAfterSave: $ akioma.osiv.RefreshProtokollQuery(self)
Code Block |
---|
language | js |
---|
title | The event Method in protokoll.js. |
---|
|
//Refresh ProtokollQuery Browse z.b. nach Create, Update, Kopieren, L??schen
akioma.osiv.RefreshProtokollQuery = function(self){
akioma.eventEmitter.emit(["dataChanged", 'eProtokollQuery']);
}; |
Save
Code Block |
---|
language | js |
---|
title | ProtokollSave method from the Menu Function |
---|
|
/**
* Used in menu function to save the Protokoll record from the Stamm Ribbon menu
*/
akioma.osiv.ProtokollSave = function(self){
var oBE = self.container.getObject('dProtokollDSO');
// update
oBE.controller.updateRecord({});
}; |
Copy
Code Block |
---|
language | js |
---|
title | Select the following code from the Menu Function |
---|
|
/**
* Used in menu function to copy the Protokoll record from the Stamm Ribbon menu
*/
akioma.osiv.ProtokollKopieren = function(ribbon){
console.log("ProtokollKopieren");
var oBE = ribbon.container.getObject('dProtokollDSO');
// Copy
//Set the initial values
akioma.osiv.setForeignKeyCalcMethodStamm_ID(ribbon);
//launch a container
var cSelectedHdl = oBE.getValue('selfhdl');
var cRepoName = 'sProtokollCreateDialogWindow';
var promise = app.controller.launchContainer( {
proc: "launchContainer.r",
para: "RunFile=" + cRepoName + "&Page=*",
data: true,
async: true
} );
promise.done(function(oRes){
var BE = oRes.dynObject.getLink("PRIMARYSDO:TARGET").controller;
BE.stop = true;
// wait for catalog load and then getInitialValues copyRecord
BE.addAfterCatalogAdd(function(){
BE.copyRecord(cSelectedHdl);
});
});
}; |
Delete
Code Block |
---|
|
/**
* Used in menu function to save the Protokoll record from the Stamm Ribbon menu
*/
akioma.osiv.ProtokollDelete = function(Ribbon){
console.log ("ProtokollDelete");
// Find Protokoll
const oBE = Ribbon.container.getObject('dProtokollDSO');
var InPapierkorb = oBE.getValue('geloescht');
if (InPapierkorb != true) {
akioma.message("L??schen nicht m??glich weil Protokoll ist nicht im Papierkorb!");
return;
};
// Delete record
// oBE.controller.deleteRecord({});
akioma.osiv.deleteRecord (oBE);
}; |