Problem with script

Hi,

IDEA: generate Entity.AfterScript after button is pressed

The script is:

function TntButton1OnClick ()
{

var Log = System.CreateObject(‘Log’);

Log.Information (“Button - START”);
Log.Information(Entity.Name);
Log.Information ("Script before change: " + Entity.AfterScript);
// new value
Entity.AfterScript = "select * from " + Entity.Schema.Name + “.” + Entity.Name + “;”;

Log.Information ("Script after change: " + Entity.AfterScript);

Log.Information (“Button - END”);
}

Message Explorer messages:
1 | 2009-01-22 16:34:08 | Script has been finished | | 1005 | 1 | 3672| 1
2 | 2009-01-22 16:46:09 | Button - START | | 1002 | 1 | 5528| 2
3 | 2009-01-22 16:46:09 | TST_AK_DANE_PRODUKTY | | 1002 | 1 | 5528| 2
4 | 2009-01-22 16:46:09 | Script before change: – NO SCRIPT
– NO SCRIPT at ALL

| | 1002 | 1 | 5528| 2
5 | 2009-01-22 16:46:09 | Script after change: select * from DB2TEST.TST_AK_DANE_PRODUKTY; | | 1002 | 1 | 5528| 2
6 | 2009-01-22 16:46:09 | Button - END | | 1002 | 1 | 5528| 2

It seems to be O.K. but …
AfterScript was not changed (!!!) - images attached.

What error I’ve done ?

Adam
image003.jpeg

Hi,

The answer is:

function TntButton1OnClick ()
{

var Log = System.CreateObject(‘Log’);
var Model = Entity.Root();
var OrigEntity = Model.Entities.GetObjectById( Entity.Id );

// from Vaclav

// How To Use Combo Boxes in Customized Forms

// Thursday, July 31st, 2008
// We need to read original object. ‘Synonym’ is only a temporary
// object (created when a form is edited) that that doesn’t have
// all properties loaded/filled.

Log.Information (“Button - START”);
Log.Information(OrigEntity.Name);
Log.Information ("Script before change: " + OrigEntity.AfterScript);
// new value
OrigEntity.AfterScript = “select * from " + OrigEntity.Schema.Name + “.” + OrigEntity.Name + " order by 1;”;

Log.Information ("Script after change: " + OrigEntity.AfterScript);

Log.Information (“Button - END”);
}

Thank You,

Adam