Can anyone tell me what should I do in X++ to get a NOT null value from args.record().datasource() method after executing the following statements:
PurchTable purchTable;
args.record(purchTable);
if(args.record().datasource()) //this condition fails because of null value
{
//I have to reach here
}
I know that the same code works fine when it is called from Form but my scenario is that I have to execute this code from within X++. Please help!
args.record().datasource() will retrieve a form datasource. Here, you are using a table buffer only. That's why you don't have anything.
If you want to retrieve the table buffer, you might go this way:
PurchTable purchTable;
PurchTable argPurchTable;
select firstOnly purchTable;
args.record(purchTable);
if (args.record() && args.dataset() == tableNum(PurchTable))
{
argPurchTable = args.record();
//do something
}
Regards,
Geoffrey