
I am using the following code, when i run the dialog i can see the dialog, choose values in it but for some reason no values are saved,i.e. in debugger it shows " " for all my variables in which i m storing the dialog field value.
Pls suggests how to fix this.
static void ProjIdUpdate(Args _args)
{
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogfieldLegalEntity,dialogfieldCurProjId,dialogfieldNewProjId;
ProjTable projTable;
ProjId curProjId,newProjId;
DataAreaId dataAreaId;
dialog = new dialog ("Update Project ID");
dialogGroup = dialog.addGroup("Choose legal entity");
dialogfieldLegalEntity = dialog.addField(extendedTypeStr(DataAreaId));
dataAreaId = dialogfieldLegalEntity.value();
dialogGroup = dialog.addGroup("Enter Proj id to be updated");
dialogfieldCurProjId = dialog.addField(extendedTypeStr(ProjId));
dialogfieldCurProjId.lookupButton(1);
curProjId = dialogfieldCurProjId.value();
dialogGroup = dialog.addGroup("Enter new value for Proj id");
dialogfieldNewProjId = dialog.addField(extendedTypeStr(ProjId),"New Proj Id","Enter new Proj id");
dialogfieldNewProjId.lookupButton(1);
newProjId = dialogfieldNewProjId.value();
dialog.run();
try
{
if(dialog.closedOk())
{
select forUpdate projTable where projTable.ProjId == curProjId && projTable.dataAreaId == dataAreaId;
if (projTable)
{
ttsBegin;
projTable.ProjId = newProjId;
projTable.update();
ttsCommit;
info("Proj id has been updaated to " projTable.ProjId);
}
pause;
}
}
catch(Exception::Error)
{
info("Caught 'Exception::Error'.");
}
}
Hi Mav,
You need to retrieve the dialog values after the dialog was closed with the OK action. Now you do it before the dialog runs, so indeed the values are empty. Try this:
static void ProjIdUpdate(Args _args)
{
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogfieldLegalEntity,dialogfieldCurProjId,dialogfieldNewProjId;
ProjTable projTable;
ProjId curProjId,newProjId;
DataAreaId dataAreaId;
dialog = new dialog ("Update Project ID");
dialogGroup = dialog.addGroup("Choose legal entity");
dialogfieldLegalEntity = dialog.addField(extendedTypeStr(DataAreaId));
dataAreaId = dialogfieldLegalEntity.value();
dialogGroup = dialog.addGroup("Enter Proj id to be updated");
dialogfieldCurProjId = dialog.addField(extendedTypeStr(ProjId));
dialogfieldCurProjId.lookupButton(1);
dialogGroup = dialog.addGroup("Enter new value for Proj id");
dialogfieldNewProjId = dialog.addField(extendedTypeStr(ProjId),"New Proj Id","Enter new Proj id");
dialogfieldNewProjId.lookupButton(1);
dialog.run();
try
{
if(dialog.closedOk())
{
curProjId = dialogfieldCurProjId.value();
newProjId = dialogfieldNewProjId.value();
select forUpdate projTable where projTable.ProjId == curProjId && projTable.dataAreaId == dataAreaId;
if (projTable)
{
ttsBegin;
projTable.ProjId = newProjId;
projTable.update();
ttsCommit;
info("Proj id has been updaated to " projTable.ProjId);
}
pause;
}
}
catch(Exception::Error)
{
info("Caught 'Exception::Error'.");
}
}